You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2006/04/08 01:03:57 UTC

svn commit: r392443 - in /geronimo/branches/1.1: applications/console-core/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/ modules/security/src/java/org/apache/geronim...

Author: ammulder
Date: Fri Apr  7 16:03:51 2006
New Revision: 392443

URL: http://svn.apache.org/viewcvs?rev=392443&view=rev
Log:
Unbreak the security realm portlet under 1.1 (quite nearly).
Also fix the problems with testing a login if you manually specify
  JDBC settings instead of referring to a database pool

Modified:
    geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
    geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java

Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java?rev=392443&r1=392442&r2=392443&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java (original)
+++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java Fri Apr  7 16:03:51 2006
@@ -727,14 +727,18 @@
 
     public void testLoginModule(J2EEServer server, LoginModule module, Map options) {
         options.put(JaasLoginModuleUse.KERNEL_NAME_LM_OPTION, kernel.getKernelName());
-        options.put(JaasLoginModuleUse.CLASSLOADER_LM_OPTION, module.getClass().getClassLoader());
         options.put(JaasLoginModuleUse.SERVERINFO_LM_OPTION, server.getServerInfo());
+        if(!options.containsKey(JaasLoginModuleUse.CLASSLOADER_LM_OPTION)) {
+            options.put(JaasLoginModuleUse.CLASSLOADER_LM_OPTION, module.getClass().getClassLoader());
+        }
         module.initialize(null, null, new HashMap(), options);
     }
 
     public Subject testLoginModule(final J2EEServer server, final LoginModule module, final Map options, final String username, final String password) throws LoginException {
         options.put(JaasLoginModuleUse.KERNEL_NAME_LM_OPTION, kernel.getKernelName());
-        options.put(JaasLoginModuleUse.CLASSLOADER_LM_OPTION, module.getClass().getClassLoader());
+        if(!options.containsKey(JaasLoginModuleUse.CLASSLOADER_LM_OPTION)) {
+            options.put(JaasLoginModuleUse.CLASSLOADER_LM_OPTION, module.getClass().getClassLoader());
+        }
         options.put(JaasLoginModuleUse.SERVERINFO_LM_OPTION, server.getServerInfo());
         Subject sub = new Subject();
         CallbackHandler handler = new CallbackHandler() {

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java?rev=392443&r1=392442&r2=392443&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java Fri Apr  7 16:03:51 2006
@@ -37,10 +37,11 @@
 import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
 import org.apache.geronimo.security.jaas.JaasLoginModuleChain;
 import org.apache.geronimo.security.jaas.LoginModuleSettings;
-import org.apache.geronimo.security.realm.SecurityRealm;
+import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
 import org.apache.geronimo.security.realm.providers.FileAuditLoginModule;
 import org.apache.geronimo.security.realm.providers.GeronimoPasswordCredentialLoginModule;
 import org.apache.geronimo.security.realm.providers.RepeatedFailureLockoutLoginModule;
+import org.apache.geronimo.security.realm.SecurityRealm;
 import org.apache.geronimo.xbeans.geronimo.loginconfig.GerControlFlagType;
 import org.apache.geronimo.xbeans.geronimo.loginconfig.GerLoginConfigDocument;
 import org.apache.geronimo.xbeans.geronimo.loginconfig.GerLoginConfigType;
@@ -259,6 +260,7 @@
         Map options = new HashMap();
         try {
             LoginModule module = loadModule(request, data, options);
+            log.warn("Testing with options "+options);
             try {
                 PortletManager.testLoginModule(request, module, options);
                 return null;
@@ -299,6 +301,7 @@
                 options.put(key, value);
             }
         }
+        options.put(JaasLoginModuleUse.CLASSLOADER_LM_OPTION, loader);
         return module;
     }
 
@@ -322,13 +325,20 @@
         ConfigurationType root = doc.addNewConfiguration();
         EnvironmentType environment = root.addNewEnvironment();
         ArtifactType configId = environment.addNewConfigId();
-        configId.setGroupId(Artifact.DEFAULT_GROUP_ID);
-        configId.setArtifactId(data.getName());
-
-        // Use a parentId of null to pick up the default
+        configId.setGroupId("console");
+        configId.setArtifactId("realm-"+data.getName());
+        configId.setVersion("1.0");
+        configId.setType("car");
+
+        // Parent
+
+        DependenciesType dependenciesType = environment.addNewDependencies();
+        ArtifactType parent = dependenciesType.addNewDependency();
+        parent.setGroupId("geronimo");
+        parent.setArtifactId("j2ee-security");
+        parent.setType("car");
         // Dependencies
         if(data.getJar() != null) {
-            DependenciesType dependenciesType = environment.addNewDependencies();
             ArtifactType artifactType = dependenciesType.addNewDependency();
             Artifact artifact = Artifact.create(data.getJar());
             artifactType.setGroupId(artifact.getGroupId());
@@ -391,13 +401,6 @@
                             if(testName.equals(poolName) && testApp.equals(appName)) {
                                 String moduleName = objectName.getKeyProperty(NameFactory.JCA_RESOURCE);
 
-                                DependenciesType dependenciesType;
-                                if (environment.isSetDependencies()) {
-                                    dependenciesType = environment.getDependencies();
-                                } else {
-                                    dependenciesType = environment.addNewDependencies();
-                                }
-
                                 ArtifactType artifactType = dependenciesType.addNewDependency();
                                 Artifact artifact = Artifact.create(moduleName);
                                 artifactType.setGroupId(artifact.getGroupId());
@@ -505,16 +508,15 @@
     }
 
     private void renderList(RenderRequest request, RenderResponse response) throws IOException, PortletException {
-        SecurityRealm[] realms = (SecurityRealm[]) PortletManager.getCurrentServer(request).getSecurityRealms();
+        // Unfortunately there are two classes named SecurityRealm; one extends the other
+        // The array type is management.geronimo.SecurityRealm (the superclass)
+        // The array entry types are security.realm.SecurityRealm (the subclass)
+        org.apache.geronimo.management.geronimo.SecurityRealm[] realms = PortletManager.getCurrentServer(request).getSecurityRealms();
         ExistingRealm[] results = new ExistingRealm[realms.length];
         for (int i = 0; i < results.length; i++) {
             final GeronimoManagedBean managedBean = (GeronimoManagedBean)realms[i];
-            try {
-                results[i] = new ExistingRealm(realms[i].getRealmName(), ObjectName.getInstance(managedBean.getObjectName()),
-                        managedBean.getState());
-            } catch (MalformedObjectNameException e) {
-                log.error("Unable to retrieve ObjectName for security realm", e);
-            }
+            results[i] = new ExistingRealm(realms[i].getRealmName(), PortletManager.getNameFor(request, realms[i]),
+                    managedBean.getState());
         }
         request.setAttribute("realms", results);
         listView.include(request, response);
@@ -611,7 +613,7 @@
                 if(appName != null && !appName.equals("null")) {
                     display = display+" ("+appName+")";
                 }
-                pools.add(new DatabasePool(name, display, appName, factory.getObjectName()));
+                pools.add(new DatabasePool(name, display, appName, PortletManager.getNameFor(renderRequest, factory)));
             }
             renderRequest.setAttribute("pools", pools);
         } catch (MalformedObjectNameException e) {
@@ -920,7 +922,7 @@
         }
 
         /**
-         * @deprecated Use getAbstractName instead
+         * @deprecated Use getAbstractName() instead
          */
         public String getObjectName() {
             return abstractName;
@@ -1007,14 +1009,14 @@
 
     public static class ExistingRealm implements Serializable {
         private final String name;
-        private final String objectName;
+        private final String abstractName;
         private final String parentName;
         private final int state;
 
-        public ExistingRealm(String name, ObjectName objectName, int state) {
+        public ExistingRealm(String name, AbstractName objectName, int state) {
             this.name = name;
-            this.objectName = objectName.getCanonicalName();
-            String parent = objectName.getKeyProperty(NameFactory.J2EE_APPLICATION);
+            this.abstractName = objectName.toString();
+            String parent = (String) objectName.getName().get(NameFactory.J2EE_APPLICATION);
             if(parent != null && parent.equals("null")) {
                 parent = null;
             }
@@ -1027,8 +1029,15 @@
             return name;
         }
 
+        /**
+         * @deprecated Use getAbstractName() instead
+         */
         public String getObjectName() {
-            return objectName;
+            return abstractName;
+        }
+
+        public String getAbstractName() {
+            return abstractName;
         }
 
         public String getParentName() {
@@ -1048,13 +1057,13 @@
         private final String name;
         private final String displayName;
         private final String applicationName;
-        private final String objectName;
+        private final String abstractName;
 
-        public DatabasePool(String name, String displayName, String applicationName, String objectName) {
+        public DatabasePool(String name, String displayName, String applicationName, AbstractName abstractName) {
             this.name = name;
             this.displayName = displayName;
             this.applicationName = applicationName;
-            this.objectName = objectName;
+            this.abstractName = abstractName.toString();
         }
 
         public String getName() {
@@ -1065,8 +1074,15 @@
             return applicationName;
         }
 
+        /**
+         * @deprecated Use getAbstractName() instead
+         */
         public String getObjectName() {
-            return objectName;
+            return abstractName;
+        }
+
+        public String getAbstrcatName() {
+            return abstractName;
         }
 
         public String getDisplayName() {

Modified: geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java?rev=392443&r1=392442&r2=392443&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java (original)
+++ geronimo/branches/1.1/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java Fri Apr  7 16:03:51 2006
@@ -130,13 +130,17 @@
         } else {
             connectionURL = (String) options.get(CONNECTION_URL);
             properties = new Properties();
-            properties.put("user", options.get(USER));
-            properties.put("password", options.get(PASSWORD));
+            if(options.get(USER) != null) {
+                properties.put("user", options.get(USER));
+            }
+            if(options.get(PASSWORD) != null) {
+                properties.put("password", options.get(PASSWORD));
+            }
             ClassLoader cl = (ClassLoader) options.get(JaasLoginModuleUse.CLASSLOADER_LM_OPTION);
             try {
                 this.driver = (Driver) cl.loadClass((String) options.get(DRIVER)).newInstance();
             } catch (ClassNotFoundException e) {
-                throw new IllegalArgumentException("Driver class " + driver + " is not available.  Perhaps you need to add it as a dependency in your deployment plan?");
+                throw new IllegalArgumentException("Driver class " + options.get(DRIVER) + " is not available.  Perhaps you need to add it as a dependency in your deployment plan?");
             } catch (Exception e) {
                 throw new IllegalArgumentException("Unable to load, instantiate, register driver " + driver + ": " + e.getMessage());
             }