roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r438727 - in /incubator/roller/branches/roller_3.0: src/org/apache/roller/ui/core/ src/org/apache/roller/ui/core/security/ web/WEB-INF/classes/
Date Thu, 31 Aug 2006 00:23:59 GMT
Author: eliast
Date: Wed Aug 30 17:23:58 2006
New Revision: 438727

URL: http://svn.apache.org/viewvc?rev=438727&view=rev
Log:
As per Allen's suggestions:
- Refactored getAutoProvision from AutoProvisionHelper to RollerContext.
- Moved check for .autoProvision.enabled inside RollerSession

Removed:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/security/AutoProvisioningHelper.java
Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerContext.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerSession.java
    incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerContext.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerContext.java?rev=438727&r1=438726&r2=438727&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerContext.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerContext.java
Wed Aug 30 17:23:58 2006
@@ -54,6 +54,7 @@
 import org.apache.roller.model.ScheduledTask;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.ui.core.pings.PingQueueTask;
+import org.apache.roller.ui.core.security.AutoProvision;
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.velocity.runtime.RuntimeSingleton;
 import org.springframework.context.ApplicationContext;
@@ -473,6 +474,49 @@
     /** Get username that built Roller */
     public String getRollerBuildUser() {
         return mBuildUser;
+    }
+    
+    /**
+     * Get an instance of AutoProvision, if available in roller.properties
+     * 
+     * @return AutoProvision
+     */
+    public static AutoProvision getAutoProvision() {
+      
+      String clazzName = RollerConfig.getProperty("users.sso.autoProvision.className");
+      
+      if(null == clazzName) {
+        return null;
+      }
+      
+      Class clazz;
+      try {
+        clazz = Class.forName(clazzName);
+      } catch (ClassNotFoundException e) {
+        mLogger.warn("Unable to found specified Auto Provision class.", e);
+        return null;
+      }
+      
+      if(null == clazz) {
+        return null;
+      }
+      
+      Class[] interfaces = clazz.getInterfaces();
+      for (int i = 0; i < interfaces.length; i++) {
+          if (interfaces[i].equals(AutoProvision.class))
+          {
+            try {
+              return (AutoProvision) clazz.newInstance();
+            } catch (InstantiationException e) {
+              mLogger.warn("InstantiationException while creating: " + clazzName, e);
+            } catch (IllegalAccessException e) {
+              mLogger.warn("IllegalAccessException while creating: " + clazzName, e);
+            }
+          }
+      }
+      
+      return null;
+      
     }
 
 }

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerSession.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerSession.java?rev=438727&r1=438726&r2=438727&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerSession.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/RollerSession.java
Wed Aug 30 17:23:58 2006
@@ -30,12 +30,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerConfig;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.PermissionsData;
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.core.security.AutoProvisioningHelper;
+import org.apache.roller.ui.core.security.AutoProvision;
 
 
 //////////////////////////////////////////////////////////////////////////////
@@ -85,13 +86,19 @@
 
                     // try one time to auto-provision, only happens if user==null
                     // which means installation has SSO-enabled in security.xml
-                    if(user == null) 
-                    {
-                        if(AutoProvisioningHelper.executeAutoProvisioning()) {
-                          user = umgr.getUserByUserName(principal.getName());
-                        }
-                    } 
-                    
+                     if(user == null && RollerConfig.getBooleanProperty("users.sso.autoProvision.enabled"))
{                    
+                       // provisioning enabled, get provisioner and execute
+                       AutoProvision provisioner = RollerContext.getAutoProvision();
+                       if(provisioner != null) 
+                       {
+                           boolean userProvisioned = provisioner.execute();
+                           if(userProvisioned) 
+                           {
+                               // try lookup again real quick
+                               user = umgr.getUserByUserName(principal.getName());
+                           }
+                       }
+                     }
                     // only set authenticated user if user is enabled
                     if(user != null && user.getEnabled().booleanValue()) 
                     {

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties?rev=438727&r1=438726&r2=438727&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties Wed Aug 30
17:23:58 2006
@@ -427,7 +427,7 @@
 users.sso.passwords.defaultValue=<unknown>
 
 users.sso.autoProvision.enabled=false
-users.sso.autoProvision.class=org.apache.roller.ui.core.security.BasicUserAutoProvision
+users.sso.autoProvision.className=org.apache.roller.ui.core.security.BasicUserAutoProvision
 
 #----------------------------------
 # misc settings



Mime
View raw message