geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r664198 - in /geronimo/server/trunk/plugins/tomcat: geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/ geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ geronimo-tomcat6/src/main/java/org/apache/geronimo/...
Date Fri, 06 Jun 2008 23:42:32 GMT
Author: djencks
Date: Fri Jun  6 16:42:31 2008
New Revision: 664198

URL: http://svn.apache.org/viewvc?rev=664198&view=rev
Log:
GERONIMO-4109 reverse host-engine relationship direction for non-default hosts

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatGeronimoRealm.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatJAASRealm.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Fri Jun  6 16:42:31 2008
@@ -294,7 +294,6 @@
         engine.setAttribute("initParams", initParams);
         engine.setReferencePattern("DefaultHost", host.getAbstractName());
         engine.setReferencePattern("RealmGBean", realm.getAbstractName());
-        engine.setReferencePattern("Hosts", host.getAbstractName());
 
         WebServiceBuilder webServiceBuilder = new MockWebServiceBuilder();
 

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
Fri Jun  6 16:42:31 2008
@@ -56,7 +56,6 @@
     public EngineGBean(String className,
             Map initParams,
             HostGBean defaultHost,
-            Collection hosts,
             ObjectRetriever realmGBean,
             ValveGBean tomcatValveChain,
             LifecycleListenerGBean listenerChain,
@@ -100,9 +99,12 @@
         }
         
         //Set the default Host
-        final String defaultHostName = ((Host)defaultHost.getInternalObject()).getName();
-        engine.setDefaultHost(defaultHostName);
-        addHost(defaultHost);
+        Host host = (Host) defaultHost.getInternalObject();
+        if (host.getParent() != null) {
+            throw new IllegalStateException("Default host is already in use by another engine:
" + host.getParent());
+        }
+        engine.setDefaultHost(host.getName());
+        addHost(host);
 
         if (manager != null)
             engine.setManager((Manager)manager.getInternalObject());
@@ -130,36 +132,6 @@
             Registry.setServer(mbeanServerReference.getMBeanServer());
         }
         
-        //Add the hosts
-        if (hosts instanceof ReferenceCollection) {
-            ReferenceCollection refs = (ReferenceCollection)hosts;
-            refs.addReferenceCollectionListener(new ReferenceCollectionListener() {
-
-                public void memberAdded(ReferenceCollectionEvent event) {
-                    Object o = event.getMember();
-                    ObjectRetriever objectRetriever = (ObjectRetriever) o;
-                    String hostName = ((Host)objectRetriever.getInternalObject()).getName();
-                    if (!hostName.equals(defaultHostName))
-                        addHost(objectRetriever);
-                }
-
-                public void memberRemoved(ReferenceCollectionEvent event) {
-                    Object o = event.getMember();
-                    ObjectRetriever objectRetriever = (ObjectRetriever) o;
-                    String hostName = ((Host)objectRetriever.getInternalObject()).getName();
-                    if (!hostName.equals(defaultHostName))
-                        removeHost(objectRetriever);
-                }
-            });
-            Iterator iterator = refs.iterator();
-            while (iterator.hasNext()){
-                ObjectRetriever objRetriever = (ObjectRetriever)iterator.next();
-                String hostName = ((Host)objRetriever.getInternalObject()).getName();
-                if (!hostName.equals(defaultHostName))
-                    addHost(objRetriever);
-            }
-        }
-
 
         //Add clustering
         if (clusterGBean != null){
@@ -167,18 +139,11 @@
         }
     }
 
