[jboss-cvs] JBossAS SVN: r92041 - projects/security/security-jboss-sx/branches/Branch_2_0/jbosssx/src/test/java/org/jboss/test/authentication/jaas.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 5 18:44:41 EDT 2009
Author: anil.saldhana at jboss.com
Date: 2009-08-05 18:44:41 -0400 (Wed, 05 Aug 2009)
New Revision: 92041
Modified:
projects/security/security-jboss-sx/branches/Branch_2_0/jbosssx/src/test/java/org/jboss/test/authentication/jaas/ClientLoginModuleUnitTestCase.java
Log:
SECURITY-339: Clientloginmodule should not pop the security context on abort - just any principal information
Modified: projects/security/security-jboss-sx/branches/Branch_2_0/jbosssx/src/test/java/org/jboss/test/authentication/jaas/ClientLoginModuleUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/branches/Branch_2_0/jbosssx/src/test/java/org/jboss/test/authentication/jaas/ClientLoginModuleUnitTestCase.java 2009-08-05 22:40:24 UTC (rev 92040)
+++ projects/security/security-jboss-sx/branches/Branch_2_0/jbosssx/src/test/java/org/jboss/test/authentication/jaas/ClientLoginModuleUnitTestCase.java 2009-08-05 22:44:41 UTC (rev 92041)
@@ -30,6 +30,7 @@
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -40,6 +41,7 @@
import org.jboss.security.SecurityContextAssociation;
import org.jboss.security.SecurityContextFactory;
import org.jboss.security.SimplePrincipal;
+import org.jboss.security.SubjectInfo;
import org.jboss.security.auth.callback.UsernamePasswordHandler;
/**
@@ -139,15 +141,24 @@
return entry;
}
+ @SuppressWarnings("unchecked")
AppConfigurationEntry[] testAbort()
{
- String name = "org.jboss.security.ClientLoginModule";
+ String name1 = "org.jboss.security.auth.spi.SimpleServerLoginModule";
+ AppConfigurationEntry ace1 = new AppConfigurationEntry(name1,
+ AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, new HashMap());
+
+
+ String name2 = "org.jboss.security.ClientLoginModule";
HashMap<String,String> options = new HashMap<String,String>();
options.put("multi-threaded", "true");
- AppConfigurationEntry ace = new AppConfigurationEntry(name,
+
+
+ AppConfigurationEntry ace2 = new AppConfigurationEntry(name2,
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
- AppConfigurationEntry[] entry = {ace};
- return entry;
+
+ AppConfigurationEntry[] entry = {ace1,ace2};
+ return entry;
}
}
@@ -161,6 +172,7 @@
suite.addTest(new ClientLoginModuleUnitTestCase("testMultiThreaded"));
suite.addTest(new ClientLoginModuleUnitTestCase("testMultiThreadedRestoreIdentity"));
suite.addTest(new ClientLoginModuleUnitTestCase("testMultiThreadedRestoreStack"));
+ suite.addTest(new ClientLoginModuleUnitTestCase("testAbort"));
return suite;
}
@@ -471,22 +483,38 @@
//Failed Login
UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke3", "BAD_PASSWORD");
LoginContext lc = new LoginContext("testAbort", handler);
- lc.login();
+ try
+ {
+ lc.login();
+ fail("Should have failed");
+ }
+ catch(LoginException le)
+ {
+ //pass
+ }
Subject subject = lc.getSubject();
- assertNotNull("Subject is not null", subject);
+ assertNull("Subject is null", subject);
- assertTrue(SecurityContextAssociation.getSecurityContext() == null);
+ SecurityContext currentSC = SecurityContextAssociation.getSecurityContext();
+ assertNotNull("Current Security Context is not null", currentSC);
+ SubjectInfo subjectInfo = currentSC.getSubjectInfo();
+ assertNotNull("SubjectInfo", subjectInfo);
+ assertNull("Subject is null", subjectInfo.getAuthenticatedSubject());
//Successful Login
SecurityContextAssociation.setSecurityContext(sc);
- handler = new UsernamePasswordHandler("jduke3", "theduke3");
+ handler = new UsernamePasswordHandler("jduke3", "jduke3");
lc = new LoginContext("testAbort", handler);
lc.login();
subject = lc.getSubject();
assertNotNull("Subject is not null", subject);
- assertTrue(SecurityContextAssociation.getSecurityContext() != null);
+ currentSC = SecurityContextAssociation.getSecurityContext();
+ assertNotNull("Current Security Context is not null", currentSC);
+ subjectInfo = currentSC.getSubjectInfo();
+ assertNotNull("SubjectInfo", subjectInfo);
+ assertNotNull("Subject is not null", subjectInfo.getAuthenticatedSubject());
}
}
More information about the jboss-cvs-commits
mailing list