geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r778049 - in /geronimo/sandbox/djencks/framework/modules/geronimo-security: ./ src/main/java/org/apache/geronimo/security/jaas/ src/main/java/org/apache/geronimo/security/realm/ src/test/java/org/apache/geronimo/security/jaas/
Date Sat, 23 May 2009 22:35:54 GMT
Author: djencks
Date: Sat May 23 22:35:54 2009
New Revision: 778049

URL: http://svn.apache.org/viewvc?rev=778049&view=rev
Log:
GERONIMO-4553 Support for non-global single-realm Configuration instances to be supplied to
ContextManager.login methods.  Note this change makes realms non-global by default.  Merge
from osgi sandbox branch

Added:
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
      - copied unchanged from r778047, geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
      - copied unchanged from r778047, geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
Modified:
    geronimo/sandbox/djencks/framework/modules/geronimo-security/   (props changed)
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
    geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java

Propchange: geronimo/sandbox/djencks/framework/modules/geronimo-security/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat May 23 22:35:54 2009
@@ -0,0 +1,2 @@
+/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security:778047
+/geronimo/server/trunk/framework/modules/geronimo-security:749113,749116-761814

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
Sat May 23 22:35:54 2009
@@ -44,5 +44,15 @@
      */
     AppConfigurationEntry[] getAppConfigurationEntries();
 
-    Boolean isPublish();
+    /**
+     * return false to exclude from global GeronimoLoginConfiguration
+     *
+     * @return whether to include in GeronimoLoginConfiguration
+     */
+    boolean isGlobal();
+
+    /**
+     * delegate from Configuration
+     */
+    void refresh();
 }

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
Sat May 23 22:35:54 2009
@@ -57,10 +57,13 @@
     }
 
     //TODO configure this
-    public Boolean isPublish() {
+    public boolean isGlobal() {
         return true;
     }
 
+    public void refresh() {
+    }
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
Sat May 23 22:35:54 2009
@@ -18,15 +18,12 @@
 package org.apache.geronimo.security.jaas;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.ReferenceCollection;
 import org.apache.geronimo.gbean.ReferenceCollectionEvent;
@@ -75,7 +72,7 @@
         }
     }
 
-    public Collection getConfigurations() {
+    public Collection<ConfigurationEntryFactory> getConfigurations() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) sm.checkPermission(SecurityServiceImpl.CONFIGURE);
 
