jboynes 2004/05/28 15:22:41
Modified: modules/assembly maven.xml
modules/assembly/src/plan j2ee-server-plan.xml
modules/security/src/java/org/apache/geronimo/security/realm/providers
PropertiesFileSecurityRealm.java
modules/security/src/test/org/apache/geronimo/security/jaas
ConfigurationEntryTest.java
LoginPropertiesFileTest.java
modules/security/src/test/org/apache/geronimo/security/network/protocol
SubjectCarryingProtocolTest.java
modules/security/src/test/org/apache/geronimo/security/remoting/jmx
RemoteLoginTest.java
Log:
Allow PropertiesFileSecurityRealm to resolve locations relative to ServerInfo
Add realm to default configuration
Revision Changes Path
1.14 +6 -1 incubator-geronimo/modules/assembly/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/assembly/maven.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- maven.xml 26 May 2004 07:43:39 -0000 1.13
+++ maven.xml 28 May 2004 22:22:40 -0000 1.14
@@ -95,6 +95,11 @@
<ant:fileset dir="src/etc"/>
</ant:copy>
+ <!-- copy in data files -->
+ <ant:copy todir="${distDir}/var">
+ <ant:fileset dir="src/var"/>
+ </ant:copy>
+
<!-- Pre-load the server's repository -->
<ant:mkdir dir="${distDir}/repository"/>
<ant:copy todir="${distDir}/repository">
1.17 +15 -1
incubator-geronimo/modules/assembly/src/plan/j2ee-server-plan.xml
Index: j2ee-server-plan.xml
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/assembly/src/plan/j2ee-server-plan.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- j2ee-server-plan.xml 19 May 2004 20:53:58 -0000 1.16
+++ j2ee-server-plan.xml 28 May 2004 22:22:40 -0000 1.17
@@ -69,7 +69,21 @@
<!-- required for rar 1.5 to load realms -->
<dependency>
<uri>regexp/jars/regexp-1.3.jar</uri>
- </dependency>
+ </dependency>
+
+ <!-- Default security realm using properties files -->
+ <gbean
name="geronimo.security:type=SecurityRealm,realm=geronimo-properties-realm"
class="org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm">
+ <attribute name="RealmName"
type="java.lang.String">geronimo-properties-realm</attribute>
+ <attribute name="MaxLoginModuleAge" type="long">10000</attribute>
+ <attribute name="UsersURI"
type="java.net.URI">var/security/users.properties</attribute>
+ <attribute name="GroupsURI"
type="java.net.URI">var/security/groups.properties</attribute>
+ <reference
name="ServerInfo">geronimo.system:role=ServerInfo</reference>
+ </gbean>
+
+ <gbean name="geronimo.security:type=SecurityService"
class="org.apache.geronimo.security.SecurityService">
+ <attribute name="PolicyConfigurationFactory"
type="java.lang.String">org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory</attribute>
+ <reference
name="Realms">geronimo.security:type=SecurityRealm,*</reference>
+ </gbean>
<gbean name="geronimo.server:type=ConnectionTracker"
class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator">
</gbean>
1.6 +13 -12
incubator-geronimo/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileSecurityRealm.java
Index: PropertiesFileSecurityRealm.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileSecurityRealm.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropertiesFileSecurityRealm.java 22 May 2004 15:25:13 -0000 1.5
+++ PropertiesFileSecurityRealm.java 28 May 2004 22:22:40 -0000 1.6
@@ -34,6 +34,7 @@
import org.apache.geronimo.gbean.GConstructorInfo;
import org.apache.geronimo.gbean.GOperationInfo;
import org.apache.geronimo.security.GeronimoSecurityException;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
import org.apache.regexp.RE;
import org.apache.commons.logging.Log;
@@ -48,6 +49,8 @@
private static final GBeanInfo GBEAN_INFO;
private static Log log =
LogFactory.getLog(PropertiesFileSecurityRealm.class);
+ private final ServerInfo serverInfo;
+
private boolean running = false;
private URI usersURI;
private URI groupsURI;
@@ -56,12 +59,9 @@
final static String REALM_INSTANCE =
"org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm";
- //deprecated for geronimombeans only
- public PropertiesFileSecurityRealm() {
- }
-
- public PropertiesFileSecurityRealm(String realmName, URI usersURI, URI
groupsURI) {
+ public PropertiesFileSecurityRealm(String realmName, URI usersURI, URI
groupsURI, ServerInfo serverInfo) {
super(realmName);
+ this.serverInfo = serverInfo;
setUsersURI(usersURI);
setGroupsURI(groupsURI);
}
@@ -92,7 +92,7 @@
if (running) {
throw new IllegalStateException("Cannot change the Users URI
after the realm is started");
}
- this.usersURI = usersURI == null ? null : usersURI.normalize();
+ this.usersURI = usersURI;
}
public URI getGroupsURI() {
@@ -103,7 +103,7 @@
if (running) {
throw new IllegalStateException("Cannot change the Groups URI
after the realm is started");
}
- this.groupsURI = groupsURI == null ? null : groupsURI.normalize();
+ this.groupsURI = groupsURI;
}
public Set getGroupPrincipals() throws GeronimoSecurityException {
@@ -158,10 +158,10 @@
public void refresh() throws GeronimoSecurityException {
try {
- users.load(usersURI.toURL().openStream());
+ users.load(serverInfo.resolve(usersURI).toURL().openStream());
Properties temp = new Properties();
- temp.load(groupsURI.toURL().openStream());
+ temp.load(serverInfo.resolve(groupsURI).toURL().openStream());
Enumeration enum = temp.keys();
while (enum.hasMoreElements()) {
@@ -206,8 +206,9 @@
infoFactory.addAttribute(new GAttributeInfo("UsersURI", true));
infoFactory.addAttribute(new GAttributeInfo("GroupsURI", true));
infoFactory.addOperation(new GOperationInfo("isLoginModuleLocal"));
- infoFactory.setConstructor(new GConstructorInfo(new
String[]{"RealmName", "UsersURI", "GroupsURI"},
- new
Class[]{String.class, URI.class, URI.class}));
+ infoFactory.addReference("ServerInfo", ServerInfo.class);
+ infoFactory.setConstructor(new GConstructorInfo(new
String[]{"RealmName", "UsersURI", "GroupsURI", "ServerInfo"},
+ new
Class[]{String.class, URI.class, URI.class, ServerInfo.class}));
GBEAN_INFO = infoFactory.getBeanInfo();
}
1.4 +12 -1
incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
Index: ConfigurationEntryTest.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConfigurationEntryTest.java 22 May 2004 15:25:35 -0000 1.3
+++ ConfigurationEntryTest.java 28 May 2004 22:22:40 -0000 1.4
@@ -37,6 +37,7 @@
import org.apache.geronimo.security.ContextManager;
import org.apache.geronimo.security.IdentificationPrincipal;
import org.apache.geronimo.security.RealmPrincipal;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
@@ -44,6 +45,7 @@
*/
public class ConfigurationEntryTest extends TestCase {
protected Kernel kernel;
+ protected ObjectName serverInfo;
protected ObjectName loginService;
protected ObjectName testCE;
protected ObjectName testRealm;
@@ -82,6 +84,12 @@
// Create all the parts
+ gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
+ serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
+ gbean.setAttribute("BaseDirectory", ".");
+ kernel.loadGBean(serverInfo, gbean);
+ kernel.startGBean(serverInfo);
+
gbean = new
GBeanMBean("org.apache.geronimo.security.jaas.LoginService");
loginService = new ObjectName("geronimo.security:type=LoginService");
gbean.setReferencePatterns("Realms", Collections.singleton(new
ObjectName("geronimo.security:type=SecurityRealm,*")));
@@ -104,6 +112,7 @@
gbean.setAttribute("MaxLoginModuleAge", new Long(1 * 1000));
gbean.setAttribute("UsersURI", (new File(new File("."),
"src/test-data/data/users.properties")).toURI());
gbean.setAttribute("GroupsURI", (new File(new File("."),
"src/test-data/data/groups.properties")).toURI());
+ gbean.setReferencePatterns("ServerInfo",
Collections.singleton(serverInfo));
kernel.loadGBean(testRealm, gbean);
gbean = new
GBeanMBean("org.apache.geronimo.remoting.router.SubsystemRouter");
@@ -143,6 +152,7 @@
kernel.stopGBean(testRealm);
kernel.stopGBean(testCE);
kernel.stopGBean(loginService);
+ kernel.stopGBean(serverInfo);
kernel.unloadGBean(loginService);
kernel.unloadGBean(testCE);
@@ -151,6 +161,7 @@
kernel.unloadGBean(asyncTransport);
kernel.unloadGBean(jmxRouter);
kernel.unloadGBean(serverStub);
+ kernel.unloadGBean(serverInfo);
kernel.shutdown();
1.4 +16 -2
incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
Index: LoginPropertiesFileTest.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoginPropertiesFileTest.java 10 Mar 2004 09:59:27 -0000 1.3
+++ LoginPropertiesFileTest.java 28 May 2004 22:22:40 -0000 1.4
@@ -25,6 +25,7 @@
import java.io.File;
import java.util.HashMap;
+import java.util.Collections;
import com.sun.security.auth.login.ConfigFile;
@@ -33,12 +34,14 @@
import org.apache.geronimo.security.ContextManager;
import org.apache.geronimo.security.IdentificationPrincipal;
import org.apache.geronimo.security.RealmPrincipal;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
* @version $Revision$ $Date$
*/
public class LoginPropertiesFileTest extends AbstractTest {
+ protected ObjectName serverInfo;
protected ObjectName propertiesRealm;
protected ObjectName propertiesCE;
@@ -47,12 +50,21 @@
super.setUp();
- GBeanMBean gbean = new
GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
+ GBeanMBean gbean;
+
+ gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
+ serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
+ gbean.setAttribute("BaseDirectory", ".");
+ kernel.loadGBean(serverInfo, gbean);
+ kernel.startGBean(serverInfo);
+
+ gbean = new
GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
propertiesRealm = new
ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
gbean.setAttribute("RealmName", "properties-realm");
gbean.setAttribute("MaxLoginModuleAge", new Long(1 * 1000));
gbean.setAttribute("UsersURI", (new File(new File("."),
"src/test-data/data/users.properties")).toURI());
gbean.setAttribute("GroupsURI", (new File(new File("."),
"src/test-data/data/groups.properties")).toURI());
+ gbean.setReferencePatterns("ServerInfo",
Collections.singleton(serverInfo));
kernel.loadGBean(propertiesRealm, gbean);
gbean = new
GBeanMBean("org.apache.geronimo.security.jaas.ConfigurationEntryRealmLocal");
@@ -70,8 +82,10 @@
public void tearDown() throws Exception {
kernel.stopGBean(propertiesCE);
kernel.stopGBean(propertiesRealm);
+ kernel.stopGBean(serverInfo);
kernel.unloadGBean(propertiesRealm);
kernel.unloadGBean(propertiesCE);
+ kernel.unloadGBean(serverInfo);
super.tearDown();
1.8 +16 -2
incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java
Index: SubjectCarryingProtocolTest.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SubjectCarryingProtocolTest.java 3 Apr 2004 22:59:43 -0000 1.7
+++ SubjectCarryingProtocolTest.java 28 May 2004 22:22:40 -0000 1.8
@@ -31,6 +31,7 @@
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Collections;
import EDU.oswego.cs.dl.util.concurrent.Latch;
import com.sun.security.auth.login.ConfigFile;
@@ -54,6 +55,7 @@
import org.apache.geronimo.security.jaas.GeronimoLoginConfiguration;
import org.apache.geronimo.system.ClockPool;
import org.apache.geronimo.system.ThreadPool;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
@@ -63,6 +65,7 @@
final static private Log log =
LogFactory.getLog(SubjectCarryingProtocolTest.class);
+ protected ObjectName serverInfo;
protected ObjectName propertiesRealm;
protected ObjectName propertiesCE;
@@ -268,12 +271,21 @@
super.setUp();
- GBeanMBean gbean = new
GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
+ GBeanMBean gbean;
+
+ gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
+ serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
+ gbean.setAttribute("BaseDirectory", ".");
+ kernel.loadGBean(serverInfo, gbean);
+ kernel.startGBean(serverInfo);
+
+ gbean = new
GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
propertiesRealm = new
ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
gbean.setAttribute("RealmName", "properties-realm");
gbean.setAttribute("MaxLoginModuleAge", new Long(1 * 1000));
gbean.setAttribute("UsersURI", (new File(new File("."),
"src/test-data/data/users.properties")).toURI());
gbean.setAttribute("GroupsURI", (new File(new File("."),
"src/test-data/data/groups.properties")).toURI());
+ gbean.setReferencePatterns("ServerInfo",
Collections.singleton(serverInfo));
kernel.loadGBean(propertiesRealm, gbean);
gbean = new
GBeanMBean("org.apache.geronimo.security.jaas.ConfigurationEntryRealmLocal");
@@ -301,8 +313,10 @@
public void tearDown() throws Exception {
kernel.stopGBean(propertiesCE);
kernel.stopGBean(propertiesRealm);
+ kernel.stopGBean(serverInfo);
kernel.unloadGBean(propertiesRealm);
kernel.unloadGBean(propertiesCE);
+ kernel.unloadGBean(serverInfo);
super.tearDown();
1.7 +12 -1
incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java
Index: RemoteLoginTest.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RemoteLoginTest.java 22 May 2004 15:25:35 -0000 1.6
+++ RemoteLoginTest.java 28 May 2004 22:22:41 -0000 1.7
@@ -40,6 +40,7 @@
import org.apache.geronimo.security.IdentificationPrincipal;
import org.apache.geronimo.security.RealmPrincipal;
import org.apache.geronimo.security.jaas.LoginServiceMBean;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
@@ -47,6 +48,7 @@
*/
public class RemoteLoginTest extends TestCase {
Kernel kernel;
+ ObjectName serverInfo;
ObjectName loginService;
ObjectName kerberosRealm;
ObjectName subsystemRouter;
@@ -86,6 +88,12 @@
// Create all the parts
+ gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
+ serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
+ gbean.setAttribute("BaseDirectory", ".");
+ kernel.loadGBean(serverInfo, gbean);
+ kernel.startGBean(serverInfo);
+
gbean = new
GBeanMBean("org.apache.geronimo.security.jaas.LoginService");
loginService = new ObjectName("geronimo.security:type=LoginService");
gbean.setReferencePatterns("Realms", Collections.singleton(new
ObjectName("geronimo.security:type=SecurityRealm,*")));
@@ -100,6 +108,7 @@
gbean.setAttribute("MaxLoginModuleAge", new Long(1 * 1000));
gbean.setAttribute("UsersURI", (new File(new File("."),
"src/test-data/data/users.properties")).toURI());
gbean.setAttribute("GroupsURI", (new File(new File("."),
"src/test-data/data/groups.properties")).toURI());
+ gbean.setReferencePatterns("ServerInfo",
Collections.singleton(serverInfo));
kernel.loadGBean(kerberosRealm, gbean);
gbean = new
GBeanMBean("org.apache.geronimo.remoting.router.SubsystemRouter");
@@ -178,6 +187,7 @@
kernel.stopGBean(subsystemRouter);
kernel.stopGBean(kerberosRealm);
kernel.stopGBean(loginService);
+ kernel.stopGBean(serverInfo);
kernel.unloadGBean(loginService);
kernel.unloadGBean(kerberosRealm);
@@ -189,6 +199,7 @@
kernel.unloadGBean(jmxRouter);
kernel.unloadGBean(secureJmxRouter);
kernel.unloadGBean(serverStub);
+ kernel.unloadGBean(serverInfo);
kernel.shutdown();
}