geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiam...@apache.org
Subject svn commit: r1222620 - /geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
Date Fri, 23 Dec 2011 09:34:03 GMT
Author: xiaming
Date: Fri Dec 23 09:34:02 2011
New Revision: 1222620

URL: http://svn.apache.org/viewvc?rev=1222620&view=rev
Log:
GERONIMO-6244 Port GERONIMO-4801 fix into 3.0-beta for JACC manager gbean already present
issue

Modified:
    geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java

Modified: geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java?rev=1222620&r1=1222619&r2=1222620&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
Fri Dec 23 09:34:02 2011
@@ -49,6 +49,7 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
@@ -220,13 +221,20 @@ public class GeronimoSecurityBuilderImpl
         if (earContext.isHasSecurity()) {
             //Be sure to only set once per app
             earContext.setHasSecurity(false);
-            AbstractNameQuery roleMapperDataName = ROLE_MAPPER_DATA_NAME.get(earContext.getGeneralData());
+            AbstractName applicationPolicyManagerName = earContext.getNaming().createChildName(earContext.getModuleName(),
SecurityNames.JACC_MANAGER, SecurityNames.JACC_MANAGER);
+            //TODO A better way to avoid the multiple invocation on securityBuilder.addGBeans
?
+            try {
+                if (earContext.getGBeanInstance(applicationPolicyManagerName) != null) {
+                    return;
+                }
+            } catch (GBeanNotFoundException e1) {
+            }
+            AbstractNameQuery roleMapperDataName = (AbstractNameQuery)earContext.getGeneralData().get(ROLE_MAPPER_DATA_NAME);
             if (roleMapperDataName == null) {
                 roleMapperDataName = defaultRoleMappingName;
                 EnvironmentBuilder.mergeEnvironments(earContext.getConfiguration().getEnvironment(),
defaultEnvironment);
             }
-            Naming naming = earContext.getNaming();
-            GBeanData jaccBeanData = configureApplicationPolicyManager(naming, earContext.getModuleName(),
earContext.getContextIDToPermissionsMap());
+            GBeanData jaccBeanData = configureApplicationPolicyManager(applicationPolicyManagerName,
earContext.getContextIDToPermissionsMap());
             jaccBeanData.setReferencePattern("PrincipalRoleMapper", roleMapperDataName);
             try {
                 earContext.addGBean(jaccBeanData);
@@ -344,9 +352,8 @@ public class GeronimoSecurityBuilderImpl
         return new AbstractNameQuery(roleMapperData.getAbstractName());
     }
 
-    protected GBeanData configureApplicationPolicyManager(Naming naming, AbstractName moduleName,
Map<String, ComponentPermissions> contextIDToPermissionsMap) {
-        AbstractName jaccBeanName = naming.createChildName(moduleName, SecurityNames.JACC_MANAGER,
SecurityNames.JACC_MANAGER);
-        GBeanData jaccBeanData = new GBeanData(jaccBeanName, ApplicationPolicyConfigurationManager.GBEAN_INFO);
+    protected GBeanData configureApplicationPolicyManager(AbstractName applicationPolicyManagerName,
Map<String, ComponentPermissions> contextIDToPermissionsMap) {        
+        GBeanData jaccBeanData = new GBeanData(applicationPolicyManagerName, ApplicationPolicyConfigurationManager.GBEAN_INFO);
         jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap);
         return jaccBeanData;
     }



Mime
View raw message