geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r592227 - in /geronimo/server/trunk/framework/modules/geronimo-security/src: main/java/org/apache/geronimo/security/jaas/ test/java/org/apache/geronimo/security/jaas/
Date Tue, 06 Nov 2007 02:36:11 GMT
Author: djencks
Date: Mon Nov  5 18:36:10 2007
New Revision: 592227

URL: http://svn.apache.org/viewvc?rev=592227&view=rev
Log:
GERONIMO-3570 GERONIMO-3571 GERONIMO-3575 Check that logout removes all principals added in
login. Fix the wrapping login module to do this also.

Modified:
    geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/WrappingLoginModule.java
    geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginCertificatePropertiesFileTest.java
    geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
    geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginSQLTest.java

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/WrappingLoginModule.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/WrappingLoginModule.java?rev=592227&r1=592226&r2=592227&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/WrappingLoginModule.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaas/WrappingLoginModule.java
Mon Nov  5 18:36:10 2007
@@ -50,6 +50,7 @@
     private Subject subject;
     private LoginModule delegate;
 
+
     public WrappingLoginModule() {
     }
 
@@ -90,9 +91,9 @@
     }
 
     public boolean logout() throws LoginException {
-        boolean result = delegate.logout();
-
         subject.getPrincipals().removeAll(localSubject.getPrincipals());
+        boolean result = delegate.logout();
+                                             
         localSubject.getPrincipals().clear();
 
         return result;

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginCertificatePropertiesFileTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginCertificatePropertiesFileTest.java?rev=592227&r1=592226&r2=592227&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginCertificatePropertiesFileTest.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginCertificatePropertiesFileTest.java
Mon Nov  5 18:36:10 2007
@@ -18,7 +18,6 @@
 package org.apache.geronimo.security.jaas;
 
 import java.io.ByteArrayInputStream;
-import java.io.File;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import java.util.HashMap;
@@ -27,16 +26,13 @@
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
-import javax.management.MalformedObjectNameException;
 
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.security.AbstractTest;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.DomainPrincipal;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
-import org.apache.geronimo.security.realm.GenericSecurityRealm;
 
 
 /**
@@ -71,50 +67,6 @@
                         +"PjUnrEF1laqhX4Rx+2u56VBA2SBnEaeADawaXWkD\n"
                         +"-----END CERTIFICATE-----";
 
-/*
-    public void setUp() throws Exception {
-        needServerInfo = true;
-        needLoginConfiguration = true;
-        super.setUp();
-
-        GBeanData gbean;
-
-        gbean = buildGBeanData("name", "CertificatePropertiesLoginModule", LoginModuleGBean.getGBeanInfo());
-        testCE = gbean.getAbstractName();
-        gbean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.CertificatePropertiesFileLoginModule");
-        Map<String, Object> props = new HashMap<String, Object>();
-        props.put("usersURI", new File(BASEDIR, "src/test/data/data/cert-users.properties").toURI().toString());
-        props.put("groupsURI", new File(BASEDIR, "src/test/data/data/groups.properties").toURI().toString());
-        gbean.setAttribute("options", props);
-        gbean.setAttribute("loginDomainName", "CertProperties");
-        gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
-        kernel.loadGBean(gbean, LoginModuleGBean.class.getClassLoader());
-
-        gbean = buildGBeanData("name", "CertificatePropertiesLoginModuleUse", JaasLoginModuleUse.getGBeanInfo());
-        AbstractName testUseName = gbean.getAbstractName();
-        gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
-        gbean.setReferencePattern("LoginModule", testCE);
-        kernel.loadGBean(gbean, JaasLoginModuleUse.class.getClassLoader());
-
-        gbean = buildGBeanData("name", "CertificatePropertiesSecurityRealm", GenericSecurityRealm.getGBeanInfo());
-        testRealm = gbean.getAbstractName();
-        gbean.setAttribute("realmName", "cert-properties-realm");
-        gbean.setAttribute("wrapPrincipals", Boolean.TRUE);
-        gbean.setReferencePattern("LoginModuleConfiguration", testUseName);
-        gbean.setReferencePattern("ServerInfo", serverInfo);
-        kernel.loadGBean(gbean, GenericSecurityRealm.class.getClassLoader());
-
-        kernel.startGBean(loginConfiguration);
-        kernel.startGBean(testCE);
-        kernel.startGBean(testUseName);
-        kernel.startGBean(testRealm);
-        
-        CertificateFactory certFac = CertificateFactory.getInstance("X.509");
-        cert = (X509Certificate) certFac.generateCertificate(new ByteArrayInputStream(certText.getBytes()));
-        badCert = (X509Certificate) certFac.generateCertificate(new ByteArrayInputStream(badCertText.getBytes()));
-    }
-*/
-
     protected GBeanData setupTestLoginModule() throws Exception {
         CertificateFactory certFac = CertificateFactory.getInstance("X.509");
         cert = (X509Certificate) certFac.generateCertificate(new ByteArrayInputStream(certText.getBytes()));
@@ -146,6 +98,7 @@
         assertEquals("subject should have 3 domain principals (" + subject.getPrincipals(DomainPrincipal.class).size()
+ ")", 3, subject.getPrincipals(DomainPrincipal.class).size());
 
         context.logout();
+        assertEquals("subject should have no principals (" + subject.getPrincipals().size()
+ ")", 0, subject.getPrincipals().size());
 
         assertTrue("id of server subject should be null", ContextManager.getSubjectId(subject)
== null);
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java?rev=592227&r1=592226&r2=592227&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginPropertiesFileTest.java
Mon Nov  5 18:36:10 2007
@@ -68,7 +68,8 @@
         assertEquals("subject should have 2 domain principals (" + subject.getPrincipals(DomainPrincipal.class).size()
+ ")", 2, subject.getPrincipals(DomainPrincipal.class).size());
 
         context.logout();
-
+        assertEquals("subject should have no principals (" + subject.getPrincipals().size()
+ ")", 0, subject.getPrincipals().size());
+ 
         assertTrue("id of server subject should be null", ContextManager.getSubjectId(subject)
== null);
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginSQLTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginSQLTest.java?rev=592227&r1=592226&r2=592227&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginSQLTest.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-security/src/test/java/org/apache/geronimo/security/jaas/LoginSQLTest.java
Mon Nov  5 18:36:10 2007
@@ -119,6 +119,7 @@
         assertEquals("server-side subject should have two domain principals", 2, subject.getPrincipals(DomainPrincipal.class).size());
 
         context.logout();
+        assertEquals("subject should have no principals (" + subject.getPrincipals().size()
+ ")", 0, subject.getPrincipals().size());
     }
 
     public void testNullUserLogin() throws Exception {



Mime
View raw message