geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r939982 [1/3] - in /geronimo/server/trunk: framework/modules/ framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingpr...
Date Sat, 01 May 2010 11:51:08 GMT
Author: xuhaihong
Date: Sat May  1 11:51:06 2010
New Revision: 939982

URL: http://svn.apache.org/viewvc?rev=939982&view=rev
Log:
a. Calculate web permissions while starting the web module to support setServletSecurity feature in Servlet 3.0
b. Initial support ServletContainerInitializer, some improvements might be needed, such as use ASM ?
c. Support ORDERED_LIBS ServletContext attribute 

Added:
    geronimo/server/trunk/plugins/j2ee/geronimo-web/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/pom.xml   (with props)
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebAttributeName.java   (with props)
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/
      - copied from r939221, geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/geronimo/web/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/geronimo/web/security/
      - copied from r939221, geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/security/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/resources/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/resources/security/
      - copied from r939221, geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/resources/security/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/resources/security/web-nosecurity.xml   (with props)
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.java   (with props)
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationServletRegistrationAdapter.java   (with props)
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/listener/JACCSecurityLifecycleListener.java   (with props)
Removed:
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/HTTPMethods.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/SpecSecurityBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/URLPattern.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/URLPatternCheck.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/UncheckedItem.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/security/
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/resources/security/
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/AuthenticationWrapper.java
Modified:
    geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ApplicationPolicyConfigurationManager.java
    geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingprovider/PolicyConfigurationGeneric.java
    geronimo/server/trunk/framework/modules/pom.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/server/trunk/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/pom.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigRoot.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/annotation/ServletSecurityAnnotationMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/DistributableMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceEnvRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServiceRefMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletMappingMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/security/AuthenticationWrapper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverterTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web/deployment/WebAppDConfigTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SchemaConversionTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/HTTPMethods.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/SpecSecurityBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/URLPattern.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/URLPatternCheck.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/security/UncheckedItem.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/geronimo/web/security/SecurityConfigTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/java/org/apache/geronimo/web/security/SpecSecurityParsingTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/test/resources/security/web6.xml
    geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/j2ee/jsr88-war-configurer/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/j2ee/pom.xml
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml
    geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/tomcat/tomcat7-clustering-wadi/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/wab/web-extender/src/main/history/dependencies.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ApplicationPolicyConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ApplicationPolicyConfigurationManager.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ApplicationPolicyConfigurationManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/ApplicationPolicyConfigurationManager.java Sat May  1 11:51:06 2010
@@ -33,8 +33,6 @@ import org.apache.geronimo.gbean.GBeanIn
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.security.SecurityNames;
-import org.apache.geronimo.security.credentialstore.CredentialStore;
-import org.apache.geronimo.security.deploy.SubjectInfo;
 
 /**
  * @version $Rev$ $Date$
@@ -43,8 +41,10 @@ public class ApplicationPolicyConfigurat
 
     private final Map<String, PolicyConfiguration> contextIdToPolicyConfigurationMap = new HashMap<String, PolicyConfiguration>();
     private final PrincipalRoleMapper principalRoleMapper;
+    private ClassLoader classLoader;
 
     public ApplicationPolicyConfigurationManager(Map<String, ComponentPermissions> contextIdToPermissionsMap, PrincipalRoleMapper principalRoleMapper, ClassLoader cl) throws PolicyContextException, ClassNotFoundException, LoginException {
+        this.classLoader = cl;
         this.principalRoleMapper = principalRoleMapper;
         Thread currentThread = Thread.currentThread();
         ClassLoader oldClassLoader = currentThread.getContextClassLoader();
@@ -67,8 +67,8 @@ public class ApplicationPolicyConfigurat
             for (Map.Entry<String, PermissionCollection> roleEntry : componentPermissions.getRolePermissions().entrySet()) {
                 String roleName = roleEntry.getKey();
                 PermissionCollection rolePermissions = roleEntry.getValue();
-                for (Enumeration permissions = rolePermissions.elements(); permissions.hasMoreElements();) {
-                    Permission permission = (Permission) permissions.nextElement();
+                for (Enumeration<Permission> permissions = rolePermissions.elements(); permissions.hasMoreElements();) {
+                    Permission permission = permissions.nextElement();
                     policyConfiguration.addToRole(roleName, permission);
 
                 }
@@ -125,6 +125,62 @@ public class ApplicationPolicyConfigurat
 
     }
 
+    public void updateApplicationPolicyConfiguration(Map<String, ComponentPermissions> contextIdToPermissionsMap) throws PolicyContextException, ClassNotFoundException, LoginException {
+        PolicyConfigurationFactory policyConfigurationFactory;
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(classLoader);
+            policyConfigurationFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        }
+        //Remove those contextId that we want to update, is this required ?
+        for (String contextId : contextIdToPermissionsMap.keySet()) {
+            contextIdToPolicyConfigurationMap.remove(contextId);
+        }
+        if (principalRoleMapper != null) {
+            principalRoleMapper.uninstall(contextIdToPermissionsMap.keySet());
+        }
+        //
+        for (Map.Entry<String, ComponentPermissions> entry : contextIdToPermissionsMap.entrySet()) {
+            String contextID = entry.getKey();
+            ComponentPermissions componentPermissions = entry.getValue();
+            //Clean existing PolicyConfiguration and set its state to "OPEN"
+            PolicyConfiguration policyConfiguration = policyConfigurationFactory.getPolicyConfiguration(contextID, true);
+            contextIdToPolicyConfigurationMap.put(contextID, policyConfiguration);
+            policyConfiguration.addToExcludedPolicy(componentPermissions.getExcludedPermissions());
+            policyConfiguration.addToUncheckedPolicy(componentPermissions.getUncheckedPermissions());
+            for (Map.Entry<String, PermissionCollection> roleEntry : componentPermissions.getRolePermissions().entrySet()) {
+                String roleName = roleEntry.getKey();
+                PermissionCollection rolePermissions = roleEntry.getValue();
+                for (Enumeration<Permission> permissions = rolePermissions.elements(); permissions.hasMoreElements();) {
+                    Permission permission = permissions.nextElement();
+                    policyConfiguration.addToRole(roleName, permission);
+                }
+            }
+        }
+        if (principalRoleMapper != null) {
+            principalRoleMapper.install(contextIdToPermissionsMap.keySet());
+        }
+        //link everything together, seems that we do nothing in the linkConfiguration method
+        /*
+        for (PolicyConfiguration policyConfiguration : contextIdToPolicyConfigurationMap.values()) {
+            for (PolicyConfiguration policyConfiguration2 : contextIdToPolicyConfigurationMap.values()) {
+                if (policyConfiguration != policyConfiguration2) {
+                    policyConfiguration.linkConfiguration(policyConfiguration2);
+                }
+            }
+        }
+        */
+        //commit
+        for (String contextId : contextIdToPermissionsMap.keySet()) {
+            contextIdToPolicyConfigurationMap.get(contextId).commit();
+        }
+        //refresh policy
+        Policy policy = Policy.getPolicy();
+        policy.refresh();
+    }
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingprovider/PolicyConfigurationGeneric.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingprovider/PolicyConfigurationGeneric.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingprovider/PolicyConfigurationGeneric.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/mappingprovider/PolicyConfigurationGeneric.java Sat May  1 11:51:06 2010
@@ -82,9 +82,9 @@ public class PolicyConfigurationGeneric 
     public void addToRole(String roleName, PermissionCollection permissions) throws PolicyContextException {
         if (state != OPEN) throw new UnsupportedOperationException("Not in an open state");
 
-        Enumeration e = permissions.elements();
+        Enumeration<Permission> e = permissions.elements();
         while (e.hasMoreElements()) {
-            addToRole(roleName, (Permission) e.nextElement());
+            addToRole(roleName, e.nextElement());
         }
     }
 