-    private void removeHost(ObjectRetriever objRetriever) {
-        Host host = (Host)objRetriever.getInternalObject();
+    public void removeHost(Host host) {
         engine.removeChild(host);
     }
 
-    private void addHost(ObjectRetriever objRetriever) {
-        Host host = (Host)objRetriever.getInternalObject();
-
-        //If we didn't set a realm, then use the default
-        if (host.getRealm() == null) {
-            host.setRealm(engine.getRealm());
-        }
+    public void addHost(Host host) {
         engine.addChild(host);
     }
 
@@ -205,7 +170,6 @@
         infoFactory.addAttribute("className", String.class, true);
         infoFactory.addAttribute("initParams", Map.class, true);
         infoFactory.addReference("DefaultHost", HostGBean.class, HostGBean.J2EE_TYPE);
-        infoFactory.addReference("Hosts", ObjectRetriever.class, HostGBean.J2EE_TYPE);
         infoFactory.addReference("RealmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
         infoFactory.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
@@ -217,8 +181,7 @@
                 "className", 
                 "initParams", 
                 "DefaultHost",
-                "Hosts", 
-                "RealmGBean", 
+                "RealmGBean",
                 "TomcatValveChain",
                 "LifecycleListenerChain",
                 "CatalinaCluster",

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
Fri Jun  6 16:42:31 2008
@@ -48,9 +48,11 @@
     private static final String NAME = "name";
     
     private final Host host;
+    private final EngineGBean engine;
     
     public HostGBean(){
         host = null;
+        engine = null;
     }
 
     public HostGBean(String className, 
@@ -60,7 +62,8 @@
             ValveGBean tomcatValveChain,
             LifecycleListenerGBean listenerChain,
             CatalinaClusterGBean clusterGBean,
-            ManagerGBean manager) throws Exception {
+            ManagerGBean manager,
+            EngineGBean engine) throws Exception {
         super(); // TODO: make it an attribute
         
         //Validate
@@ -128,6 +131,11 @@
         //Add manager
         if (manager != null)
             host.setManager((Manager)manager.getInternalObject());
+
+        this.engine = engine;
+        if (engine != null) {
+            engine.addHost(host);
+        }
     }
 
     public Object getInternalObject() {
@@ -144,6 +152,9 @@
 
     public void doStop() throws Exception {
         log.debug("Stopped host '" + host.getName() + "'");
+        if (engine != null) {
+            engine.removeHost(host);
+        }
     }
 
     public static final GBeanInfo GBEAN_INFO;
@@ -158,6 +169,7 @@
         infoFactory.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
         infoFactory.addReference("CatalinaCluster", CatalinaClusterGBean.class, CatalinaClusterGBean.J2EE_TYPE);
         infoFactory.addReference("Manager", ManagerGBean.class, ManagerGBean.J2EE_TYPE);
+        infoFactory.addReference("Engine", EngineGBean.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addOperation("getInternalObject");
         infoFactory.setConstructor(new String[] { 
                 "className", 
@@ -167,7 +179,8 @@
                 "TomcatValveChain",
                 "LifecycleListenerChain",
                 "CatalinaCluster",
-                "Manager"});
+                "Manager",
+                "Engine"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
Fri Jun  6 16:42:31 2008
@@ -330,6 +330,8 @@
                     } else {
                         //JAAS
                         realm = new TomcatJAASRealm();
+                        ((JAASRealm) realm).setUserClassNames("org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
+                        ((JAASRealm) realm).setRoleClassNames("org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
                     }
 
                     if (log.isDebugEnabled()) {
@@ -339,8 +341,6 @@
                             " adapter for this context.");
                     }
 
-                    ((JAASRealm) realm).setUserClassNames("org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
-                    ((JAASRealm) realm).setRoleClassNames("org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
                     ((JAASRealm) realm).setAppName(securityRealmName);
 
                     anotherCtxObj.setRealm(realm);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatGeronimoRealm.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatGeronimoRealm.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatGeronimoRealm.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatGeronimoRealm.java
Fri Jun  6 16:42:31 2008
@@ -51,6 +51,9 @@
 import org.apache.geronimo.tomcat.JAASTomcatPrincipal;
 import org.apache.geronimo.tomcat.interceptor.PolicyContextBeforeAfter;
 
+/**
+ * This class adapts the tomcat framework to use JACC security.
+ */
 public class TomcatGeronimoRealm extends JAASRealm {
 
     private static final Logger log = LoggerFactory.getLogger(TomcatGeronimoRealm.class);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatJAASRealm.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatJAASRealm.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatJAASRealm.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/realm/TomcatJAASRealm.java
Fri Jun  6 16:42:31 2008
@@ -32,6 +32,7 @@
 
 
 /**
+ * This is a non-JACC security solution using default tomcat security.  Not recommended for
javaee apps.
  * @version $Rev$ $Date$
  */
 public class TomcatJAASRealm extends JAASRealm implements Cloneable {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Fri Jun  6 16:42:31 2008
@@ -166,14 +166,13 @@
         initParams.put("name", "localhost");
         initParams.put("appBase", "");
 
-        HostGBean host = new HostGBean("org.apache.catalina.core.StandardHost", initParams,
null, realm, null, null, null, null);
+        HostGBean host = new HostGBean("org.apache.catalina.core.StandardHost", initParams,
null, realm, null, null, null, null, null);
         //Default Engine
         initParams = Collections.singletonMap("name", "Geronimo");
 
         EngineGBean engine = new EngineGBean("org.apache.geronimo.tomcat.TomcatEngine",
                 initParams,
                 host,
-                Collections.singleton(host),
                 realm,
                 null,
                 null,

Modified: geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml?rev=664198&r1=664197&r2=664198&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/tomcat/tomcat6/src/main/plan/plan.xml Fri Jun  6 16:42:31
2008
@@ -122,11 +122,6 @@
         <reference name="DefaultHost">
             <name>TomcatHost</name>
         </reference>
-        <references name="Hosts">
-            <pattern>
-                <type>Host</type>
-            </pattern>
-        </references>
         <reference name="RealmGBean">
             <name>TomcatJAASRealm</name>
         </reference>
@@ -178,12 +173,13 @@
     -->
 
     <!-- Realm -->
-    <!-- This is an example TomcatJAASRealm -->
+    <!-- This is an example TomcatJAASRealm, used only if you specify "DefaultJAASRealm"
as the security realm name in your geronimo plan -->
     <gbean name="TomcatJAASRealm" class="org.apache.geronimo.tomcat.RealmGBean">
         <attribute name="className">org.apache.geronimo.tomcat.realm.TomcatJAASRealm</attribute>
         <attribute name="initParams">
             userClassNames=org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal
             roleClassNames=org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal
+            appName=DefaultJAASRealm
         </attribute>
     </gbean>
 



Mime
View raw message