geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r167853 - in /geronimo/trunk/modules/tomcat-builder: project.xml src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java src/schema/geronimo-tomcat.xsd src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Date Tue, 03 May 2005 03:42:26 GMT
Author: jgenender
Date: Mon May  2 20:42:26 2005
New Revision: 167853

URL: http://svn.apache.org/viewcvs?rev=167853&view=rev
Log:
Tomcat Builder provides for context configuration and adds ability to use valves

Added:
    geronimo/trunk/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml
Modified:
    geronimo/trunk/modules/tomcat-builder/project.xml
    geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat.xsd
    geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java

Modified: geronimo/trunk/modules/tomcat-builder/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/project.xml?rev=167853&r1=167852&r2=167853&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/project.xml (original)
+++ geronimo/trunk/modules/tomcat-builder/project.xml Mon May  2 20:42:26 2005
@@ -360,6 +360,16 @@
 
         <dependency>
             <groupId>tomcat</groupId>
+            <artifactId>servlets-default</artifactId>
+            <version>${tomcat_version}</version>
+            <url>http://jakarta.apache.org/tomcat/</url>
+            <properties>
+                <repository>true</repository>
+            </properties>
+        </dependency>
+
+        <dependency>
+            <groupId>tomcat</groupId>
             <artifactId>tomcat-http</artifactId>
             <version>${tomcat_version}</version>
             <url>http://jakarta.apache.org/tomcat/</url>

Modified: geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=167853&r1=167852&r2=167853&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Mon May  2 20:42:26 2005
@@ -27,18 +27,16 @@
 import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.Permissions;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
+
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.security.jacc.WebResourcePermission;
@@ -46,7 +44,6 @@
 import javax.security.jacc.WebUserDataPermission;
 import javax.transaction.UserTransaction;
 
-import org.apache.catalina.core.StandardWrapper;
 import org.apache.geronimo.axis.builder.WSDescriptorParser;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.service.ServiceConfigBuilder;
@@ -63,9 +60,6 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.tomcat.TomcatClassLoader;
-import org.apache.geronimo.tomcat.TomcatWebAppContext;
-import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
@@ -76,40 +70,26 @@
 import org.apache.geronimo.security.deployment.SecurityConfiguration;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.security.util.URLPattern;
+import org.apache.geronimo.tomcat.RealmGBean;
+import org.apache.geronimo.tomcat.TomcatClassLoader;
+import org.apache.geronimo.tomcat.TomcatWebAppContext;
+import org.apache.geronimo.tomcat.ValveGBean;
+import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.xbeans.geronimo.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.tomcat.TomcatWebAppType;
-import org.apache.geronimo.xbeans.j2ee.DescriptionType;
-import org.apache.geronimo.xbeans.j2ee.DispatcherType;
-import org.apache.geronimo.xbeans.j2ee.DisplayNameType;
-import org.apache.geronimo.xbeans.j2ee.ErrorPageType;
 import org.apache.geronimo.xbeans.j2ee.FilterMappingType;
-import org.apache.geronimo.xbeans.j2ee.FilterType;
-import org.apache.geronimo.xbeans.j2ee.FormLoginConfigType;
 import org.apache.geronimo.xbeans.j2ee.HttpMethodType;
-import org.apache.geronimo.xbeans.j2ee.JspConfigType;
-import org.apache.geronimo.xbeans.j2ee.ListenerType;
-import org.apache.geronimo.xbeans.j2ee.LocaleEncodingMappingListType;
-import org.apache.geronimo.xbeans.j2ee.LocaleEncodingMappingType;
-import org.apache.geronimo.xbeans.j2ee.LoginConfigType;
-import org.apache.geronimo.xbeans.j2ee.MimeMappingType;
-import org.apache.geronimo.xbeans.j2ee.ParamValueType;
 import org.apache.geronimo.xbeans.j2ee.RoleNameType;
 import org.apache.geronimo.xbeans.j2ee.SecurityConstraintType;
 import org.apache.geronimo.xbeans.j2ee.SecurityRoleRefType;
 import org.apache.geronimo.xbeans.j2ee.SecurityRoleType;
 import org.apache.geronimo.xbeans.j2ee.ServletMappingType;
 import org.apache.geronimo.xbeans.j2ee.ServletType;
-import org.apache.geronimo.xbeans.j2ee.TaglibType;
 import org.apache.geronimo.xbeans.j2ee.UrlPatternType;
 import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
