[jboss-cvs] JBossAS SVN: r106479 - in branches/JBPAPP_5_1/security/src/main/org/jboss/security: plugins and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 6 17:39:31 EDT 2010
Author: mmoyses
Date: 2010-07-06 17:39:30 -0400 (Tue, 06 Jul 2010)
New Revision: 106479
Modified:
branches/JBPAPP_5_1/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java
branches/JBPAPP_5_1/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java
Log:
JBPAPP-8025: fixing setting of custom SecurityManager and CallbackHandler classes
Modified: branches/JBPAPP_5_1/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java
===================================================================
--- branches/JBPAPP_5_1/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java 2010-07-06 21:18:33 UTC (rev 106478)
+++ branches/JBPAPP_5_1/security/src/main/org/jboss/security/integration/JNDIBasedSecurityManagement.java 2010-07-06 21:39:30 UTC (rev 106479)
@@ -231,6 +231,7 @@
public void setAuthenticationMgrClass(String authenticationMgrClass)
{
this.authenticationMgrClass = authenticationMgrClass;
+ securityMgrMap.clear();
}
@ManagementProperty(use = {ViewUse.CONFIGURATION},
Modified: branches/JBPAPP_5_1/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java
===================================================================
--- branches/JBPAPP_5_1/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java 2010-07-06 21:18:33 UTC (rev 106478)
+++ branches/JBPAPP_5_1/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java 2010-07-06 21:39:30 UTC (rev 106479)
@@ -49,6 +49,7 @@
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
import javax.security.jacc.PolicyContext;
import org.jboss.logging.Logger;
@@ -127,6 +128,8 @@
/** Frequency of the thread cleaning the authentication cache of expired entries */
private static int defaultCacheFlushPeriod = 60*60;
+ private static JNDIBasedSecurityManagement securityManagement = SecurityConstantsBridge.getSecurityManagement();
+
static
{
// Get a log interface, required for some statics below
@@ -160,7 +163,7 @@
throws ClassNotFoundException, ClassCastException
{
securityMgrClassName = className;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
securityMgrClass = loader.loadClass(securityMgrClassName);
if( AuthenticationManager.class.isAssignableFrom(securityMgrClass) == false )
throw new ClassCastException(securityMgrClass+" does not implement "+AuthenticationManager.class);
@@ -173,7 +176,7 @@
throws ClassNotFoundException
{
securityProxyFactoryClassName = className;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
securityProxyFactoryClass = loader.loadClass(securityProxyFactoryClassName);
}
@@ -192,7 +195,7 @@
throws ClassNotFoundException
{
callbackHandlerClassName = className;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
callbackHandlerClass = loader.loadClass(callbackHandlerClassName);
}
@@ -496,7 +499,14 @@
return null;
}
});
+ CallbackHandler callbackHandler = null;
+ callbackHandler = (CallbackHandler) callbackHandlerClass.newInstance();
+ if (callbackHandler != null)
+ securityManagement.setCallBackHandler(callbackHandler);
}
+
+ // Set AuthenticationManager class
+ securityManagement.setAuthenticationMgrClass(securityMgrClassName);
// Register the Principal property editor
PropertyEditorManager.registerEditor(Principal.class, PrincipalEditor.class);
@@ -764,4 +774,15 @@
return cachePolicy;
}
}
+
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
}
More information about the jboss-cvs-commits
mailing list