@@ -102,9 +102,9 @@ public class PolicyConfigurationGeneric 
     public void addToUncheckedPolicy(PermissionCollection permissions) throws PolicyContextException {
         if (state != OPEN) throw new UnsupportedOperationException("Not in an open state");
 
-        Enumeration e = permissions.elements();
+        Enumeration<Permission> e = permissions.elements();
         while (e.hasMoreElements()) {
-            addToUncheckedPolicy((Permission) e.nextElement());
+            addToUncheckedPolicy(e.nextElement());
         }
     }
 
@@ -119,9 +119,9 @@ public class PolicyConfigurationGeneric 
     public void addToExcludedPolicy(PermissionCollection permissions) throws PolicyContextException {
         if (state != OPEN) throw new UnsupportedOperationException("Not in an open state");
 
-        Enumeration e = permissions.elements();
+        Enumeration<Permission> e = permissions.elements();
         while (e.hasMoreElements()) {
-            addToExcludedPolicy((Permission) e.nextElement());
+            addToExcludedPolicy(e.nextElement());
         }
     }
 
@@ -175,8 +175,8 @@ public class PolicyConfigurationGeneric 
             for (String role : roleSet) {
                 Permissions permissions = rolePermissionsMap.get(role);
                 if (permissions == null) continue;
-                for (Enumeration rolePermissions = permissions.elements(); rolePermissions.hasMoreElements();) {
-                    principalPermissions.add((Permission) rolePermissions.nextElement());
+                for (Enumeration<Permission> rolePermissions = permissions.elements(); rolePermissions.hasMoreElements();) {
+                    principalPermissions.add(rolePermissions.nextElement());
                 }
             }
 

Modified: geronimo/server/trunk/framework/modules/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/pom.xml?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/pom.xml Sat May  1 11:51:06 2010
@@ -55,7 +55,7 @@
         <module>geronimo-rmi-loader</module>
         <module>geronimo-system</module>
         <module>geronimo-pax-logging</module>
-        <module>geronimo-kernel</module>
+        <!--module>geronimo-kernel</module-->
         <module>geronimo-plugin</module>
         <module>geronimo-deploy-tool</module>
         <module>geronimo-shell-base</module>
@@ -77,7 +77,7 @@
                 <module>geronimo-rmi-loader</module>
                 <module>geronimo-system</module>
                 <module>geronimo-pax-logging</module>
-                <module>geronimo-kernel</module>
+                <!--module>geronimo-kernel</module-->
                 <module>geronimo-plugin</module>
                 <module>geronimo-deploy-tool</module>
                 <module>geronimo-cli</module>
@@ -119,7 +119,7 @@
                 <module>geronimo-rmi-loader</module>
                 <module>geronimo-system</module>
                 <module>geronimo-pax-logging</module>
-                <module>geronimo-kernel</module>
+                <!--module>geronimo-kernel</module-->
                 <module>geronimo-plugin</module>
                 <module>geronimo-deploy-tool</module>
                 <module>geronimo-cli</module>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java Sat May  1 11:51:06 2010
@@ -64,13 +64,13 @@ public class EARContext extends Deployme
                       AbstractNameQuery connectionTrackerObjectName,
                       AbstractNameQuery corbaGBeanObjectName
     ) throws DeploymentException {
-        this(baseDir, 
-             inPlaceConfigurationDir, 
-             environment, 
-             moduleType, 
-             naming, 
-             configurationManager, 
-             bundleContext, 
+        this(baseDir,
+             inPlaceConfigurationDir,
+             environment,
+             moduleType,
+             naming,
+             configurationManager,
+             bundleContext,
              serverName,
              baseName,
              transactionManagerObjectName,
@@ -78,7 +78,7 @@ public class EARContext extends Deployme
              corbaGBeanObjectName,
              new HashMap());
     }
-    
+
     public EARContext(File baseDir,
                       File inPlaceConfigurationDir,
                       Environment environment,
@@ -128,7 +128,7 @@ public class EARContext extends Deployme
         this.messageDestinations  = new HashMap();
     }
 
-    // For sub-classes only     
+    // For sub-classes only
     protected EARContext(File baseDir,
                          File inPlaceConfigurationDir,
                          Environment environment,
@@ -143,7 +143,7 @@ public class EARContext extends Deployme
                          AbstractNameQuery connectionTrackerObjectName,
                          AbstractNameQuery corbaGBeanObjectName,
                          Map messageDestinations) throws DeploymentException {
-        super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming, 
+        super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming,
               configurationManager, resourceContext, bundleContext);
 
         this.serverName = serverName;
@@ -152,7 +152,7 @@ public class EARContext extends Deployme
         this.corbaGBeanObjectName = corbaGBeanObjectName;
         this.messageDestinations = messageDestinations;
     }
-    
+
     public AbstractNameQuery getServerName() {
         return serverName;
     }
@@ -238,4 +238,11 @@ public class EARContext extends Deployme
         }
     };
 
+    public static final Key<AbstractName> JACC_MANAGER_NAME_KEY = new Key<AbstractName>() {
+
+        @Override
+        public AbstractName get(Map<Key, Object> context) {
+            return (AbstractName) context.get(this);
+        }
+    };
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java Sat May  1 11:51:06 2010
@@ -23,6 +23,7 @@ import java.util.Map;
 import javax.xml.namespace.QName;
 
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.xbeans.javaee6.WebAppDocument;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlDocumentProperties;
@@ -39,6 +40,7 @@ public class SchemaConversionUtils {
     static final String GERONIMO_NAMING_NAMESPACE = "http://geronimo.apache.org/xml/ns/naming-1.2";
     private static final String GERONIMO_SERVICE_NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
     public static final String JPA_PERSISTENCE_NAMESPACE = "http://java.sun.com/xml/ns/persistence";
+    private static final QName TAGLIB = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE, "taglib");
 
     private static final Map<String, ElementConverter> GERONIMO_SCHEMA_CONVERSIONS = new HashMap<String, ElementConverter>();
 
@@ -363,6 +365,88 @@ public class SchemaConversionUtils {
         moveElements("env-entry-value", namespace, moveable, cursor);
     }
 
