geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r167852 - in /geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat: BaseGBean.java EngineGBean.java GeronimoStandardContext.java HostGBean.java TomcatContainer.java TomcatContext.java TomcatGeronimoEmbedded.java TomcatWebAppContext.java ValveGBean.java util/SecurityHolder.java
Date Tue, 03 May 2005 03:41:19 GMT
Author: jgenender
Date: Mon May  2 20:41:18 2005
New Revision: 167852

URL: http://svn.apache.org/viewcvs?rev=167852&view=rev
Log:
Added Valves that may be added to the Engine, Host or Context

Added:
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/ValveGBean.java
Modified:
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/BaseGBean.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/util/SecurityHolder.java

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/BaseGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/BaseGBean.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/BaseGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/BaseGBean.java Mon May
 2 20:41:18 2005
@@ -37,4 +37,5 @@
         }
         
     }
+        
 }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java Mon
May  2 20:41:18 2005
@@ -16,10 +16,13 @@
 */
 package org.apache.geronimo.tomcat;
 
+import java.util.ArrayList;
 import java.util.Map;
 
 import org.apache.catalina.Engine;
 import org.apache.catalina.Realm;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardEngine;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -29,7 +32,10 @@
     
     private final Engine engine;
 
-    public EngineGBean(String className, Map initParams, ObjectRetriever realmGBean) throws
Exception {
+    public EngineGBean(String className, 
+            Map initParams, 
+            ObjectRetriever realmGBean,            
+            ValveGBean tomcatValveChain) throws Exception {
         super(); // TODO: make it an attribute
         
         if (className == null){
@@ -44,6 +50,19 @@
         if (realmGBean != null){
             engine.setRealm((Realm)realmGBean.getInternalObject());
         }
+        
+        //Add the valve list
+        if (engine instanceof StandardEngine){
+            if (tomcatValveChain != null){
+                ArrayList chain = new ArrayList();
+                ValveGBean valveGBean = tomcatValveChain;
+                while(valveGBean != null){
+                    ((StandardEngine)engine).addValve((Valve)valveGBean.getInternalObject());
+                    valveGBean = valveGBean.getNextValve();
+                }
+            }
+        }
+
     }
 
     public Object getInternalObject() {
@@ -66,8 +85,9 @@
         infoFactory.addAttribute("className", String.class, true);
         infoFactory.addAttribute("initParams", Map.class, true);
         infoFactory.addReference("realmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
+        infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
         infoFactory.addOperation("getInternalObject");
-        infoFactory.setConstructor(new String[] { "className", "initParams", "realmGBean"
});
+        infoFactory.setConstructor(new String[] { "className", "initParams", "realmGBean",
"TomcatValveChain" });
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Mon May  2 20:41:18 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.tomcat;
 
+import java.util.List;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -24,6 +25,7 @@
 import javax.security.jacc.PolicyContext;
 
 import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Valve;
 import org.apache.catalina.core.StandardContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -52,7 +54,7 @@
     
     public void setContextProperties(TomcatContext ctx){
     
-        // create ReadOnlyContext
+        // Create ReadOnlyContext
         javax.naming.Context enc = null;
         Map componentContext = ctx.getComponentContext();
         try {
@@ -118,6 +120,17 @@
                 addValve(policyValve);
             }    
         }
+        
+        // Add User Defined Valves
+        List valveChain = ctx.getValveChain();
+        if (valveChain != null){
+            Iterator iterator = valveChain.iterator();
+            while(iterator.hasNext()){
+                addValve((Valve)iterator.next());
+            }
+        }
+
+
     }
 
     public synchronized void start() throws LifecycleException {

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java Mon May
 2 20:41:18 2005
@@ -16,13 +16,15 @@
 */
 package org.apache.geronimo.tomcat;
 
+import java.util.ArrayList;
 import java.util.Map;
 
-import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
 import org.apache.catalina.Realm;
-import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.core.StandardHost;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -32,7 +34,11 @@
     
     private final Host host;
 
-    public HostGBean(String className, Map initParams, ObjectRetriever engineGBean, ObjectRetriever
realmGBean) throws Exception {
+    public HostGBean(String className, 
+            Map initParams, 
+            ObjectRetriever engineGBean, 
+            ObjectRetriever realmGBean,            
+            ValveGBean tomcatValveChain) throws Exception {
         super(); // TODO: make it an attribute
         
         //Validate
@@ -56,6 +62,18 @@
             host.setRealm((Realm)realmGBean.getInternalObject());
         else
             host.setRealm(engine.getRealm());
+
+        //Add the valve list
+        if (host instanceof StandardHost){
+            if (tomcatValveChain != null){
+                ArrayList chain = new ArrayList();
+                ValveGBean valveGBean = tomcatValveChain;
+                while(valveGBean != null){
+                    ((StandardHost)host).addValve((Valve)valveGBean.getInternalObject());
+                    valveGBean = valveGBean.getNextValve();
+                }
+            }
+        }
         
         //Add the host to the engine
         engine.addChild(host);
@@ -83,8 +101,9 @@
         infoFactory.addAttribute("initParams", Map.class, true);
         infoFactory.addReference("engineGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addReference("realmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
+        infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
         infoFactory.addOperation("getInternalObject");
-        infoFactory.setConstructor(new String[] { "className", "initParams", "engineGBean",
"realmGBean" });
+        infoFactory.setConstructor(new String[] { "className", "initParams", "engineGBean",
"realmGBean", "TomcatValveChain" });
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Mon May  2 20:41:18 2005
@@ -16,6 +16,9 @@
  */
 package org.apache.geronimo.tomcat;
 
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
@@ -173,7 +176,7 @@
 
         // Set the context for the Tomcat implementation
         ctx.setContext(anotherCtxObj);
-
+        
         // Have the context to set its properties if its a GeronimoStandardContext
         if (anotherCtxObj instanceof GeronimoStandardContext) 
             ((GeronimoStandardContext)anotherCtxObj).setContextProperties(ctx);
@@ -188,7 +191,11 @@
             throw new IllegalArgumentException("Invalid virtual host '" + virtualServer +"'.
 Do you have a matchiing Host entry in the plan?");
         }
         
-        anotherCtxObj.setRealm(host.getRealm());
+        if (ctx.getRealm() != null)
+            anotherCtxObj.setRealm(ctx.getRealm());
+        else
+            anotherCtxObj.setRealm(host.getRealm());
+            
 
         host.addChild(anotherCtxObj);
     }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java Mon
May  2 20:41:18 2005
@@ -16,10 +16,12 @@
  */
 package org.apache.geronimo.tomcat;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.Realm;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
@@ -56,4 +58,7 @@
 
     public Set getUnshareableResources();
     
+    public Realm getRealm();
+    
+    public List getValveChain();    
 }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
Mon May  2 20:41:18 2005
@@ -16,6 +16,8 @@
 */
 package org.apache.geronimo.tomcat;
 
+import java.io.File;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.startup.ContextConfig;
@@ -37,7 +39,7 @@
 
         context.setDocBase(docBase);
         context.setPath(path);
-
+        
         ContextConfig config = new ContextConfig();
         config.setCustomAuthenticators(authenticators);
         ((Lifecycle) context).addLifecycleListener(config);

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Mon May  2 20:41:18 2005
@@ -19,13 +19,17 @@
 
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.management.ObjectName;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Valve;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -65,6 +69,10 @@
     private String docBase = null;
     
     private String virtualServer = null;
+    
+    private final Realm realm;
+    
+    private final List valveChain;
 
     private final Map componentContext;
     
@@ -104,6 +112,8 @@
             TrackedConnectionAssociator trackedConnectionAssociator,
             TomcatContainer container, 
             RoleDesignateSource roleDesignateSource,
+            ObjectRetriever tomcatRealm,
+            ValveGBean tomcatValveChain,
             J2EEServer server, 
             J2EEApplication application, 
             Kernel kernel)
@@ -135,6 +145,28 @@
         this.server = server;
         this.application = application;
         
+        if (tomcatRealm != null){
+            realm = (Realm)tomcatRealm.getInternalObject();
+            if (!(realm instanceof Realm)){
+                throw new IllegalArgumentException("tomcatRealm must be an instance of org.apache.catalina.Realm.");
+            }
+        } else{
+            realm = null;
+        }
+        
+        //Add the valve list
+        if (tomcatValveChain != null){
+            ArrayList chain = new ArrayList();
+            ValveGBean valveGBean = tomcatValveChain;
+            while(valveGBean != null){
+                chain.add((Valve)valveGBean.getInternalObject());
+                valveGBean = valveGBean.getNextValve();
+            }
+            valveChain = chain;
+        } else {
+            valveChain = null;
+        }
+        
         URI root = URI.create(configurationBaseUrl.toString());
         webAppRoot = root.resolve(webAppRoot);
         URL webAppRootURL = webAppRoot.toURL();
@@ -226,6 +258,14 @@
         return unshareableResources;
     }
 
+    public Realm getRealm() {
+        return realm;
+    }
+
+    public List getValveChain() {
+        return valveChain;
+    }
+
     /**
      * ObjectName must match this pattern: <p/>
      * domain:j2eeType=WebModule,name=MyName,J2EEServer=MyServer,J2EEApplication=MyApplication
@@ -317,6 +357,8 @@
                 NameFactory.GERONIMO_SERVICE);
         infoBuilder.addReference("RoleDesignateSource",
                 RoleDesignateSource.class, NameFactory.JACC_MANAGER);
+        infoBuilder.addReference("TomcatRealm", ObjectRetriever.class);
+        infoBuilder.addReference("TomcatValveChain", ValveGBean.class);
         infoBuilder.addReference("J2EEServer", J2EEServer.class);
         infoBuilder.addReference("J2EEApplication", J2EEApplication.class);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
@@ -339,6 +381,8 @@
                 "trackedConnectionAssociator", 
                 "Container",
                 "RoleDesignateSource", 
+                "TomcatRealm",
+                "TomcatValveChain",
                 "J2EEServer", 
                 "J2EEApplication",
                 "kernel" 

Added: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/ValveGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/ValveGBean.java?rev=167852&view=auto
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/ValveGBean.java (added)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/ValveGBean.java Mon
May  2 20:41:18 2005
@@ -0,0 +1,100 @@
+/**
+*
+* Copyright 2003-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.
+*/
+
+package org.apache.geronimo.tomcat;
+
+import java.util.Map;
+
+import org.apache.catalina.Valve;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+public class ValveGBean extends BaseGBean implements GBeanLifecycle, ObjectRetriever {
+
+    public static final String J2EE_TYPE = "TomcatValve";
+        
+    private final Valve valve;
+    private final ValveGBean nextValve;
+ 
+    
+    public ValveGBean(){      
+        valve = null;
+        nextValve = null;
+    }
+    
+    public ValveGBean(String className, Map initParams, ValveGBean nextValve) throws Exception{
+
+        //Validate
+        if (className == null){
+            throw new IllegalArgumentException("className cannot be null.");
+        }
+        
+        if (nextValve != null){
+            if (!(nextValve.getInternalObject() instanceof Valve)){
+                throw new IllegalArgumentException("className cannot be null.");        
       
+            }
+            
+            this.nextValve = nextValve;
+        } else {
+            this.nextValve = null;
+        }
+        
+        //Create the Valve object
+        valve = (Valve)Class.forName(className).newInstance();
+
+        //Set the parameters
+        setParameters(valve, initParams);
+        
+    }
+    
+    public void doStart() throws Exception {
+    }
+
+    public void doStop() throws Exception {
+    }
+
+    public void doFail() {
+    }
+
+    public Object getInternalObject() {
+        return valve;
+    }
+
+    public ValveGBean getNextValve() {
+        return nextValve;
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(ValveGBean.class, J2EE_TYPE);
+        infoFactory.addAttribute("className", String.class, true);
+        infoFactory.addAttribute("initParams", Map.class, true);
+        infoFactory.addReference("NextValve", ValveGBean.class, J2EE_TYPE);
+        infoFactory.addOperation("getInternalObject");
+        infoFactory.addOperation("getNextValve");
+        infoFactory.setConstructor(new String[] { "className", "initParams", "NextValve"
});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/util/SecurityHolder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/util/SecurityHolder.java?rev=167852&r1=167851&r2=167852&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/util/SecurityHolder.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/util/SecurityHolder.java
Mon May  2 20:41:18 2005
@@ -16,11 +16,14 @@
  **/
 package org.apache.geronimo.tomcat.util;
 
+import java.io.Serializable;
 import java.security.PermissionCollection;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 
-public class SecurityHolder
+public class SecurityHolder implements Serializable
 {
+
+    private static final long serialVersionUID = 3761404231197734961L;
 
     private String policyContextID;
     private DefaultPrincipal defaultPrincipal;



Mime
View raw message