Enhanced error detection at startup time. Changed no-arg constructor to better support unit testing. JavaDoced method.

This commit is contained in:
Ben Alex 2004-03-28 12:05:12 +00:00
parent c5951ff1c0
commit 71a0faf829
1 changed files with 21 additions and 3 deletions

View File

@ -73,6 +73,24 @@ public final class JettyAcegiUserRealm implements UserRealm {
this.realm = realm; this.realm = realm;
this.key = providerKey; this.key = providerKey;
if ((realm == null) || "".equals(realm)) {
throw new IllegalArgumentException("realm must be specified");
}
if ((key == null) || "".equals(key)) {
throw new IllegalArgumentException("key must be specified");
}
if ((appContextLocation == null) || "".equals(appContextLocation)) {
throw new IllegalArgumentException(
"appContextLocation must be specified");
}
if (Thread.currentThread().getContextClassLoader().getResource(appContextLocation) == null) {
throw new IllegalArgumentException("Cannot locate "
+ appContextLocation);
}
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(appContextLocation); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(appContextLocation);
Map beans = ctx.getBeansOfType(AuthenticationManager.class, true, true); Map beans = ctx.getBeansOfType(AuthenticationManager.class, true, true);
@ -85,8 +103,8 @@ public final class JettyAcegiUserRealm implements UserRealm {
authenticationManager = (AuthenticationManager) beans.get(beanName); authenticationManager = (AuthenticationManager) beans.get(beanName);
} }
private JettyAcegiUserRealm() { protected JettyAcegiUserRealm() {
super(); throw new IllegalArgumentException("Cannot use default constructor");
} }
//~ Methods ================================================================ //~ Methods ================================================================
@ -96,7 +114,7 @@ public final class JettyAcegiUserRealm implements UserRealm {
} }
/** /**
* DOCUMENT ME! * Accesses the realm name.
* *
* @return the name of the realm as defined when * @return the name of the realm as defined when
* <code>SpringUserRealm</code> was created * <code>SpringUserRealm</code> was created