[Jboss-cvs] JBossAS SVN: r56348 - trunk/ejb3/src/main/org/jboss/ejb3/embedded

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 28 12:10:26 EDT 2006


Author: wolfc
Date: 2006-08-28 12:10:22 -0400 (Mon, 28 Aug 2006)
New Revision: 56348

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
Log:
Fixed usage of AuthorizationManager (JBAS-3535)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java	2006-08-28 16:09:44 UTC (rev 56347)
+++ trunk/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java	2006-08-28 16:10:22 UTC (rev 56348)
@@ -25,7 +25,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.security.auth.callback.SecurityAssociationHandler;
 import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.plugins.JBossAuthorizationManager;
 import org.jboss.security.plugins.JaasSecurityManager;
+import org.jboss.security.plugins.SecurityDomainContext;
 
 import javax.naming.*;
 import javax.naming.spi.ObjectFactory;
@@ -74,18 +76,6 @@
 
       Context ctx = getInitialContext();
 
-//		ctx = (Context) ctx.lookup("java:");
-//		ctx = ctx.createSubcontext("jaas");
-//		//ctx.bind("other", new MyAuthenticationManager("other"));
-//		NonSerializableFactory.rebind(ctx, "other", new JaasSecurityManager("other", new SecurityAssociationHandler()));
-//		//ctx.bind("other", new JaasSecurityManager("other", new SecurityAssociationHandler()));
-
-//		RefAddr refAddr = new StringRefAddr("nns", "JSM");
-//		String factoryName = SecurityDomainObjectFactory.class.getName();
-//		Reference ref = new Reference("javax.naming.Context", refAddr, factoryName, null);
-//		ctx.rebind(SECURITY_MGR_PATH, ref);
-
-      //RefAddr refAddr = new StringRefAddr("nns", "JSM");
       String factoryName = SecurityDomainObjectFactory.class.getName();
       Reference ref = new Reference("nl.wolfc.embedded.security.plugins.JaasSecurityManager", factoryName, null);
       ctx.rebind(SECURITY_MGR_PATH, ref);
@@ -112,17 +102,28 @@
 
    public static class SecurityDomainObjectFactory implements ObjectFactory
    {
+      @SuppressWarnings("unused")
+      private static final Logger log = Logger.getLogger(SecurityDomainObjectFactory.class);
+      
       public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
       {
+         String securityDomainName = name.get(0);
+         final SecurityDomainContext ctx = new SecurityDomainContext(getSecurityManager(securityDomainName), null);
+         ctx.setAuthorizationManager(new JBossAuthorizationManager(securityDomainName, new SecurityAssociationHandler()));
          return new BrainlessContext()
          {
             public Object lookup(Name name) throws NamingException
             {
-               return lookup(name.get(0));
+               log.debug("lookup " + name);
+               if(name.size() < 2)
+                  return lookup(name.get(0));
+               else
+                  return ctx.lookup(name.get(1));
             }
 
             public Object lookup(String name) throws NamingException
             {
+               log.debug("lookup " + name);
                return getSecurityManager(name);
             }
          };




More information about the jboss-cvs-commits mailing list