@@ -108,10 +105,10 @@
     }
 
     private void addConfiguration(ConfigurationEntryFactory factory) {
-        if (entries.containsKey(factory.getConfigurationName())) {
-            throw new java.lang.IllegalArgumentException("ConfigurationEntry named: " + factory.getConfigurationName()
+ " already registered");
-        }
-        if (useAllConfigurations || factory.isPublish()) {
+        if (useAllConfigurations || factory.isGlobal()) {
+            if (entries.containsKey(factory.getConfigurationName())) {
+                throw new java.lang.IllegalArgumentException("ConfigurationEntry named: "
+ factory.getConfigurationName() + " already registered");
+            }
             AppConfigurationEntry[] ace = factory.getAppConfigurationEntries();
             entries.put(factory.getConfigurationName(), ace);
             log.debug("Added Application Configuration Entry " + factory.getConfigurationName());

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
Sat May 23 22:35:54 2009
@@ -19,23 +19,23 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Properties;
 import java.util.Set;
 
 import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
 
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.security.SecurityNames;
 import org.apache.geronimo.security.jaas.ConfigurationEntryFactory;
 import org.apache.geronimo.security.jaas.JaasLoginModuleChain;
 import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
-import org.apache.geronimo.security.SecurityNames;
+import org.apache.geronimo.security.jaas.SingleLoginConfiguration;
+import org.apache.geronimo.security.jaas.ConfigurationFactory;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
 
@@ -60,7 +60,7 @@
  * @version $Rev$ $Date$
  */
 @GBean(j2eeType = SecurityNames.SECURITY_REALM)
-public class GenericSecurityRealm implements SecurityRealm, ConfigurationEntryFactory {
+public class GenericSecurityRealm implements SecurityRealm, ConfigurationEntryFactory, ConfigurationFactory
{
 
     private final String realmName;
     private AppConfigurationEntry[] config;
@@ -69,12 +69,16 @@
     private final boolean wrapPrincipals;
     private final JaasLoginModuleUse loginModuleUse;
 
-    private final boolean publish;
+    private final boolean global;
+    private final ServerInfo serverInfo;
+    private final ClassLoader classLoader;
+    private final Kernel kernel;
+    private final Configuration configuration;
 
     public GenericSecurityRealm(@ParamAttribute(name="realmName") String realmName,
                                 @ParamReference(name="LoginModuleConfiguration", namingType
= "LoginModuleUse")JaasLoginModuleUse loginModuleUse,
                                 @ParamAttribute(name="wrapPrincipals")boolean wrapPrincipals,
-                                @ParamAttribute(name="publish")Boolean publish,
+                                @ParamAttribute(name="global")boolean global,
                                 @ParamReference(name="ServerInfo")ServerInfo serverInfo,
                                 @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader
classLoader,
                                 @ParamSpecial(type = SpecialAttributeType.kernel)Kernel kernel
@@ -82,18 +86,13 @@
         this.realmName = realmName;
         this.wrapPrincipals = wrapPrincipals;
         this.loginModuleUse = loginModuleUse;
-        this.publish = publish == null || publish;
-
-        Set<String> domainNames = new HashSet<String>();
-        List<AppConfigurationEntry> loginModuleConfigurations = new ArrayList<AppConfigurationEntry>();
-
-        if (loginModuleUse != null) {
-            loginModuleUse.configure(domainNames, loginModuleConfigurations, realmName, kernel,
serverInfo, classLoader);
-        }
-
-        domains = domainNames.toArray(new String[domainNames.size()]);
-        config = loginModuleConfigurations.toArray(new AppConfigurationEntry[loginModuleConfigurations.size()]);
+        this.global = global;
+        this.serverInfo = serverInfo;
+        this.classLoader = classLoader;
+        this.kernel = kernel;
 
+        refresh();
+        configuration = new SingleLoginConfiguration(this);
     }
 
     public String getRealmName() {
@@ -130,8 +129,28 @@
         return realmName;
     }
 
-    public Boolean isPublish() {
-        return publish;
+    public boolean isGlobal() {
+        return global;
+    }
+
+    public void refresh() {
+        Set<String> domainNames = new HashSet<String>();
+        List<AppConfigurationEntry> loginModuleConfigurations = new ArrayList<AppConfigurationEntry>();
+
+        if (loginModuleUse != null) {
+            try {
+                loginModuleUse.configure(domainNames, loginModuleConfigurations, realmName,
kernel, serverInfo, classLoader);
+            } catch (ClassNotFoundException e) {
+                throw new IllegalStateException("can not configure realm", e);
+            }
+        }
+
+        domains = domainNames.toArray(new String[domainNames.size()]);
+        config = loginModuleConfigurations.toArray(new AppConfigurationEntry[loginModuleConfigurations.size()]);
+    }
+
+    public Configuration getConfiguration() {
+        return configuration;
     }
 
 }

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
Sat May 23 22:35:54 2009
@@ -60,6 +60,7 @@
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
         gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
         gbean.setReferencePattern("ServerInfo", serverInfo);
+        gbean.setAttribute("global", Boolean.TRUE);
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         gbean = buildGBeanData("name", "NeverFailLoginModule", LoginModuleGBean.class);
@@ -92,6 +93,7 @@
         gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
         gbean.setReferencePattern("LoginModuleConfiguration", neverFailUseName);
         gbean.setReferencePattern("ServerInfo", serverInfo);
+        gbean.setAttribute("global", Boolean.TRUE);
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
Sat May 23 22:35:54 2009
@@ -179,6 +179,7 @@
         gbean.setAttribute("realmName", "properties-realm");
         gbean.setReferencePattern("LoginModuleConfiguration", testUseName1);
         gbean.setReferencePattern("ServerInfo", serverInfo);
+        gbean.setAttribute("global", Boolean.TRUE);
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
Sat May 23 22:35:54 2009
@@ -51,7 +51,8 @@
         GenericSecurityRealm realm = new GenericSecurityRealm(realmName,
                 loginModuleUse,
                 wrapPrincipals,
-                null, null,
+                true,
+                null,
                 getClass().getClassLoader(),
                 null);
         GeronimoLoginConfiguration loginConfig = new GeronimoLoginConfiguration(Collections.<ConfigurationEntryFactory>singleton(realm),
false);

Modified: geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java?rev=778049&r1=778048&r2=778049&view=diff
==============================================================================
--- geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java
(original)
+++ geronimo/sandbox/djencks/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java
Sat May 23 22:35:54 2009
@@ -77,6 +77,7 @@
         gbean.setAttribute("realmName", "properties-realm");
         gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
         gbean.setReferencePattern("ServerInfo", serverInfo);
+        gbean.setAttribute("global", Boolean.TRUE);
         kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
 
         kernel.startGBean(loginConfiguration);



Mime
View raw message