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/05/24 00:32:25 UTC
svn commit: r778047 - in
/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src:
main/java/org/apache/geronimo/security/jaas/
main/java/org/apache/geronimo/security/realm/
test/java/org/apache/geronimo/security/jaas/
Author: djencks
Date: Sat May 23 22:32:25 2009
New Revision: 778047
URL: http://svn.apache.org/viewvc?rev=778047&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
Added:
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java (with props)
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java (with props)
Modified:
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java
Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationEntryFactory.java Sat May 23 22:32:25 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();
}
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java?rev=778047&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java Sat May 23 22:32:25 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.security.jaas;
+
+import javax.security.auth.login.Configuration;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ConfigurationFactory {
+
+ String getConfigurationName();
+
+ Configuration getConfiguration();
+
+}
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/ConfigurationFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/DirectConfigurationEntry.java Sat May 23 22:32:25 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/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java Sat May 23 22:32:25 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());
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java?rev=778047&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java Sat May 23 22:32:25 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.security.jaas;
+
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.AppConfigurationEntry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingleLoginConfiguration extends Configuration {
+
+ private final ConfigurationEntryFactory configurationEntryFactory;
+
+ public SingleLoginConfiguration(ConfigurationEntryFactory configurationEntryFactory) {
+ if (configurationEntryFactory == null) throw new NullPointerException("configurationEntryFactory required");
+ this.configurationEntryFactory = configurationEntryFactory;
+ }
+
+ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
+ if (!configurationEntryFactory.getConfigurationName().equals(s)) throw new IllegalArgumentException("realm name " + s + " does not match expected " + configurationEntryFactory.getConfigurationName());
+ return configurationEntryFactory.getAppConfigurationEntries();
+ }
+
+ public void refresh() {
+ configurationEntryFactory.refresh();
+ }
+}
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/SingleLoginConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java Sat May 23 22:32:25 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/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/AbstractLoginModuleTest.java Sat May 23 22:32:25 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/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java Sat May 23 22:32:25 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/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/NoLoginModuleReuseTest.java Sat May 23 22:32:25 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/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java?rev=778047&r1=778046&r2=778047&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/TimeoutTest.java Sat May 23 22:32:25 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);