From 71a0faf829bed446b5900d38dedc945f8dbaaedb Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Sun, 28 Mar 2004 12:05:12 +0000 Subject: [PATCH] Enhanced error detection at startup time. Changed no-arg constructor to better support unit testing. JavaDoced method. --- .../adapters/jetty/JettyAcegiUserRealm.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/adapters/jetty/src/main/java/org/acegisecurity/adapters/jetty/JettyAcegiUserRealm.java b/adapters/jetty/src/main/java/org/acegisecurity/adapters/jetty/JettyAcegiUserRealm.java index 5bbe102adb..ae2b941695 100644 --- a/adapters/jetty/src/main/java/org/acegisecurity/adapters/jetty/JettyAcegiUserRealm.java +++ b/adapters/jetty/src/main/java/org/acegisecurity/adapters/jetty/JettyAcegiUserRealm.java @@ -73,6 +73,24 @@ public final class JettyAcegiUserRealm implements UserRealm { this.realm = realm; 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); Map beans = ctx.getBeansOfType(AuthenticationManager.class, true, true); @@ -85,8 +103,8 @@ public final class JettyAcegiUserRealm implements UserRealm { authenticationManager = (AuthenticationManager) beans.get(beanName); } - private JettyAcegiUserRealm() { - super(); + protected JettyAcegiUserRealm() { + throw new IllegalArgumentException("Cannot use default constructor"); } //~ 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 * SpringUserRealm was created