geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r105957 - in geronimo/trunk/modules/security/src: java/org/apache/geronimo/security/jaas test/org/apache/geronimo/security/jaas
Date Sat, 20 Nov 2004 09:13:13 GMT
Author: ammulder
Date: Sat Nov 20 01:13:11 2004
New Revision: 105957

Modified:
   geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
   geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
Log:
Fix automatic coordinator mapping and add a test for it


Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java
Sat Nov 20 01:13:11 2004
@@ -46,7 +46,7 @@
 
     private static Map entries = new Hashtable();
     private Configuration oldConfiguration;
-    private Kernel kernel;
+    private static Kernel kernel; //todo: this restricts you to one Kernel per JVM
 
     public GeronimoLoginConfiguration(Kernel kernel) {
         this.kernel = kernel;
@@ -92,7 +92,13 @@
         if (sm != null) sm.checkPermission(SecurityService.CONFIGURE);
 
         if (entries.containsKey(realm.getRealmName())) throw new java.lang.IllegalArgumentException("ConfigurationEntry
already registered");
-        entries.put(realm.getRealmName(), new AppConfigurationEntry("org.apache.geronimo.security.jaas.JaasLoginCoordinator",
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, new Properties()));
+        Map options = new HashMap();
+        options.put("realm", realm.getRealmName());
+        if(kernel != null) {
+            options.put("kernel", kernel.getKernelName());
+        }
+
+        entries.put(realm.getRealmName(), new AppConfigurationEntry("org.apache.geronimo.security.jaas.JaasLoginCoordinator",
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options));
     }
 
     public static void unRegister(String name) {

Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
(original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
Sat Nov 20 01:13:11 2004
@@ -55,6 +55,7 @@
     protected ObjectName serverStub;
 
     public void test() throws Exception {
+        // First try with explicit configuration entry
         LoginContext context = new LoginContext("properties-client", new AbstractTest.UsernamePasswordCallback("alan",
"starcraft"));
 
         context.login();
@@ -72,6 +73,27 @@
         assertTrue("server subject should have two realm principals ("+subject.getPrincipals(RealmPrincipal.class).size()+")",
subject.getPrincipals(RealmPrincipal.class).size() == 2);
         assertTrue("server subject should have five principals ("+subject.getPrincipals().size()+")",
subject.getPrincipals().size() == 5);
         RealmPrincipal principal = (RealmPrincipal) subject.getPrincipals(RealmPrincipal.class).iterator().next();
+        assertTrue("id of principal should be non-zero", principal.getId() != 0);
+
+        context.logout();
+
+        assertTrue("id of subject should be null", ContextManager.getSubjectId(subject) ==
null);
+
+        // next try the automatic configuration entry
+        context = new LoginContext("properties-realm", new AbstractTest.UsernamePasswordCallback("alan",
"starcraft"));
+
+        context.login();
+        subject = context.getSubject();
+        assertTrue("expected non-null client subject", subject != null);
+        subject = ContextManager.getServerSideSubject(subject);
+
+        assertTrue("expected non-null server subject", subject != null);
+        assertTrue("server subject should have one remote principal", subject.getPrincipals(IdentificationPrincipal.class).size()
== 1);
+        remote = (IdentificationPrincipal) subject.getPrincipals(IdentificationPrincipal.class).iterator().next();
+        assertTrue("server subject should be associated with remote id", ContextManager.getRegisteredSubject(remote.getId())
!= null);
+        assertTrue("server subject should have two realm principals ("+subject.getPrincipals(RealmPrincipal.class).size()+")",
subject.getPrincipals(RealmPrincipal.class).size() == 2);
+        assertTrue("server subject should have five principals ("+subject.getPrincipals().size()+")",
subject.getPrincipals().size() == 5);
+        principal = (RealmPrincipal) subject.getPrincipals(RealmPrincipal.class).iterator().next();
         assertTrue("id of principal should be non-zero", principal.getId() != 0);
 
         context.logout();

Mime
View raw message