-import org.apache.geronimo.xbeans.j2ee.WelcomeFileListType;
-import org.apache.catalina.deploy.ErrorPage;
-import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.deploy.FilterMap;
-import org.apache.catalina.deploy.LoginConfig;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
@@ -303,7 +283,7 @@
            // and the url class loader will not pick up a manifiest from an unpacked dir
            earContext.addManifestClassPath(warFile, URI.create(module.getTargetPath()));
 
-           // add the dependencies declared in the geronimo-jetty.xml file
+           // add the dependencies declared in the geronimo-tomcat.xml file
            TomcatWebAppType tomcatWebApp = (TomcatWebAppType) module.getVendorDD();
            DependencyType[] dependencies = tomcatWebApp.getDependencyArray();
            ServiceConfigBuilder.addDependencies(earContext, dependencies, repository);
@@ -378,6 +358,32 @@
            webModuleData.setReferencePattern("trackedConnectionAssociator", earContext.getConnectionTrackerObjectName());
            webModuleData.setReferencePattern("Container", tomcatContainerObjectName);
 
+           //Is there a Tomcat realm declaration?
+           if (tomcatWebApp != null) {
+               String tomcatRealm = tomcatWebApp.getTomcatRealm();
+               if ( tomcatRealm != null) {
+                   ObjectName realmName = NameFactory.getComponentName(null, null, null,
null, tomcatRealm.trim(), RealmGBean.GBEAN_INFO.getJ2eeType(), moduleJ2eeContext);
+                   webModuleData.setReferencePattern("TomcatRealm", realmName);
+               }           
+           }
+           
+           //Is there a Tomcat Valve Chain declaration?
+           if (tomcatWebApp != null) {
+               String tomcatValveChain = tomcatWebApp.getTomcatValveChain();
+               if ( tomcatValveChain != null) {
+                   ObjectName valveName = NameFactory.getComponentName(null, null, null,
null, tomcatValveChain.trim(), ValveGBean.J2EE_TYPE, moduleJ2eeContext);
+                       //NameFactory.getComponentName(null, null, null, null, tomcatValveChain.trim(),
ValveGbean., moduleJ2eeContext);
+                   webModuleData.setReferencePattern("TomcatValveChain", valveName);
+               }           
+           }
+           
+           //Handle the role permissions on the servlets.
+           ServletType[] servletTypes = webApp.getServletArray();
+           for (int i = 0; i < servletTypes.length; i++) {
+               ServletType servletType = servletTypes[i];
+               processRoleRefPermissions(servletType, securityRoles, rolePermissions);
+           }
+           
            if (tomcatWebApp.isSetSecurityRealmName()) {
                
                SecurityHolder securityHolder = new SecurityHolder();
@@ -399,8 +405,7 @@
                        checkedPermissions.add(permission);
                    }
                }
-               securityHolder.setChecked(checkedPermissions);
-
+               securityHolder.setChecked(checkedPermissions);      
                earContext.addSecurityContext(policyContextID, componentPermissions);
                if (tomcatWebApp.isSetSecurity()) {
                    SecurityConfiguration securityConfiguration = SecurityBuilder.buildSecurityConfiguration(tomcatWebApp.getSecurity());
@@ -450,44 +455,11 @@
        ClassLoader webClassLoader = new TomcatClassLoader(webClassPathURLs, baseUrl, cl,
contextPriorityClassLoader);
        return webClassLoader;
    }
