Revision 6932
Added by Matt Jones over 12 years ago
AuthSession.java | ||
---|---|---|
38 | 38 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
39 | 39 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
40 | 40 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
41 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
41 | 42 |
|
42 | 43 |
/** |
43 | 44 |
* A Class that implements session tracking for MetaCatServlet users. |
... | ... | |
54 | 55 |
|
55 | 56 |
/** |
56 | 57 |
* Construct an AuthSession |
58 |
* @throws ClassNotFoundException |
|
59 |
* @throws IllegalAccessException |
|
60 |
* @throws InstantiationException |
|
57 | 61 |
*/ |
58 |
public AuthSession() throws Exception { |
|
62 |
public AuthSession() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
|
59 | 63 |
// Determine our session authentication method and |
60 | 64 |
// create an instance of the auth class |
61 |
this.authClass = PropertyService.getProperty("auth.class"); |
|
65 |
try { |
|
66 |
this.authClass = PropertyService.getProperty("auth.class"); |
|
67 |
} catch (PropertyNotFoundException e) { |
|
68 |
// TODO Auto-generated catch block |
|
69 |
e.printStackTrace(); |
|
70 |
} |
|
62 | 71 |
this.authService = (AuthInterface) createObject(authClass); |
63 | 72 |
} |
64 | 73 |
|
... | ... | |
265 | 274 |
* |
266 | 275 |
* @param className the fully qualified name of the class to instantiate |
267 | 276 |
*/ |
268 |
private static Object createObject(String className) throws Exception { |
|
277 |
private static Object createObject(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
|
269 | 278 |
|
270 | 279 |
Object object = null; |
271 |
try { |
|
280 |
// try {
|
|
272 | 281 |
Class classDefinition = Class.forName(className); |
273 | 282 |
object = classDefinition.newInstance(); |
274 |
} catch (InstantiationException e) { |
|
275 |
throw e; |
|
276 |
} catch (IllegalAccessException e) { |
|
277 |
throw e; |
|
278 |
} catch (ClassNotFoundException e) { |
|
279 |
throw e; |
|
280 |
} |
|
283 |
// } catch (InstantiationException e) {
|
|
284 |
// throw e;
|
|
285 |
// } catch (IllegalAccessException e) {
|
|
286 |
// throw e;
|
|
287 |
// } catch (ClassNotFoundException e) {
|
|
288 |
// throw e;
|
|
289 |
// }
|
|
281 | 290 |
return object; |
282 | 291 |
} |
283 | 292 |
|
Also available in: Unified diff
Refactoring classes that throw generic Exception class to throw their more specific subclasses so that new exceptions are not hidden behind generic messages. Makes debugging easier.