+    public static  WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException {
+        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
+        String version = "3.0";
+        XmlCursor cursor = xmlObject.newCursor();
+        try {
+            cursor.toStartDoc();
+            cursor.toFirstChild();
+            String nameSpaceURI = cursor.getName().getNamespaceURI();
+            if ("http://java.sun.com/xml/ns/javaee".equals(nameSpaceURI) || "http://java.sun.com/xml/ns/j2ee".equals(nameSpaceURI)) {
+                SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
+                XmlObject result = xmlObject.changeType(WebAppDocument.type);
+                XmlBeansUtil.validateDD(result);
+                return (WebAppDocument) result;
+            }
+            //otherwise assume DTD
+            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
+            String publicId = xmlDocumentProperties.getDoctypePublicId();
+            boolean is22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId);
+            if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId) || is22) {
+                XmlCursor moveable = xmlObject.newCursor();
+                try {
+                    moveable.toStartDoc();
+                    moveable.toFirstChild();
+                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
+                    cursor.toStartDoc();
+                    cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "web-app");
+                    cursor.toFirstChild();
+                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
+                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
+                    cursor.push();
+                    if (cursor.toNextSibling(TAGLIB)) {
+                        cursor.toPrevSibling();
+                        moveable.toCursor(cursor);
+                        cursor.beginElement("jsp-config", SchemaConversionUtils.JAVAEE_NAMESPACE);
+                        while (moveable.toNextSibling(TAGLIB)) {
+                            moveable.moveXml(cursor);
+                        }
+                    }
+                    cursor.pop();
+                    do {
+                        String name = cursor.getName().getLocalPart();
+                        if ("filter".equals(name) || "servlet".equals(name) || "context-param".equals(name)) {
+                            cursor.push();
+                            cursor.toFirstChild();
+                            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
+                            while (cursor.toNextSibling(SchemaConversionUtils.JAVAEE_NAMESPACE, "init-param")) {
+                                cursor.push();
+                                cursor.toFirstChild();
+                                SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
+                                cursor.pop();
+                            }
+                            cursor.pop();
+                            cursor.push();
+                            if (cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "jsp-file")) {
+                                String jspFile = cursor.getTextValue();
+                                if (!jspFile.startsWith("/")) {
+                                    if (is22) {
+                                        cursor.setTextValue("/" + jspFile);
+                                    } else {
+                                        throw new XmlException("jsp-file does not start with / and this is not a 2.2 web app: " + jspFile);
+                                    }
+                                }
+                            }
+                            cursor.pop();
+                        }
+                    } while (cursor.toNextSibling());
+                } finally {
+                    moveable.dispose();
+                }
+            }
+        } finally {
+            cursor.dispose();
+        }
+        XmlObject result = xmlObject.changeType(WebAppDocument.type);
+        if (result != null) {
+            XmlBeansUtil.validateDD(result);
+            return (WebAppDocument) result;
+        }
+        XmlBeansUtil.validateDD(xmlObject);
+        return (WebAppDocument) xmlObject;
+    }
+
     private static void moveElements(String localName, String namespace, XmlCursor moveable, XmlCursor toHere) {
         QName name = new QName(namespace, localName);
         //skip elements already in the correct order.

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-security-builder/src/main/java/org/apache/geronimo/security/deployment/GeronimoSecurityBuilderImpl.java Sat May  1 11:51:06 2010
@@ -144,7 +144,7 @@ public class GeronimoSecurityBuilderImpl
     }
 
     //MBE methods
-    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {        
+    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
     }
 
     public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
@@ -230,10 +230,10 @@ public class GeronimoSecurityBuilderImpl
             jaccBeanData.setReferencePattern("PrincipalRoleMapper", roleMapperDataName);
             try {
                 earContext.addGBean(jaccBeanData);
+                earContext.getGeneralData().put(EARContext.JACC_MANAGER_NAME_KEY, jaccBeanData.getAbstractName());
             } catch (GBeanAlreadyExistsException e) {
                 throw new DeploymentException("JACC manager gbean already present", e);
             }
-//            earContext.setJaccManagerName(jaccBeanData.getAbstractName());
         }
     }
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/pom.xml?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/pom.xml Sat May  1 11:51:06 2010
@@ -35,6 +35,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-web</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+        <dependency>
             <!-- g-schema-jee_5 comes via g-j2ee-builder from this -->
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-naming-builder</artifactId>
@@ -58,6 +64,7 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-servlet_3.0_spec</artifactId>
         </dependency>
+
         <dependency>
             <groupId>org.apache.geronimo.framework</groupId>
             <artifactId>geronimo-kernel</artifactId>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java Sat May  1 11:51:06 2010
@@ -18,10 +18,10 @@ package org.apache.geronimo.web.deployme
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.HashSet;
 
 import javax.xml.namespace.QName;
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigBean.java Sat May  1 11:51:06 2010
@@ -26,8 +26,8 @@ import javax.enterprise.deploy.spi.DConf
 import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
 import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
 
-import org.apache.geronimo.deployment.service.jsr88.EnvironmentData;
 import org.apache.geronimo.deployment.dconfigbean.DConfigBeanSupport;
+import org.apache.geronimo.deployment.service.jsr88.EnvironmentData;
 import org.apache.geronimo.naming.deployment.ENCHelper;
 import org.apache.geronimo.naming.deployment.jsr88.EjbLocalRef;
 import org.apache.geronimo.naming.deployment.jsr88.EjbRef;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigRoot.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigRoot.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigRoot.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web/deployment/WebAppDConfigRoot.java Sat May  1 11:51:06 2010
@@ -19,6 +19,7 @@ package org.apache.geronimo.web.deployme
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import javax.enterprise.deploy.model.DDBean;
 import javax.enterprise.deploy.model.DDBeanRoot;
 import javax.enterprise.deploy.spi.DConfigBean;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Sat May  1 11:51:06 2010
@@ -27,10 +27,12 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
@@ -84,15 +86,14 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.security.jaspi.AuthConfigProviderGBean;
 import org.apache.geronimo.security.jaspi.ServerAuthConfigGBean;
 import org.apache.geronimo.security.jaspi.ServerAuthContextGBean;
 import org.apache.geronimo.security.jaspi.ServerAuthModuleGBean;
+import org.apache.geronimo.web.security.SpecSecurityBuilder;
 import org.apache.geronimo.web25.deployment.merge.MergeHelper;
 import org.apache.geronimo.web25.deployment.security.AuthenticationWrapper;
-import org.apache.geronimo.web25.deployment.security.SpecSecurityBuilder;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
 import org.apache.geronimo.xbeans.javaee6.FilterType;
 import org.apache.geronimo.xbeans.javaee6.FullyQualifiedClassType;
@@ -100,12 +101,10 @@ import org.apache.geronimo.xbeans.javaee
 import org.apache.geronimo.xbeans.javaee6.ServletMappingType;
 import org.apache.geronimo.xbeans.javaee6.ServletType;
 import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
-import org.apache.geronimo.xbeans.javaee6.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
 import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlDocumentProperties;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
 import org.osgi.framework.Bundle;
@@ -137,19 +136,24 @@ public abstract class AbstractWebModuleB
         }
     };
 
