geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r159321 - in geronimo/trunk: etc/ modules/jetty/ modules/jetty/src/java/org/apache/geronimo/jetty/ modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/
Date Mon, 28 Mar 2005 22:47:56 GMT
Author: djencks
Date: Mon Mar 28 14:47:54 2005
New Revision: 159321

URL: http://svn.apache.org/viewcvs?view=rev&rev=159321
Log:
move to earlier creation of req/resp wrappers so they are available for jacc purposes

Added:
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/RequestWrappingBeforeAfter.java
Modified:
    geronimo/trunk/etc/project.properties
    geronimo/trunk/modules/jetty/project.properties
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyFilterMapping.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java

Modified: geronimo/trunk/etc/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/trunk/etc/project.properties?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/etc/project.properties (original)
+++ geronimo/trunk/etc/project.properties Mon Mar 28 14:47:54 2005
@@ -138,7 +138,7 @@
 jaxb_ri_version=SNAPSHOT
 jdbm_version=0.20-dev
 jelly_velocity_tags_version=1.0
-jetty_version=5.1.3rc2
+jetty_version=5.1.3-G-SNAPSHOT
 jgroups_version=2.2.5
 jmock_version=1.0.1
 jrms_version=1.1

Modified: geronimo/trunk/modules/jetty/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/project.properties?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/modules/jetty/project.properties (original)
+++ geronimo/trunk/modules/jetty/project.properties Mon Mar 28 14:47:54 2005
@@ -2,7 +2,7 @@
 ## $Rev$ $Date$
 ##
 
-# the directory containing the geronimo website in CVS
+maven.repo.remote=http://www.mortbay.org/maven, http://www.openejb.org/maven, http://www.ibiblio.org/maven
 
 maven.junit.jvmargs=-Djava.security.auth.login.config=src/test-resources/data/login.config
-ea
 maven.junit.fork=true

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyFilterMapping.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyFilterMapping.java?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyFilterMapping.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyFilterMapping.java
Mon Mar 28 14:47:54 2005
@@ -21,9 +21,8 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.mortbay.jetty.servlet.WebApplicationHandler;
-import org.mortbay.jetty.servlet.FilterHolder;
 import org.mortbay.jetty.servlet.Dispatcher;
