[Yanel-commits] rev 30786 - public/yanel/trunk/src/core/java/org/wyona/yanel/core/map

michi at wyona.com michi at wyona.com
Sat Jan 26 07:26:51 CET 2008


Author: michi
Date: 2008-01-26 07:26:49 +0100 (Sat, 26 Jan 2008)
New Revision: 30786

Modified:
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/Realm.java
Log:
set and init Default WebAuthenticator if there is no custom WebAuthenticator configured for a realm

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/Realm.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/Realm.java	2008-01-25 15:23:54 UTC (rev 30785)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/Realm.java	2008-01-26 06:26:49 UTC (rev 30786)
@@ -154,18 +154,24 @@
 
         // Set WebAuthenticator for this realm
         Configuration waConfigElement = config.getChild("web-authenticator", false);
+        WebAuthenticator wa = null;
         if (waConfigElement != null) {
-            WebAuthenticator wa = null;
             try {
             	String customWebAuthenticatorImplClassName = waConfigElement.getAttribute("class");
             	wa = (WebAuthenticator) Class.forName(customWebAuthenticatorImplClassName).newInstance();
-
                 wa.init(ConfigurationUtil.getCustomConfiguration(waConfigElement, "web-authenticator-config", "http://www.wyona.org/security/1.0"), new RealmConfigPathResolver(this));
+                log.info("Custom WebAuthenticator (" + customWebAuthenticatorImplClassName + ") will be used!");
             } catch (ConfigurationException e) {
-                wa = null;
+                log.error(e, e);
+                log.warn("Default WebAuthenticator will be used!");
+                wa = getDefaultWebAuthenticator();
+                wa.init(null, new RealmConfigPathResolver(this));
             }
-            setWebAuthenticator(wa);
+        } else {
+            wa = getDefaultWebAuthenticator();
+            wa.init(null, new RealmConfigPathResolver(this));
         }
+        setWebAuthenticator(wa);
 
 
 
@@ -478,4 +484,13 @@
         log.warn("Shutdown realm: " + getName());
         getRepository().close();
     }
+
+    /**
+     * Get Default WebAuthenticator
+     */
+    private WebAuthenticator getDefaultWebAuthenticator() throws Exception {
+        // TODO: Get this setting from spring config
+        String defaultWebAuthenticatorImplClassName = "org.wyona.yanel.servlet.security.impl.DefaultWebAuthenticatorImpl";
+        return (WebAuthenticator) Class.forName(defaultWebAuthenticatorImplClassName).newInstance();
+    }
 }



More information about the Yanel-commits mailing list