[jboss-cvs] JBossAS SVN: r65834 - trunk/security/src/main/org/jboss/security/integration.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 4 07:08:45 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-10-04 07:08:45 -0400 (Thu, 04 Oct 2007)
New Revision: 65834

Modified:
   trunk/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java
Log:
CachePolicy on the auth mgr

Modified: trunk/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java
===================================================================
--- trunk/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java	2007-10-04 11:07:30 UTC (rev 65833)
+++ trunk/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java	2007-10-04 11:08:45 UTC (rev 65834)
@@ -22,6 +22,7 @@
 package org.jboss.security.integration;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.Context;
@@ -192,8 +193,11 @@
    
    public SecurityDomainContext createSecurityDomainContext(String domain) throws Exception
    {
-      SecurityDomainContext securityDomainContext = new SecurityDomainContext(createAuthenticationManager(domain), 
-            (CachePolicy)createObject(this.cachePolicyName)); 
+      CachePolicy cachePolicy = (CachePolicy)createObject(this.cachePolicyName);
+      cachePolicy.create();
+      AuthenticationManager am = createAuthenticationManager(domain);
+      setSecurityDomainCache(am, cachePolicy);
+      SecurityDomainContext securityDomainContext = new SecurityDomainContext(am, cachePolicy); 
       
       securityDomainContext.setAuthorizationManager(createAuthorizationManager(domain));
       securityDomainContext.setAuditMgr(createAuditManager(domain));
@@ -278,4 +282,27 @@
       Class clazz = SecurityActions.getContextClassLoader().loadClass(fqn);
       return clazz.newInstance();
    }
+   
+   /** Use reflection to attempt to set the authentication cache on the
+    * securityMgr argument.
+    * @param securityMgr the security manager
+    * @param cachePolicy the cache policy implementation
+    */
+   private static void setSecurityDomainCache(AuthenticationManager securityMgr,
+      CachePolicy cachePolicy)
+   {
+      try
+      {
+         Class[] setCachePolicyTypes = {CachePolicy.class};
+         Method m = securityMgr.getClass().getMethod("setCachePolicy", setCachePolicyTypes);
+         Object[] setCachePolicyArgs = {cachePolicy};
+         m.invoke(securityMgr, setCachePolicyArgs);
+         log.debug("setCachePolicy, c="+setCachePolicyArgs[0]);
+      }
+      catch(Exception e2)
+      {    
+         if(log.isTraceEnabled())
+            log.trace("Optional setCachePolicy failed" + e2.getLocalizedMessage());
+      }
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list