You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/07/20 20:09:53 UTC

svn commit: r795937 - /geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java

Author: djencks
Date: Mon Jul 20 18:09:53 2009
New Revision: 795937

URL: http://svn.apache.org/viewvc?rev=795937&view=rev
Log:
GERONIMO-4756 prospective fix

Modified:
    geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java

Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java?rev=795937&r1=795936&r2=795937&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/JettyModuleBuilder.java Mon Jul 20 18:09:53 2009
@@ -87,6 +87,7 @@
 import org.apache.geronimo.jetty7.security.AuthConfigProviderHandlerFactory;
 import org.apache.geronimo.jetty7.security.BuiltInAuthMethod;
 import org.apache.geronimo.jetty7.security.JettySecurityHandlerFactory;
+import org.apache.geronimo.jetty7.security.auth.NoneAuthenticator;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
@@ -778,7 +779,7 @@
             throw new DeploymentException("Web app " + module.getName() + " cannot have more than one login-config element.  Currently has " + loginConfigArray.length + " login-config elements.");
         }
         JettyAuthenticationType authType = jettyWebApp.getAuthentication();
-        if (loginConfigArray.length == 1 || authType != null) {
+        if (loginConfigArray.length == 1 || authType != null || jettyWebApp.isSetSecurityRealmName()) {
             AbstractName factoryName = moduleContext.getNaming().createChildName(module.getModuleName(), "securityHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
             webModuleData.setReferencePattern("SecurityHandlerFactory", factoryName);
 
@@ -863,42 +864,41 @@
                 }
                 //otherwise rely on pre-configured jaspi
             } else {
-                LoginConfigType loginConfig = loginConfigArray[0];
-                if (loginConfig.isSetAuthMethod()) {
-                    String authMethod = loginConfig.getAuthMethod().getStringValue().trim();
-                    BuiltInAuthMethod auth = BuiltInAuthMethod.getValueOf(authMethod);
-                    GBeanData securityFactoryData = new GBeanData(factoryName, JettySecurityHandlerFactory.class);
-                    securityFactoryData.setAttribute("authMethod", auth);
-                    configureConfigurationFactory(jettyWebApp, loginConfig, securityFactoryData);
-
-                    moduleContext.addGBean(securityFactoryData);
-
-
-                    if (auth == BuiltInAuthMethod.BASIC) {
-                        securityFactoryData.setAttribute("realmName", loginConfig.getRealmName().getStringValue().trim());
-                    } else if (auth == BuiltInAuthMethod.DIGEST) {
-                        securityFactoryData.setAttribute("realmName", loginConfig.getRealmName().getStringValue().trim());
-                    } else if (auth == BuiltInAuthMethod.FORM) {
-                        if (loginConfig.isSetFormLoginConfig()) {
-                            FormLoginConfigType formLoginConfig = loginConfig.getFormLoginConfig();
-                            securityFactoryData.setAttribute("loginPage", formLoginConfig.getFormLoginPage().getStringValue());
-                            securityFactoryData.setAttribute("errorPage", formLoginConfig.getFormErrorPage().getStringValue());
+                LoginConfigType loginConfig = loginConfigArray.length == 1? loginConfigArray[0]: null;
+                GBeanData securityFactoryData = new GBeanData(factoryName, JettySecurityHandlerFactory.class);
+                configureConfigurationFactory(jettyWebApp, loginConfig, securityFactoryData);
+                BuiltInAuthMethod auth = BuiltInAuthMethod.NONE;
+                if (loginConfig != null) {
+                    if (loginConfig.isSetAuthMethod()) {
+                        String authMethod = loginConfig.getAuthMethod().getStringValue().trim();
+                        auth = BuiltInAuthMethod.getValueOf(authMethod);
+
+                        if (auth == BuiltInAuthMethod.BASIC) {
+                            securityFactoryData.setAttribute("realmName", loginConfig.getRealmName().getStringValue().trim());
+                        } else if (auth == BuiltInAuthMethod.DIGEST) {
+                            securityFactoryData.setAttribute("realmName", loginConfig.getRealmName().getStringValue().trim());
+                        } else if (auth == BuiltInAuthMethod.FORM) {
+                            if (loginConfig.isSetFormLoginConfig()) {
+                                FormLoginConfigType formLoginConfig = loginConfig.getFormLoginConfig();
+                                securityFactoryData.setAttribute("loginPage", formLoginConfig.getFormLoginPage().getStringValue());
+                                securityFactoryData.setAttribute("errorPage", formLoginConfig.getFormErrorPage().getStringValue());
+                            }
+                        } else if (auth == BuiltInAuthMethod.CLIENTCERT) {
+                            //nothing to do
+                        } else {
+                            throw new DeploymentException("unrecognized auth method, use jaspi to configure: " + authMethod);
                         }
-                    } else if (auth == BuiltInAuthMethod.CLIENTCERT) {
-                        //nothing to do
+
                     } else {
-                        throw new DeploymentException("unrecognized auth method, use jaspi to configure: " + authMethod);
+                        throw new DeploymentException("No auth method configured and no jaspi configured");
+                    }
+                    if (loginConfig.isSetRealmName()) {
+                        webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
                     }
-
-                } else {
-                    throw new DeploymentException("No auth method configured and no jaspi configured");
-                }
-                if (loginConfig.isSetRealmName()) {
-                    webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
                 }
+                securityFactoryData.setAttribute("authMethod", auth);
+                moduleContext.addGBean(securityFactoryData);
             }
-//        } else if (jettyWebApp.isSetSecurityRealmName()) {
-//            webModuleData.setAttribute("authenticator", new NonAuthenticator());
         }
     }