geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r371341 - in /geronimo/trunk/modules: jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ jetty/src/java/org/apache/geronimo/jetty/ jetty/src/java/org/apache/geronimo/jetty/interceptor/
Date Sun, 22 Jan 2006 18:18:38 GMT
Author: djencks
Date: Sun Jan 22 10:18:34 2006
New Revision: 371341

URL: http://svn.apache.org/viewcvs?rev=371341&view=rev
Log:
GERONIMO-1440 Supply a 'Non'Authenticator if security realm name is supplied but no login
method specified. This makes jetty install the defaultPrincipal/Subject for unsecured web
apps

Added:
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/NonAuthenticator.java
Modified:
    geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java

Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=371341&r1=371340&r2=371341&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Sun Jan 22 10:18:34 2006
@@ -42,6 +42,7 @@
 import org.apache.geronimo.jetty.JettyFilterMapping;
 import org.apache.geronimo.jetty.JettyServletHolder;
 import org.apache.geronimo.jetty.JettyWebAppContext;
+import org.apache.geronimo.jetty.NonAuthenticator;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -250,7 +251,7 @@
         }
 
         // get the ids from either the application plan or for a stand alone module from
the specific deployer
-        URI configId = null;
+        URI configId;
         try {
             configId = new URI(jettyWebApp.getConfigId());
         } catch (URISyntaxException e) {
@@ -312,7 +313,7 @@
                 log.warn(e);
             }
 
-            JettyWebAppType jettyWebApp = null;
+            JettyWebAppType jettyWebApp;
             if (rawPlan != null) {
                 XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
                         JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(),
"jetty").convertToSpecificPlan(rawPlan);
@@ -448,7 +449,7 @@
         GbeanType[] gbeans = jettyWebApp.getGbeanArray();
         ServiceConfigBuilder.addGBeans(gbeans, webClassLoader, moduleJ2eeContext, earContext);
 
-        ObjectName webModuleName = null;
+        ObjectName webModuleName;
         try {
             webModuleName = NameFactory.getModuleName(null, null, null, null, null, moduleJ2eeContext);
         } catch (MalformedObjectNameException e) {
@@ -616,6 +617,8 @@
                     webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
                 }
 
+            } else if (jettyWebApp.isSetSecurityRealmName()) {
+                webModuleData.setAttribute("authenticator", new NonAuthenticator());
             }
             earContext.addGBean(webModuleData);
 
@@ -844,7 +847,7 @@
         getWebClassPath(earContext, webModule);
         URI[] webClassPath = webModule.getWebClasspath();
         URI baseUri = earContext.getBaseDir().toURI();
-        URL baseUrl = null;
+        URL baseUrl;
         try {
             baseUrl = baseUri.resolve(webModule.getTargetPathURI()).toURL();
         } catch (MalformedURLException e) {
@@ -942,13 +945,13 @@
         GBeanData servletData;
         if (servletType.isSetServletClass()) {
             String servletClassName = servletType.getServletClass().getStringValue().trim();
-            Class servletClass = null;
+            Class servletClass;
             try {
                 servletClass = webClassLoader.loadClass(servletClassName);
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("Could not load servlet class " + servletClassName,
e);
             }
-            Class baseServletClass = null;
+            Class baseServletClass;
             try {
                 baseServletClass = webClassLoader.loadClass(Servlet.class.getName());
             } catch (ClassNotFoundException e) {

Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/NonAuthenticator.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/NonAuthenticator.java?rev=371341&view=auto
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/NonAuthenticator.java
(added)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/NonAuthenticator.java
Sun Jan 22 10:18:34 2006
@@ -0,0 +1,23 @@
+package org.apache.geronimo.jetty;
+
+import org.mortbay.http.Authenticator;
+import org.mortbay.http.UserRealm;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+
+import java.security.Principal;
+import java.io.IOException;
+
+/**
+ * Authenticator that always denies, returning null.  Useful when you need to install a default
principal/subject
+ * in an unsecured web app.
+ */
+public class NonAuthenticator implements Authenticator {
+    public Principal authenticate(UserRealm realm, String pathInContext, HttpRequest request,
HttpResponse response) throws IOException {
+        return null;
+    }
+
+    public String getAuthMethod() {
+        return "None"; 
+    }
+}

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?rev=371341&r1=371340&r2=371341&view=diff
==============================================================================
--- 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
Sun Jan 22 10:18:34 2006
@@ -240,7 +240,7 @@
      *         security checking should not proceed and servlet handling should proceed,
      *         e.g. login page.
      */
-    private Principal obtainUser(String pathInContext, HttpRequest request, HttpResponse
response, WebResourcePermission resourcePermission, WebUserDataPermission dataPermission)
throws IOException, IOException {
+    private Principal obtainUser(String pathInContext, HttpRequest request, HttpResponse
response, WebResourcePermission resourcePermission, WebUserDataPermission dataPermission)
throws IOException {
         boolean unauthenticated = !(checked.implies(resourcePermission) || checked.implies(dataPermission));
         boolean forbidden = excludedPermissions.implies(resourcePermission) || excludedPermissions.implies(dataPermission);
 



Mime
View raw message