-/*
-   private StandardWrapper createServlet(ServletType servletType,
-                               Map servletMappings,
+
+   private void processRoleRefPermissions(ServletType servletType,
                                Set securityRoles,
                                Map rolePermissions) throws MalformedObjectNameException,
DeploymentException {
        String servletName = servletType.getServletName().getStringValue().trim();
- //      GBeanData servletData;
-       StandardWrapper servletData = new StandardWrapper();
-       if (servletType.isSetServletClass()) {
-           String servletClassName = servletType.getServletClass().getStringValue().trim();
-           servletData.setServletClass(servletClassName);
-       } else if (servletType.isSetJspFile()) {
-           servletData.setJspFile(servletType.getJspFile().getStringValue().trim());
-           //TODO MAKE THIS CONFIGURABLE!!! Tomcat uses the servlet mapping set up from the
default-web.xml
-           servletData.setServletClass("org.apache.jasper.servlet.JspServlet");
-       } else {
-           throw new DeploymentException("Neither servlet class nor jsp file is set for "
+ servletName);
-       }
-       //TODO in init param setter, add classpath if jspFile is not null.
-       servletData.setServletName(servletName);
-       ParamValueType[] initParamArray = servletType.getInitParamArray();
-       for (int j = 0; j < initParamArray.length; j++) {
-           ParamValueType paramValueType = initParamArray[j];
-           servletData.addInitParameter(paramValueType.getParamName().getStringValue().trim(),
paramValueType.getParamValue().getStringValue().trim());
-       }
-
-       if (servletType.isSetLoadOnStartup()) {
-           Integer loadOnStartup = new Integer(servletType.getLoadOnStartup().getBigIntegerValue().intValue());
-           servletData.setLoadOnStartup(loadOnStartup.intValue());
-       }
-
-       Set mappings = (Set) servletMappings.get(servletName);
-       if (mappings != null){
-           Iterator iterator = mappings.iterator();
-           while(iterator.hasNext()){
-               servletData.addMapping((String)iterator.next());
-           }
-       }
 
        //WebRoleRefPermissions
        SecurityRoleRefType[] securityRoleRefTypeArray = servletType.getSecurityRoleRefArray();
@@ -497,8 +469,6 @@
            String roleName = securityRoleRefType.getRoleName().getStringValue().trim();
            String roleLink = securityRoleRefType.getRoleLink().getStringValue().trim();
 
-           servletData.addSecurityReference(roleName, roleLink);
-
            //jacc 3.1.3.2
            addPermissionToRole(roleLink, new WebRoleRefPermission(servletName, roleName),
rolePermissions);
            unmappedRoles.remove(roleName);
@@ -509,9 +479,8 @@
        }
 //       servletData.setAttribute("webRoleRefPermissions", webRoleRefPermissions);
 
-       return servletData;
    }
-**/
+
    private ComponentPermissions buildSpecSecurityConfig(WebAppType webApp, Set securityRoles,
Map rolePermissions) {
        Map uncheckedPatterns = new HashMap();
        Map uncheckedResourcePatterns = new HashMap();

Modified: geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat.xsd?rev=167853&r1=167852&r2=167853&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat.xsd (original)
+++ geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat.xsd Mon May  2 20:42:26
2005
@@ -31,7 +31,6 @@
     <xs:import namespace="http://geronimo.apache.org/xml/ns/security" schemaLocation="../../../security-builder/src/schema/geronimo-security.xsd"/>
     <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment" schemaLocation="../../../service-builder/src/schema/geronimo-config.xsd"/>
 
-
     <xs:element name="web-app" type="tomcat:web-appType"/>
 
     <xs:complexType name="web-appType">
@@ -41,6 +40,8 @@
             <xs:element name="context-root" type="xs:string" minOccurs="0"/>
             <xs:element name="context-priority-classloader" type="xs:boolean"/>
             <xs:element name="virtual-server" type="xs:string" minOccurs="0"/>
+            <xs:element name="tomcat-realm" type="xs:string" minOccurs="0"/>
+            <xs:element name="tomcat-valve-chain" type="xs:string" minOccurs="0"/>
 
             <xs:sequence minOccurs="0">
                 <xs:element name="security-realm-name" type="xs:string"/>
@@ -61,5 +62,4 @@
         <xs:attribute name="configId" type="xs:string" use="required"/>
         <xs:attribute name="parentId" type="xs:string" use="optional"/>
     </xs:complexType>
-
 </xs:schema>

Added: geronimo/trunk/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml?rev=167853&view=auto
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml
(added)
+++ geronimo/trunk/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-tomcat.xml
Mon May  2 20:42:26 2005
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<web-app
+    xmlns="http://geronimo.apache.org/xml/ns/web/tomcat"
+    xmlns:sec="http://geronimo.apache.org/xml/ns/security"
+    configId="org/apache/geronimo/test">
+
+    <context-root>/test</context-root>
+    <context-priority-classloader>false</context-priority-classloader>
+    <tomcat-realm>TomcatRealm</tomcat-realm>
+    <tomcat-valve-chain>FirstValve</tomcat-valve-chain>
+    
+    <security-realm-name>test</security-realm-name>
+    <security>
+        <default-principal realm-name="geronimo-properties-realm">
+            <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="metro"/>
+        </default-principal>
+    </security>
+     
+    <gbean name="TomcatRealm" class="org.apache.geronimo.tomcat.RealmGBean">
+        <attribute name="className">org.apache.geronimo.tomcat.realm.TomcatGeronimoRealm</attribute>
+        <attribute name="initParams">
+            userClassNames=org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal
+            roleClassNames=org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal
+        </attribute>
+    </gbean>
+ 
+    <gbean name="FirstValve" class="org.apache.geronimo.tomcat.ValveGBean">
+        <attribute name="className">org.apache.catalina.authenticator.SingleSignOn</attribute>
+        <reference name="NextValve"><moduleType>J2EEModule</moduleType><name>SecondValve</name></reference>
+    </gbean>
+    
+    <gbean name="SecondValve" class="org.apache.geronimo.tomcat.ValveGBean">
+        <attribute name="className">org.apache.catalina.valves.AccessLogValve</attribute>
+        <attribute name="initParams">
+            prefix=localhost_access_log. 
+            suffix=.txt
+            pattern=common
+        </attribute>
+    </gbean>   
+</web-app>

Modified: geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=167853&r1=167852&r2=167853&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
(original)
+++ geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Mon May  2 20:42:26 2005
@@ -22,7 +22,10 @@
 import java.io.ObjectOutputStream;
 import java.net.URI;
 import java.net.URL;
+import java.security.PermissionCollection;
+import java.security.Permissions;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -65,6 +68,8 @@
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.registry.BasicGBeanRegistry;
 import org.apache.geronimo.security.SecurityServiceImpl;
+import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
+import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.ConnectorGBean;
 import org.apache.geronimo.tomcat.EngineGBean;
@@ -143,7 +148,21 @@
         UnpackedJarFile jarFile = new UnpackedJarFile(path);
         Module module = builder.createModule(null, jarFile);
         URI id = new URI("war4");
+        
+        ObjectName jaccBeanName = NameFactory.getComponentName(null, null, null, null, "foo",
NameFactory.JACC_MANAGER, moduleContext);
+        GBeanData jaccBeanData = new GBeanData(jaccBeanName, ApplicationPolicyConfigurationManager.GBEAN_INFO);
+        PermissionCollection excludedPermissions= new Permissions();
+        PermissionCollection uncheckedPermissions= new Permissions();
+        ComponentPermissions componentPermissions = new ComponentPermissions(excludedPermissions,
uncheckedPermissions, new HashMap());
+        Map contextIDToPermissionsMap = new HashMap();
+        contextIDToPermissionsMap.put("test_J2EEApplication=null_J2EEServer=bar_j2eeType=WebModule_name=org/apache/geronimo/test",
componentPermissions);
+        jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap);
+        jaccBeanData.setAttribute("principalRoleMap", new HashMap());
+        jaccBeanData.setAttribute("roleDesignates", new HashMap());
+        start(jaccBeanData);        
+        
         EARContext earContext = createEARContext(outputPath, id);