-    public static final EARContext.Key<List<String>> EXCLUDED_JAR_URLS = new EARContext.Key<List<String>>() {
+    public static final EARContext.Key<Set<String>> EXCLUDED_JAR_URLS = new EARContext.Key<Set<String>>() {
 
         @Override
-        public List<String> get(Map<EARContext.Key, Object> context) {
-            return (List<String>) context.get(this);
+        public Set<String> get(Map<EARContext.Key, Object> context) {
+            Set<String> excludedJarUrls = (Set<String>) context.get(this);
+            if (excludedJarUrls == null) {
+                excludedJarUrls = new HashSet<String>();
+                context.put(this, excludedJarUrls);
+            }
+            return excludedJarUrls;
         }
     };
 
-    public static final EARContext.Key<Boolean> EXCLUDED_ANNOTATION_SCAN_JAR_URLS = new EARContext.Key<Boolean>() {
+    public static final EARContext.Key<Map<String, Set<String>>> SERVLET_CONTAINER_INITIALIZERS = new EARContext.Key<Map<String, Set<String>>>() {
 
         @Override
-        public Boolean get(Map<EARContext.Key, Object> context) {
-            return (Boolean) context.get(this);
+        public Map<String, Set<String>> get(Map<EARContext.Key, Object> context) {
+            return (Map<String, Set<String>>) context.get(this);
         }
     };
 
@@ -161,7 +165,12 @@ public abstract class AbstractWebModuleB
         }
     };
 
-    private static final QName TAGLIB = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE, "taglib");
+    public static final EARContext.Key<List<String>> ORDERED_LIBS = new EARContext.Key<List<String>> () {
+        @Override
+        public List<String> get(Map<EARContext.Key, Object> context) {
+            return (List<String>) context.get(this);
+        }
+    };
 
     private static final String LINE_SEP = System.getProperty("line.separator");
 
@@ -427,11 +436,21 @@ public abstract class AbstractWebModuleB
         getNamingBuilders().buildEnvironment(webApp, webModule.getVendorDD(), webModule.getEnvironment());
         getNamingBuilders().initContext(webApp, gerWebApp, webModule);
 
-        identifySpecDDSchemaVersion(earContext, module);
+        float originalSpecDDVersion;
+        String originalSpecDD = module.getOriginalSpecDD();
+        if (originalSpecDD == null) {
+            originalSpecDDVersion = 3.0f;
+        } else {
+            originalSpecDDVersion = identifySpecDDSchemaVersion(originalSpecDD);
+        }
+        earContext.getGeneralData().put(INITIAL_WEB_XML_SCHEMA_VERSION, originalSpecDDVersion);
         //Process web fragments and annotations
         if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f && !webApp.getMetadataComplete()) {
             MergeHelper.processWebFragmentsAndAnnotations(earContext, webModule, bundle, webApp);
         }
+        //TODO From my understanding, whether we scan ServletContainerInitializer has nothing to do with meta-complete/web.xml schema version
+        //Might need double-check !
+        MergeHelper.processServletContainerInitializer(earContext, webModule, bundle);
 
         //Process Web Service
         Map servletNameToPathMap = buildServletNameToPathMap((WebAppType) webModule.getSpecDD(), webModule.getContextRoot());
@@ -465,139 +484,50 @@ public abstract class AbstractWebModuleB
         return writer.toString();
     }
 
-    protected WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException {
-        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
-        String version = "3.0";
-        XmlCursor cursor = xmlObject.newCursor();
+    /**
+     * Identify the spec DD schema version, and save it in the EARContext
+     * @param xmlObject
+     * @param earContext
+     */
+    private float identifySpecDDSchemaVersion(String originalSpecDD) {
+        float schemaVersion = 0f;
+        XmlCursor cursor = null;
         try {
+            cursor = XmlBeansUtil.parse(originalSpecDD).newCursor();
             cursor.toStartDoc();
             cursor.toFirstChild();
             String nameSpaceURI = cursor.getName().getNamespaceURI();
-            if ("http://java.sun.com/xml/ns/javaee".equals(nameSpaceURI) || "http://java.sun.com/xml/ns/j2ee".equals(nameSpaceURI)) {
-                SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
-                XmlObject result = xmlObject.changeType(WebAppDocument.type);
-                XmlBeansUtil.validateDD(result);
-                return (WebAppDocument) result;
-            }
-            //otherwise assume DTD
-            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-            String publicId = xmlDocumentProperties.getDoctypePublicId();
-            boolean is22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId);
-            if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId) || is22) {
-                XmlCursor moveable = xmlObject.newCursor();
+            if (nameSpaceURI != null && nameSpaceURI.length() > 0) {
+                String version = cursor.getAttributeText(new QName("", "version"));
+                if (version != null) {
+                    schemaVersion = Float.parseFloat(version);
+                }
+            } else {
+                XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
+                String publicId = xmlDocumentProperties.getDoctypePublicId();
+                if ("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId)) {
+                    schemaVersion = 2.2f;
+                } else if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId)) {
+                    schemaVersion = 2.3f;
+                }
+            }
+        } catch (Exception e) {
+            log.error("Fail to identify web.xml schema version", e);
+            //Should never happen, as we have checked the deployment plan  in the previous code
+        } finally {
+            if (cursor != null) {
                 try {
-                    moveable.toStartDoc();
-                    moveable.toFirstChild();
-                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
-                    cursor.toStartDoc();
-                    cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "web-app");
-                    cursor.toFirstChild();
-                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
-                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
-                    cursor.push();
-                    if (cursor.toNextSibling(TAGLIB)) {
-                        cursor.toPrevSibling();
-                        moveable.toCursor(cursor);
-                        cursor.beginElement("jsp-config", SchemaConversionUtils.JAVAEE_NAMESPACE);
-                        while (moveable.toNextSibling(TAGLIB)) {
-                            moveable.moveXml(cursor);
-                        }
-                    }
-                    cursor.pop();
-                    do {
-                        String name = cursor.getName().getLocalPart();
-                        if ("filter".equals(name) || "servlet".equals(name) || "context-param".equals(name)) {
-                            cursor.push();
-                            cursor.toFirstChild();
-                            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
-                            while (cursor.toNextSibling(SchemaConversionUtils.JAVAEE_NAMESPACE, "init-param")) {
-                                cursor.push();
-                                cursor.toFirstChild();
-                                SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
-                                cursor.pop();
-                            }
-                            cursor.pop();
-                            cursor.push();
-                            if (cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "jsp-file")) {
-                                String jspFile = cursor.getTextValue();
-                                if (!jspFile.startsWith("/")) {
-                                    if (is22) {
-                                        cursor.setTextValue("/" + jspFile);
-                                    } else {
-                                        throw new XmlException("jsp-file does not start with / and this is not a 2.2 web app: " + jspFile);
-                                    }
-                                }
-                            }
-                            cursor.pop();
-                        }
-                    } while (cursor.toNextSibling());
-                } finally {
-                    moveable.dispose();
+                    cursor.dispose();
+                } catch (Exception e) {
                 }
             }
-        } finally {
-            cursor.dispose();
-        }
-        XmlObject result = xmlObject.changeType(WebAppDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (WebAppDocument) result;
         }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (WebAppDocument) xmlObject;