+import org.mortbay.jetty.servlet.WebApplicationHandler;
 
 /**
  * @version $Rev:  $ $Date:  $

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
Mon Mar 28 14:47:54 2005
@@ -88,7 +88,6 @@
             throws ServletException, UnavailableException, IOException {
 
         currentServletHolder.set(this);
-        PolicyContext.setHandlerData(ServletHttpRequest.unwrap(request));
 
         super.handle(request, response);
     }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Mon Mar 28 14:47:54 2005
@@ -39,6 +39,7 @@
 import org.mortbay.http.HttpResponse;
 import org.mortbay.http.HttpException;
 import org.mortbay.jetty.servlet.*;
+import org.mortbay.jetty.servlet.Dispatcher;
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -50,6 +51,7 @@
 import org.apache.geronimo.jetty.interceptor.TransactionContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.WebApplicationContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.SecurityContextBeforeAfter;
+import org.apache.geronimo.jetty.interceptor.RequestWrappingBeforeAfter;
 import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
@@ -232,16 +234,17 @@
         interceptor = new ThreadClassloaderBeforeAfter(interceptor, index++, index++, this.webClassLoader);
         interceptor = new WebApplicationContextBeforeAfter(interceptor, index++, this);
 //JACC
-        if (securityConfig != null) {
+        if (securityRealmName != null) {
             //set the JAASJettyRealm as our realm.
             JAASJettyRealm realm = new JAASJettyRealm(realmName, securityRealmName);
             setRealm(realm);
             this.securityInterceptor = new SecurityContextBeforeAfter(interceptor, index++,
index++, policyContextID, securityConfig, authenticator, securityRoles, uncheckedPermissions,
excludedPermissions, rolePermissions, realm);
-            interceptor = securityInterceptor;
+            interceptor = this.securityInterceptor;
         } else {
             securityInterceptor = null;
         }
 //end JACC
+        interceptor = new RequestWrappingBeforeAfter(interceptor, handler);
         chain = interceptor;
         contextLength = index;
 

Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/RequestWrappingBeforeAfter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/RequestWrappingBeforeAfter.java?view=auto&rev=159321
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/RequestWrappingBeforeAfter.java
(added)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/RequestWrappingBeforeAfter.java
Mon Mar 28 14:47:54 2005
@@ -0,0 +1,55 @@
+/**
+ *
+ * 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.jetty.interceptor;
+
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHttpRequest;
+import org.mortbay.jetty.servlet.ServletHttpResponse;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class RequestWrappingBeforeAfter implements BeforeAfter {
+    private final BeforeAfter next;
+    private final ServletHandler handler;
+
+    public RequestWrappingBeforeAfter(BeforeAfter next, ServletHandler handler) {
+        this.next = next;
+        this.handler = handler;
+    }
+    
+    public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse)
{
+        if (httpRequest != null) {
+            ServletHttpRequest request = (ServletHttpRequest) httpRequest.getWrapper();
+            if (request == null)
+            {
+                // Build the request and response.
+                request = new ServletHttpRequest(handler, null, httpRequest);
+                ServletHttpResponse response = new ServletHttpResponse(request, httpResponse);
+                httpRequest.setWrapper(request);
+                httpResponse.setWrapper(response);
+            }
+        }
+        next.before(context, httpRequest, httpResponse);
+    }
+
+    public void after(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse)
{
+        next.after(context, httpRequest, httpResponse);
+    }
+}

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java?view=diff&r1=159320&r2=159321
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java
Mon Mar 28 14:47:54 2005
@@ -37,21 +37,12 @@
 import javax.security.jacc.WebResourcePermission;
 import javax.security.jacc.WebRoleRefPermission;
 import javax.security.jacc.WebUserDataPermission;
-
-import org.mortbay.http.Authenticator;
-import org.mortbay.http.HttpException;
-import org.mortbay.http.HttpRequest;
-import org.mortbay.http.HttpResponse;
-import org.mortbay.http.SecurityConstraint;
-import org.mortbay.http.UserRealm;
-import org.mortbay.jetty.servlet.FormAuthenticator;
-import org.mortbay.jetty.servlet.ServletHttpRequest;
+import javax.servlet.http.HttpServletRequest;
 
 import org.apache.geronimo.common.GeronimoSecurityException;
 import org.apache.geronimo.jetty.JAASJettyPrincipal;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
-import org.apache.geronimo.security.PrimaryRealmPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
 import org.apache.geronimo.security.SubjectId;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
@@ -62,6 +53,14 @@
 import org.apache.geronimo.security.jacc.RoleMappingConfiguration;
 import org.apache.geronimo.security.jacc.RoleMappingConfigurationFactory;
 import org.apache.geronimo.security.util.ConfigurationUtil;
+import org.mortbay.http.Authenticator;
+import org.mortbay.http.HttpException;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+import org.mortbay.http.SecurityConstraint;
+import org.mortbay.http.UserRealm;
+import org.mortbay.jetty.servlet.FormAuthenticator;
+import org.mortbay.jetty.servlet.ServletHttpRequest;
 
 
 /**
@@ -175,6 +174,11 @@
         PolicyContext.setContextID(policyContextID);
         setCurrentSecurityInterceptor(this);
 
+        if (httpRequest != null){
+            ServletHttpRequest request = (ServletHttpRequest)httpRequest.getWrapper();
+            PolicyContext.setHandlerData((HttpServletRequest)request);
+        }
+
         if (next != null) {
             next.before(context, httpRequest, httpResponse);
         }
@@ -352,19 +356,7 @@
         }
 
         JAASJettyPrincipal result = new JAASJettyPrincipal("default");
-        Subject defaultSubject = new Subject();
-
-        RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(defaultPrincipal.getPrincipal(),
defaultPrincipal.getRealmName());
-        if (realmPrincipal == null) {
-            throw new GeronimoSecurityException("Unable to create realm principal");
-        }
-        PrimaryRealmPrincipal primaryRealmPrincipal = ConfigurationUtil.generatePrimaryRealmPrincipal(defaultPrincipal.getPrincipal(),
defaultPrincipal.getRealmName());
-        if (primaryRealmPrincipal == null) {
-            throw new GeronimoSecurityException("Unable to create primary realm principal");
-        }
-
-        defaultSubject.getPrincipals().add(realmPrincipal);
-        defaultSubject.getPrincipals().add(primaryRealmPrincipal);
+        Subject defaultSubject = ConfigurationUtil.generateDefaultSubject(defaultPrincipal);
 
         result.setSubject(defaultSubject);
 



Mime
View raw message