+        earContext.setJaccManagerName(jaccBeanName);
         ObjectName serverName = earContext.getServerObjectName();
         GBeanData server = new GBeanData(serverName, J2EEServerImpl.GBEAN_INFO);
         start(server);
@@ -160,19 +179,16 @@
                 .intValue() != State.RUNNING_INDEX) {
             fail("gbean not started: " + configData.getName());
         }
-        assertEquals(
-                new Integer(State.RUNNING_INDEX),
-                kernel
-                        .getAttribute(
-                                ObjectName
-                                        .getInstance("test:J2EEApplication=null,J2EEServer=bar,j2eeType=WebModule,name=war4"),
-                                "state"));
-        Set names = kernel
-                .listGBeans(ObjectName
-                        .getInstance("test:J2EEApplication=null,J2EEServer=bar,WebModule=war4,*"));
+
+        assertEquals(new Integer(State.RUNNING_INDEX),kernel.getAttribute(
+                                ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=bar,j2eeType=WebModule,name=org/apache/geronimo/test"),
+                                "state"));        
+
+        Set names = kernel.listGBeans(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=bar,*"));
         System.out.println("Object names: " + names);
         for (Iterator iterator = names.iterator(); iterator.hasNext();) {
             ObjectName objectName = (ObjectName) iterator.next();
+            System.out.println("STATE: " + kernel.getAttribute(objectName, "state") + " -
" + objectName.getCanonicalName());
             assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(
                     objectName, "state"));
         }
@@ -406,9 +422,7 @@
 
         tm = new GBeanData(tmName, TransactionManagerImpl.GBEAN_INFO);
         Set patterns = new HashSet();
-        patterns
-                .add(ObjectName
-                        .getInstance("geronimo.server:j2eeType=JCAManagedConnectionFactory,*"));
+        patterns.add(ObjectName.getInstance("geronimo.server:j2eeType=JCAManagedConnectionFactory,*"));
         tm.setAttribute("defaultTransactionTimeoutSeconds", new Integer(10));
         tm.setReferencePatterns("ResourceManagers", patterns);
         start(tm);



Mime
View raw message