+        return schemaVersion;
     }
 
-    /**
-     * Identify the spec DD schema version, and save it in the EARContext
-     * @param xmlObject
-     * @param earContext
-     */
-    private void identifySpecDDSchemaVersion(EARContext earContext, Module module) throws DeploymentException {
-        String originalSpecDD = module.getOriginalSpecDD();
-        float schemaVersion = 0f;
-        if (originalSpecDD == null) {
-            schemaVersion = 3.0f;
-        } else {
-            XmlCursor cursor = null;
-            try {
-                cursor = XmlBeansUtil.parse(originalSpecDD).newCursor();
-                cursor.toStartDoc();
-                cursor.toFirstChild();
-                String nameSpaceURI = cursor.getName().getNamespaceURI();
-                if (nameSpaceURI != null && nameSpaceURI.length() > 0) {
-                    String version = cursor.getAttributeText(new QName("", "version"));
-                    if (version != null) {
-                        schemaVersion = Float.parseFloat(version);
-                    }
-                } else {
-                    XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-                    String publicId = xmlDocumentProperties.getDoctypePublicId();
-                    if ("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId)) {
-                        schemaVersion = 2.2f;
-                    } else if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId)) {
-                        schemaVersion = 2.3f;
-                    }
-                }
-            } catch (Exception e) {
-                throw new DeploymentException(e);
-            } finally {
-                if (cursor != null) {
-                    try {
-                        cursor.dispose();
-                    } catch (Exception e) {
-                    }
-                }
-            }
-        }
-        if (schemaVersion == 0f) {
-            throw new DeploymentException("Unrecongnized schema version in web.xml file");
-        }
-        earContext.getGeneralData().put(INITIAL_WEB_XML_SCHEMA_VERSION, schemaVersion);
-    }
-
-    protected ComponentPermissions buildSpecSecurityConfig(WebAppType webApp) {
-        SpecSecurityBuilder builder = new SpecSecurityBuilder();
-        return builder.buildSpecSecurityConfig(webApp);
+    protected ComponentPermissions buildSpecSecurityConfig(EARContext earContext, WebAppType webApp, Bundle bundle) {
+        SpecSecurityBuilder builder = new SpecSecurityBuilder(webApp, bundle, INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f && !webApp.getMetadataComplete());
+        return builder.buildSpecSecurityConfig();
     }
 
     protected void configureLocalJaspicProvider(AuthenticationWrapper authType, String contextPath, Module module, GBeanData securityFactoryData) throws DeploymentException,

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java Sat May  1 11:51:06 2010
@@ -17,9 +17,13 @@
 
 package org.apache.geronimo.web25.deployment.merge;
 
+import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -30,6 +34,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.zip.ZipEntry;
 
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.annotation.HandlesTypes;
 import javax.servlet.annotation.WebFilter;
 import javax.servlet.annotation.WebListener;
 import javax.servlet.annotation.WebServlet;
@@ -38,11 +44,7 @@ import org.apache.geronimo.common.Deploy
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.xbean.finder.BundleAnnotationFinder;
-import org.apache.xbean.osgi.bundle.util.BundleResourceFinder;
-import org.apache.xbean.osgi.bundle.util.DiscoveryFilter;
-import org.apache.xbean.osgi.bundle.util.DiscoveryRange;
-import org.apache.xbean.osgi.bundle.util.BundleResourceFinder.ResourceFinderCallback;
+import org.apache.geronimo.kernel.util.IOUtils;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
 import org.apache.geronimo.web25.deployment.merge.annotation.AnnotationMergeHandler;
 import org.apache.geronimo.web25.deployment.merge.annotation.ServletSecurityAnnotationMergeHandler;
@@ -86,6 +88,14 @@ import org.apache.geronimo.xbeans.javaee
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
 import org.apache.geronimo.xbeans.javaee6.WebFragmentDocument;
 import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+import org.apache.xbean.finder.BundleAnnotationFinder;
+import org.apache.xbean.osgi.bundle.util.BundleClassFinder;
+import org.apache.xbean.osgi.bundle.util.BundleResourceFinder;
+import org.apache.xbean.osgi.bundle.util.ClassDiscoveryFilter;
+import org.apache.xbean.osgi.bundle.util.DiscoveryRange;
+import org.apache.xbean.osgi.bundle.util.ResourceDiscoveryFilter;
+import org.apache.xbean.osgi.bundle.util.BundleResourceFinder.ResourceFinderCallback;
+import org.apache.xmlbeans.XmlException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -172,8 +182,7 @@ public class MergeHelper {
             }
             // EXCLUDED_JAR_URLS is required for TLD scanning, ServletContainerInitializer scanning and ServletContextListeners.
             // So does it mean that we always need to scan web-fragment.xml whatever meta-complete is set with true or false.
-            List<String> excludedURLs = new ArrayList<String>();
-            earContext.getGeneralData().put(AbstractWebModuleBuilder.EXCLUDED_JAR_URLS, excludedURLs);
+            Set<String> excludedURLs = AbstractWebModuleBuilder.EXCLUDED_JAR_URLS.get(earContext.getGeneralData());
             //Add left named web-fragment.xml file URLs to the EXCLUDED_JAR_URLS List
             for (String foundedWebFragementName : webFragmentEntryMap.keySet()) {
                 if (!expliciteConfiguredWebFragmentNames.contains(foundedWebFragementName)) {
@@ -188,7 +197,7 @@ public class MergeHelper {
     public static void mergeAnnotations(Bundle bundle, WebAppType webApp, MergeContext mergeContext, final String prefix) throws DeploymentException {
         final boolean isJarFile = prefix.endsWith(".jar");
         try {
-            BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(null, bundle, new DiscoveryFilter() {
+            BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(null, bundle, new ResourceDiscoveryFilter() {
 
                 @Override
                 public boolean directoryDiscoveryRequired(String url) {
@@ -248,11 +257,9 @@ public class MergeHelper {
 
     public static void processServletContainerInitializer(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
         //ServletContainerInitializer
-        //TODO A possible solution might be create ServletContainerInitializer GBean for each found ServletContainerInitializer,
-        //The GBean would contain all the matched classes according the configuration of HandlesTypes annotation
-        //then check the specific API of Tomcat/Jetty, which could be used to regiester them to the servlet container
-        //That is for web application scope, how about the server scope ?
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+        final Set<String> excludedJarNames = AbstractWebModuleBuilder.EXCLUDED_JAR_URLS.get(earContext.getGeneralData());
+        final Set<String> servletContainerInitializers = new HashSet<String>();
         try {
             PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
             BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin, bundle, "META-INF/services", "javax.servlet.ServletContainerInitializer");
@@ -263,8 +270,78 @@ public class MergeHelper {
                 }
 
                 public void foundInJar(Bundle bundle, String jarName, ZipEntry entry, InputStream in) throws Exception {
+                    if (!excludedJarNames.contains(jarName)) {
+                        BufferedReader bufferedReader = null;
+                        try {
+                            bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+                            String servletContainerInitializer = null;
+                            while ((servletContainerInitializer = bufferedReader.readLine()) != null) {
+                                servletContainerInitializer = servletContainerInitializer.trim();
+                                if (!servletContainerInitializer.isEmpty()) {
+                                    servletContainerInitializers.add(servletContainerInitializer);
+                                }
+                            }
+                        } catch (IOException e) {
+                            logger.warn("Fail to scan META-INF/services/javax.servlet.ServletContainerInitializer", e);
+                        } finally {
+                            IOUtils.close(bufferedReader);
+                        }
+                    }
                 }
             });
+            //TODO we might need to change to ASM
+            BundleClassFinder bundleClassFinder = new BundleClassFinder(packageAdmin, bundle, new ClassDiscoveryFilter() {
+
+                @Override
+                public boolean directoryDiscoveryRequired(String directory) {
+                    return true;
+                }
+
+                @Override
+                public boolean jarFileDiscoveryRequired(String jarUrl) {
+                    return !excludedJarNames.contains(jarUrl);
+                }
+
+                @Override
+                public boolean packageDiscoveryRequired(String packageName) {
+                    return true;
+                }
+
+                @Override
+                public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
+                    return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
+                }
+            });
+            Map<String, Set<String>> servletContainerInitializerClassNamesMap = new HashMap<String, Set<String>>();
+            List<Class> allAvailbleClasses = bundleClassFinder.loadClasses(bundleClassFinder.find());
+            for (String servletContainerInitializer : servletContainerInitializers) {
+                Class<?> servletContainerInitializerClass = null;
+                try {
+                    servletContainerInitializerClass = bundle.loadClass(servletContainerInitializer);
+                } catch (Exception e) {
+                    logger.warn("Fail to load ServletContainerInitializer class " + servletContainerInitializer, e);
+                }
+                if (!ServletContainerInitializer.class.isAssignableFrom(servletContainerInitializerClass)) {
+                    logger.warn("Class " + servletContainerInitializer + " does not implement ServletContainerInitializer interface, ignored");
+                    continue;
+                }
+                HandlesTypes handlesTypes = servletContainerInitializerClass.getAnnotation(HandlesTypes.class);
+                if (handlesTypes == null || handlesTypes.value().length == 0) {
+                    servletContainerInitializerClassNamesMap.put(servletContainerInitializer, null);
+                    continue;
+                }
+                Set<String> acceptedClassNames = new HashSet<String>();
+                for (Class candidateClass : allAvailbleClasses) {
+                    for (Class expectedClass : handlesTypes.value()) {
+                        if (expectedClass.isAssignableFrom(candidateClass)) {
+                            acceptedClassNames.add(candidateClass.getName());
+                            break;
+                        }
+                    }
+                }
+                servletContainerInitializerClassNamesMap.put(servletContainerInitializer, acceptedClassNames.size() > 0 ? acceptedClassNames : null);
+            }
+            earContext.getGeneralData().put(AbstractWebModuleBuilder.SERVLET_CONTAINER_INITIALIZERS, servletContainerInitializerClassNamesMap);
         } catch (Exception e) {
             throw new DeploymentException("Fail to scan javax.servlet.ServletContainerInitializer", e);
         } finally {
@@ -273,32 +350,48 @@ public class MergeHelper {
     }
 
     public static void processWebFragmentsAndAnnotations(EARContext earContext, Module module, Bundle bundle, WebAppType webApp) throws DeploymentException {
-        BundleResourceFinder bundleResourceFinder = new BundleResourceFinder(null, bundle, "META-INF/", "web-fragment.xml");
         final Map<String, WebFragmentDocument> jarUrlWebFragmentDocumentMap = new LinkedHashMap<String, WebFragmentDocument>();
-        final String validJarNamePrefix = module.isStandAlone() ? "WEB-INF" : module.getName() + "/WEB-INF";
-        try {
-            bundleResourceFinder.find(new ResourceFinderCallback() {
-
-                public void foundInDirectory(Bundle bundle, String basePath, URL url) throws Exception {
-                }
-
-                public void foundInJar(Bundle bundle, String jarName, ZipEntry entry, InputStream in) throws Exception {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Found web-fragment.xml in jarName = [" + jarName + "] jarURL = [" + bundle.getEntry(jarName) + "]");
-                    }
-                    if (jarName.startsWith(validJarNamePrefix) && jarName.endsWith(".jar")) {
-                        WebFragmentDocument webFragmentDocument = (WebFragmentDocument) XmlBeansUtil.parse(in);
+        final String validJarNamePrefix = module.isStandAlone() ? "WEB-INF/lib" : module.getName() + "/WEB-INF/lib";
+        for (Enumeration<String> enumeration = bundle.getEntryPaths(validJarNamePrefix); enumeration.hasMoreElements();) {
+            String url = enumeration.nextElement();
+            if (url.endsWith(".jar")) {
+                URL webFragmentUrl = bundle.getEntry(url + "/META-INF/web-fragment.xml");
+                WebFragmentDocument webFragmentDocument = null;
+                if (webFragmentUrl != null) {
+                    InputStream in = null;
+                    try {
+                        in = webFragmentUrl.openStream();
+                        webFragmentDocument = (WebFragmentDocument) XmlBeansUtil.parse(in);
                         //Hopefully, XmlBeansUtil should help to check most of errors against the schema files, like none null servlet-name etc.
                         XmlBeansUtil.validateDD(webFragmentDocument);
-                        jarUrlWebFragmentDocumentMap.put(jarName, webFragmentDocument);
+                    } catch (IOException e) {
+                        logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
+                        throw new DeploymentException("Fail to scan web-fragment.xml files", e);
+                    } catch (XmlException e) {
+                        logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
+                        throw new DeploymentException("Fail to scan web-fragment.xml files", e);
+                    } finally {
+                        IOUtils.close(in);
                     }
+                } else {
+                    webFragmentDocument = WebFragmentDocument.Factory.newInstance();
+                    webFragmentDocument.setWebFragment(WebFragmentType.Factory.newInstance());
                 }
-            });
-        } catch (Exception e) {
-            logger.error("Fail to scan web-fragment.xml files", e);
-            throw new DeploymentException("Fail to scan web-fragment.xml files", e);
+                jarUrlWebFragmentDocumentMap.put(url, webFragmentDocument);
+            }
         }
         WebFragmentEntry[] webFragmentEntries = sortWebFragments(earContext, module, bundle, webApp, jarUrlWebFragmentDocumentMap);
+        //Save ORDERED_LIBS Attribute
+        List<String> orderedLibs = new ArrayList<String>();
+        for (WebFragmentEntry webFragmentEntry : webFragmentEntries) {
+            String jarURL = webFragmentEntry.getJarURL();
+            int iBeginIndex = jarURL.indexOf("WEB-INF/");
+            if (iBeginIndex > 0) {
+                orderedLibs.add(jarURL.substring(iBeginIndex + 8));
+            }
+        }
+        earContext.getGeneralData().put(AbstractWebModuleBuilder.ORDERED_LIBS, orderedLibs);
+        //
         MergeContext mergeContext = new MergeContext();
         mergeContext.setEarContext(earContext);
         mergeContext.setBundle(bundle);

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/annotation/ServletSecurityAnnotationMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/annotation/ServletSecurityAnnotationMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/annotation/ServletSecurityAnnotationMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/annotation/ServletSecurityAnnotationMergeHandler.java Sat May  1 11:51:06 2010
@@ -17,39 +17,25 @@
 
 package org.apache.geronimo.web25.deployment.merge.annotation;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 import javax.servlet.Servlet;
 import javax.servlet.annotation.HttpConstraint;
 import javax.servlet.annotation.HttpMethodConstraint;
 import javax.servlet.annotation.ServletSecurity;
-import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.web25.deployment.merge.MergeContext;
-import org.apache.geronimo.web25.deployment.merge.webfragment.ServletMappingMergeHandler;
 import org.apache.geronimo.web25.deployment.utils.WebDeploymentValidationUtils;
-import org.apache.geronimo.xbeans.javaee6.AuthConstraintType;
-import org.apache.geronimo.xbeans.javaee6.SecurityConstraintType;
-import org.apache.geronimo.xbeans.javaee6.ServletMappingType;
 import org.apache.geronimo.xbeans.javaee6.ServletType;
-import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
-import org.apache.geronimo.xbeans.javaee6.WebResourceCollectionType;
 import org.osgi.framework.Bundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
+ *  For supporting dynamic security configurations for servlets, the detailed analysis for ServletConstraint are delayed to start time.
+ *  This ServletSecurityAnnotationMergeHandler is mainly used for annotation configuration validation
  * @version $Rev$ $Date$
  */
 public class ServletSecurityAnnotationMergeHandler implements AnnotationMergeHandler {
 
-    private static final Logger logger = LoggerFactory.getLogger(ServletSecurityAnnotationMergeHandler.class);
-
     @Override
     public void merge(Class<?>[] classes, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
     }
@@ -58,7 +44,6 @@ public class ServletSecurityAnnotationMe
     public void postProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
         try {
             Bundle bundle = mergeContext.getBundle();
-            Map<String, Set<String>> servletClassNameUrlPatternsMap = genetateServletClassUrlPatternsMap(webApp, mergeContext);
             for (ServletType servlet : webApp.getServletArray()) {
                 if (servlet.getServletClass() == null || servlet.getServletClass().getStringValue().isEmpty()) {
                     continue;
@@ -72,26 +57,22 @@ public class ServletSecurityAnnotationMe
                 if (servletSecurity == null) {
                     continue;
                 }
-                Set<String> urlPatterns = servletClassNameUrlPatternsMap.get(servletClassName);
-                if (urlPatterns == null || urlPatterns.isEmpty()) {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("No url pattern for the servlet class " + servletClassName + " is found in the deployment plan, SecurityConstraint annotation is ignored");
-                    }
-                    continue;
-                }
-                HttpConstraint httpConstraint = servletSecurity.value();
                 if (servletSecurity.httpMethodConstraints().length > 0) {
-                    String[] omissionMethods = new String[servletSecurity.httpMethodConstraints().length];
-                    int iIndex = 0;
                     for (HttpMethodConstraint httpMethodConstraint : servletSecurity.httpMethodConstraints()) {
-                        //Generate a security-constraint for each HttpMethodConstraint
-                        String httpMethod = normalizeHTTPMethod(servletClassName, httpMethodConstraint.value());
-                        omissionMethods[iIndex++] = httpMethod;
-                        addNewHTTPMethodSecurityConstraint(webApp, servletClassName, httpMethodConstraint.rolesAllowed(), httpMethodConstraint.transportGuarantee(), httpMethodConstraint
-                                .emptyRoleSemantic(), httpMethod, urlPatterns);
+                        String httpMethod = httpMethodConstraint.value();
+                        if (httpMethod == null || httpMethod.trim().isEmpty()) {
+                            throw new DeploymentException("HTTP protocol method could not be null or empty string in the ServletSecurity annotation of the class " + servletClassName);
+                        }
+                        httpMethod = httpMethod.trim();
+                        if (!WebDeploymentValidationUtils.isValidHTTPMethod(httpMethod)) {
+                            throw new DeploymentException("Invalid HTTP method value is found in the ServletSecurity annotation of the class " + servletClassName);
+                        }
                     }
                 } else {
-                    addNewHTTPSecurityConstraint(webApp, servletClassName, httpConstraint.rolesAllowed(), httpConstraint.transportGuarantee(), httpConstraint.value(), new String[] {}, urlPatterns);
+                    HttpConstraint httpConstraint = servletSecurity.value();
+                    if (httpConstraint.rolesAllowed().length > 0 && httpConstraint.value().equals(ServletSecurity.EmptyRoleSemantic.DENY)) {
+                        throw new DeploymentException("EmptyRoleSemantic with value DENY is not allowed in combination with a non-empty rolesAllowed list in the class " + servletClassName);
+                    }
                 }
             }
         } catch (ClassNotFoundException e) {
@@ -99,117 +80,6 @@ public class ServletSecurityAnnotationMe
         }
     }
 
-    /**
-     * Create Security Constraint based on the arguments
-     * @param webApp
-     * @param rolesAllowed
-     * @param transportGuarantee
-     * @param emptyRoleSemantic
-     * @return null when emptyRoleSemantic=PERMIT AND rolesAllowed={} AND transportGuarantee=NONE
-     */
-    private SecurityConstraintType addNewSecurityConstraint(WebAppType webApp, String className, String[] rolesAllowed, TransportGuarantee transportGuarantee,
-            ServletSecurity.EmptyRoleSemantic emptyRoleSemantic) throws DeploymentException {
-        if (rolesAllowed.length > 0 && emptyRoleSemantic.equals(ServletSecurity.EmptyRoleSemantic.DENY)) {
-            throw new DeploymentException("EmptyRoleSemantic with value DENY is not allowed in combination with a non-empty rolesAllowed list in the class " + className);
-        }
-        //If emptyRoleSemantic=PERMIT AND rolesAllowed={} AND transportGuarantee=NONE then
-        //No Constraint
-        if (rolesAllowed.length > 0 || transportGuarantee.equals(TransportGuarantee.CONFIDENTIAL) || emptyRoleSemantic.equals(ServletSecurity.EmptyRoleSemantic.DENY)) {
-            SecurityConstraintType securityConstraint = webApp.addNewSecurityConstraint();
-            if (transportGuarantee.equals(TransportGuarantee.CONFIDENTIAL)) {
-                securityConstraint.addNewUserDataConstraint().addNewTransportGuarantee().setStringValue(TransportGuarantee.CONFIDENTIAL.name());
-            }
-            if (emptyRoleSemantic.equals(ServletSecurity.EmptyRoleSemantic.DENY)) {
-                securityConstraint.addNewAuthConstraint();
-            } else {
-                AuthConstraintType authConstraint = securityConstraint.addNewAuthConstraint();
-                for (String roleAllowed : rolesAllowed) {
-                    authConstraint.addNewRoleName().setStringValue(roleAllowed);
-                }
-            }
-            return securityConstraint;
-        }
-        return null;
-    }
-
-    private SecurityConstraintType addNewHTTPSecurityConstraint(WebAppType webApp, String className, String[] rolesAllowed, TransportGuarantee transportGuarantee,
-            ServletSecurity.EmptyRoleSemantic emptyRoleSemantic, String[] omissionMethods, Set<String> urlPatterns) throws DeploymentException {
-        SecurityConstraintType securityConstraint = addNewSecurityConstraint(webApp, className, rolesAllowed, transportGuarantee, emptyRoleSemantic);
-        if (omissionMethods.length > 0 || securityConstraint != null) {
-            if (securityConstraint == null) {
-                securityConstraint = webApp.addNewSecurityConstraint();
-            }
-            WebResourceCollectionType webResourceCollection = securityConstraint.getWebResourceCollectionArray().length == 0 ? securityConstraint.addNewWebResourceCollection() : securityConstraint
-                    .getWebResourceCollectionArray(0);
-            for (String omissionMethod : omissionMethods) {
-                webResourceCollection.addNewHttpMethodOmission().setStringValue(omissionMethod);
-            }
-            for (String urlPattern : urlPatterns) {
-                webResourceCollection.addNewUrlPattern().setStringValue(urlPattern);
-            }
-        }
-        return securityConstraint;
-    }
-
-    private SecurityConstraintType addNewHTTPMethodSecurityConstraint(WebAppType webApp, String className, String[] rolesAllowed, TransportGuarantee transportGuarantee,
-            ServletSecurity.EmptyRoleSemantic emptyRoleSemantic, String httpMethod, Set<String> urlPatterns) throws DeploymentException {
-        SecurityConstraintType securityConstraint = addNewSecurityConstraint(webApp, className, rolesAllowed, transportGuarantee, emptyRoleSemantic);
-        if (securityConstraint == null) {
-            securityConstraint = webApp.addNewSecurityConstraint();
-        }
-        WebResourceCollectionType webResourceCollection = securityConstraint.getWebResourceCollectionArray().length == 0 ? securityConstraint.addNewWebResourceCollection() : securityConstraint
-                .getWebResourceCollectionArray(0);
-        for (String urlPattern : urlPatterns) {
-            webResourceCollection.addNewUrlPattern().setStringValue(urlPattern);
-        }
-        webResourceCollection.addNewHttpMethod().setStringValue(httpMethod);
-        return securityConstraint;
-    }
-
-    private String normalizeHTTPMethod(String servletClassName, String httpMethod) throws DeploymentException {
-        if (httpMethod == null || httpMethod.trim().isEmpty()) {
-            throw new DeploymentException("HTTP protocol method could not be null or empty string in the ServletSecurity annotation of the class " + servletClassName);
-        }
-        httpMethod = httpMethod.trim();
-        if (!WebDeploymentValidationUtils.isValidHTTPMethod(httpMethod)) {
-            throw new DeploymentException("Invalid HTTP method value is found in the ServletSecurity annotation of the class " + servletClassName);
-        }
-        return httpMethod;
-    }
-
-    private Map<String, Set<String>> genetateServletClassUrlPatternsMap(WebAppType webApp, MergeContext mergeContext) {
-        Set<String> urlPatternsConfiguredInSecurityConstraint = new HashSet<String>();
-        for (SecurityConstraintType secuirtyConstrait : webApp.getSecurityConstraintArray()) {
-            for (WebResourceCollectionType webResourceCollection : secuirtyConstrait.getWebResourceCollectionArray()) {
-                for (UrlPatternType urlPattern : webResourceCollection.getUrlPatternArray()) {
-                    urlPatternsConfiguredInSecurityConstraint.add(urlPattern.getStringValue());
-                }
-            }
-        }
-        Map<String, Set<String>> servletClassUrlPatternsMap = new HashMap<String, Set<String>>();
-        for (ServletType servlet : webApp.getServletArray()) {
-            if (servlet.getServletClass() == null || servlet.getServletClass().getStringValue().isEmpty()) {
-                continue;
-            }
-            String servletClassName = servlet.getServletClass().getStringValue();
-            Set<String> urlPatterns = servletClassUrlPatternsMap.get(servlet.getServletClass().getStringValue());
-            if (urlPatterns == null) {
-                urlPatterns = new HashSet<String>();
-                servletClassUrlPatternsMap.put(servletClassName, urlPatterns);
-            }
-            ServletMappingType servletMapping = (ServletMappingType) mergeContext.getAttribute(ServletMappingMergeHandler.createServletMappingKey(servlet.getServletName().getStringValue()));
-            if (servletMapping != null) {
-                for (UrlPatternType urlPattern : servletMapping.getUrlPatternArray()) {
-                    String urlPatternValue = urlPattern.getStringValue();
-                    if (!urlPatternsConfiguredInSecurityConstraint.contains(urlPatternValue)) {
-                        urlPatterns.add(urlPatternValue);
-                    }
-                }
-            }
-        }
-        return servletClassUrlPatternsMap;
-    }
-
     @Override
     public void preProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
     }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/DistributableMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/DistributableMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/DistributableMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/DistributableMergeHandler.java Sat May  1 11:51:06 2010
@@ -47,8 +47,8 @@ public class DistributableMergeHandler i
             }
         } else {
             if (distributableInWebXml) {
-                for (int i = 0; i < webApp.getDistributableArray().length; i++) {
-                    webApp.removeDistributable(i);
+                for (int i = 0, iLoopSize = webApp.getDistributableArray().length; i < iLoopSize; i++) {
+                    webApp.removeDistributable(0);
                 }
             }
         }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java Sat May  1 11:51:06 2010
@@ -19,6 +19,7 @@ package org.apache.geronimo.web25.deploy
 
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.web25.deployment.merge.MergeContext;
 import org.apache.geronimo.xbeans.javaee6.FilterType;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.java Sat May  1 11:51:06 2010
@@ -22,8 +22,8 @@ import org.apache.geronimo.web25.deploym
 import org.apache.geronimo.web25.deployment.merge.MergeContext;
 import org.apache.geronimo.web25.deployment.merge.MergeItem;
 import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
-import org.apache.geronimo.xbeans.javaee6.MessageDestinationRefType;
 import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.MessageDestinationRefType;
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
 import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.java Sat May  1 11:51:06 2010
@@ -22,8 +22,8 @@ import org.apache.geronimo.web25.deploym
 import org.apache.geronimo.web25.deployment.merge.MergeContext;
 import org.apache.geronimo.web25.deployment.merge.MergeItem;
 import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
-import org.apache.geronimo.xbeans.javaee6.PersistenceContextRefType;
 import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.PersistenceContextRefType;
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
 import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.java?rev=939982&r1=939981&r2=939982&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.java Sat May  1 11:51:06 2010
@@ -22,8 +22,8 @@ import org.apache.geronimo.web25.deploym
 import org.apache.geronimo.web25.deployment.merge.MergeContext;
 import org.apache.geronimo.web25.deployment.merge.MergeItem;
 import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
-import org.apache.geronimo.xbeans.javaee6.PersistenceUnitRefType;
 import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.PersistenceUnitRefType;
 import org.apache.geronimo.xbeans.javaee6.WebAppType;
 import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
 



Mime
View raw message