geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r413196 - in /geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty: JettyEJBWebServiceContext.java JettyWebAppContext.java JettyWebApplicationHandler.java
Date Sat, 10 Jun 2006 00:19:45 GMT
Author: djencks
Date: Fri Jun  9 17:19:44 2006
New Revision: 413196

URL: http://svn.apache.org/viewvc?rev=413196&view=rev
Log:
GERONIMO-2100 Be sure defaultSubject is set properly for ejb web services and prevent subject
from leaking back into the calling environment

Added:
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationHandler.java
      - copied unchanged from r413195, geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationHandler.java
Modified:
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java

Modified: geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java?rev=413196&r1=413195&r2=413196&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
(original)
+++ geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
Fri Jun  9 17:19:44 2006
@@ -16,9 +16,6 @@
  */
 package org.apache.geronimo.jetty;
 
-import org.apache.geronimo.webservices.WebServiceContainer;
-import org.mortbay.http.*;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -27,6 +24,20 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.security.auth.Subject;
+
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.webservices.WebServiceContainer;
+import org.mortbay.http.Authenticator;
+import org.mortbay.http.BasicAuthenticator;
+import org.mortbay.http.ClientCertAuthenticator;
+import org.mortbay.http.DigestAuthenticator;
+import org.mortbay.http.HttpContext;
+import org.mortbay.http.HttpException;
+import org.mortbay.http.HttpHandler;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+
 /**
  * Delegates requests to a WebServiceContainer which is presumably for an EJB WebService.
  * <p/>
@@ -142,12 +153,19 @@
             Thread currentThread = Thread.currentThread();
             ClassLoader oldClassLoader = currentThread.getContextClassLoader();
             currentThread.setContextClassLoader(classLoader);
+            //hard to imagine this could be anything but null, but....
+            Subject oldSubject = ContextManager.getCurrentCaller();
             try {
                 if (authenticator != null) {
                     String pathInContext = org.mortbay.util.URI.canonicalPath(req.getPath());
                     if (authenticator.authenticate(realm, pathInContext, req, res) == null)
{
                         throw new HttpException(403);
                     }
+                } else {
+                    //EJB will figure out correct defaultSubject shortly
+                    //TODO consider replacing the GenericEJBContainer.DefaultSubjectInterceptor
with this line
+                    //setting the defaultSubject.
+                    ContextManager.setCurrentCaller(null);
                 }
                 try {
                     webServiceContainer.invoke(request, response);
@@ -158,6 +176,7 @@
                     throw (HttpException) new HttpException(500, "Could not process message!").initCause(e);
                 }
             } finally {
+                ContextManager.setCurrentCaller(oldSubject);
                 currentThread.setContextClassLoader(oldClassLoader);
             }
         }

Modified: geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?rev=413196&r1=413195&r2=413196&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Fri Jun  9 17:19:44 2006
@@ -237,7 +237,8 @@
             setVirtualHosts(host.getVirtualHosts());
         }
 
-        handler = new WebApplicationHandler();
+        //use our wrapper to avoid leaking subject back to the caller
+        handler = new JettyWebApplicationHandler();
         addHandler(handler);
 
         userTransaction.setUp(transactionContextManager, trackedConnectionAssociator);



Mime
View raw message