geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: rev 45907 - in geronimo/trunk/modules/security/src: java/org/apache/geronimo/security/realm/providers test/org/apache/geronimo/security/jaas
Date Sat, 11 Sep 2004 18:45:52 GMT
Author: adc
Date: Sat Sep 11 11:45:51 2004
New Revision: 45907

Modified:
   geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SimpleSecurityRealm.java
   geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSimpleRealmTest.java
Log:
Added the ability to pass in a set of options to the LoginModule.

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SimpleSecurityRealm.java
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SimpleSecurityRealm.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SimpleSecurityRealm.java
Sat Sep 11 11:45:51 2004
@@ -17,7 +17,7 @@
 package org.apache.geronimo.security.realm.providers;
 
 import javax.security.auth.login.AppConfigurationEntry;
-import java.util.HashMap;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -38,6 +38,7 @@
 
     private boolean running = false;
     private String loginModuleName;
+    private Properties options;
 
 
     public SimpleSecurityRealm(String realmName) {
@@ -52,6 +53,14 @@
         this.loginModuleName = loginModuleName;
     }
 
+    public Properties getOptions() {
+        return options;
+    }
+
+    public void setOptions(Properties options) {
+        this.options = options;
+    }
+
     public void doStart() {
         refresh();
         running = true;
@@ -104,7 +113,6 @@
     }
 
     public javax.security.auth.login.AppConfigurationEntry getAppConfigurationEntry() {
-        HashMap options = new HashMap();
 
         AppConfigurationEntry entry = new AppConfigurationEntry(loginModuleName,
                                                                 AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT,
@@ -123,6 +131,7 @@
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(SimpleSecurityRealm.class, AbstractSecurityRealm.GBEAN_INFO);
 
         infoFactory.addAttribute("loginModuleName", String.class, true);
+        infoFactory.addAttribute("options", Properties.class, true);
 
         infoFactory.addOperation("isLoginModuleLocal");
 

Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSimpleRealmTest.java
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSimpleRealmTest.java
(original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/LoginSimpleRealmTest.java
Sat Sep 11 11:45:51 2004
@@ -28,9 +28,9 @@
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
 import java.io.IOException;
+import java.security.Principal;
 import java.util.Map;
 import java.util.Properties;
-import java.security.Principal;
 
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.security.AbstractTest;
@@ -65,10 +65,14 @@
         loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
         kernel.loadGBean(loginConfiguration, gbean);
 
+        Properties options = new Properties();
+        options.put("group", "it");
+
         gbean = new GBeanMBean("org.apache.geronimo.security.realm.providers.SimpleSecurityRealm");
         simpleRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=simple-realm");
         gbean.setAttribute("realmName", "simple-realm");
         gbean.setAttribute("loginModuleName", TestLoginModule.class.getName());
+        gbean.setAttribute("options", options);
         gbean.setAttribute("maxLoginModuleAge", new Long(24 * 60 * 60 * 1000));
         kernel.loadGBean(simpleRealm, gbean);
 
@@ -162,9 +166,12 @@
         public void initialize(Subject subject, CallbackHandler handler, Map sharedState,
Map options) {
             this.subject = subject;
             this.handler = handler;
+
+            if (!options.get("group").equals("it")) throw new IllegalArgumentException("Missing
group option");
         }
 
         public class TestPrincipal implements Principal {
+
             private final String name;
 
             public TestPrincipal(String name) {
@@ -177,6 +184,7 @@
         }
 
         public class TestGroupPrincipal implements Principal {
+
             private final String name;
 
             public TestGroupPrincipal(String name) {

Mime
View raw message