Make samples and tests use username "rod".

This commit is contained in:
Ben Alex 2007-12-03 02:56:52 +00:00
parent 3123d24337
commit 47229be5cb
68 changed files with 397 additions and 397 deletions

View File

@ -27,7 +27,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLES_IGNORED_BY_CAS rod=koala,ROLES_IGNORED_BY_CAS
dianne=emu,ROLES_IGNORED_BY_CAS dianne=emu,ROLES_IGNORED_BY_CAS
scott=wombat,ROLES_IGNORED_BY_CAS scott=wombat,ROLES_IGNORED_BY_CAS
peter=opal,disabled,ROLES_IGNORED_BY_CAS peter=opal,disabled,ROLES_IGNORED_BY_CAS

View File

@ -30,7 +30,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLES_IGNORED_BY_CAS rod=koala,ROLES_IGNORED_BY_CAS
dianne=emu,ROLES_IGNORED_BY_CAS dianne=emu,ROLES_IGNORED_BY_CAS
scott=wombat,ROLES_IGNORED_BY_CAS scott=wombat,ROLES_IGNORED_BY_CAS
peter=opal,disabled,ROLES_IGNORED_BY_CAS peter=opal,disabled,ROLES_IGNORED_BY_CAS

View File

@ -79,8 +79,8 @@ public class CasPasswordHandlerProxyTests extends TestCase {
public void testNormalOperation() { public void testNormalOperation() {
CasPasswordHandlerProxy proxy = new MockCasPasswordHandlerProxy( CasPasswordHandlerProxy proxy = new MockCasPasswordHandlerProxy(
"org/springframework/security/adapters/cas/applicationContext-valid.xml"); "org/springframework/security/adapters/cas/applicationContext-valid.xml");
assertTrue(proxy.authenticate(new MockHttpServletRequest(), "marissa", "koala")); assertTrue(proxy.authenticate(new MockHttpServletRequest(), "rod", "koala"));
assertFalse(proxy.authenticate(new MockHttpServletRequest(), "marissa", "WRONG_PASSWORD")); assertFalse(proxy.authenticate(new MockHttpServletRequest(), "rod", "WRONG_PASSWORD"));
assertFalse(proxy.authenticate(new MockHttpServletRequest(), "INVALID_USER_NAME", "WRONG_PASSWORD")); assertFalse(proxy.authenticate(new MockHttpServletRequest(), "INVALID_USER_NAME", "WRONG_PASSWORD"));
} }

View File

@ -23,7 +23,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -23,7 +23,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -175,7 +175,7 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
public void testAuthenticationFailsForIncorrectPassword() public void testAuthenticationFailsForIncorrectPassword()
throws Exception { throws Exception {
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml"); CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
assertEquals(null, adapter.authenticate("marissa", "kangaroo")); assertEquals(null, adapter.authenticate("rod", "kangaroo"));
} }
public void testAuthenticationFailsForIncorrectUserName() public void testAuthenticationFailsForIncorrectUserName()
@ -188,14 +188,14 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
throws Exception { throws Exception {
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml"); CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
byte[] credentials = {'k', 'o', 'a', 'l', 'a'}; byte[] credentials = {'k', 'o', 'a', 'l', 'a'};
Principal result = adapter.authenticate("marissa", credentials); Principal result = adapter.authenticate("rod", credentials);
if (!(result instanceof PrincipalSpringSecurityUserToken)) { if (!(result instanceof PrincipalSpringSecurityUserToken)) {
fail("Should have returned PrincipalSpringSecurityUserToken"); fail("Should have returned PrincipalSpringSecurityUserToken");
} }
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -205,14 +205,14 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
public void testAuthenticationUsingStringForCredentials() public void testAuthenticationUsingStringForCredentials()
throws Exception { throws Exception {
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml"); CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
Principal result = adapter.authenticate("marissa", "koala"); Principal result = adapter.authenticate("rod", "koala");
if (!(result instanceof PrincipalSpringSecurityUserToken)) { if (!(result instanceof PrincipalSpringSecurityUserToken)) {
fail("Should have returned PrincipalSpringSecurityUserToken"); fail("Should have returned PrincipalSpringSecurityUserToken");
} }
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -222,7 +222,7 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
public void testAuthenticationWithNullPasswordHandledGracefully() public void testAuthenticationWithNullPasswordHandledGracefully()
throws Exception { throws Exception {
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml"); CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
assertEquals(null, adapter.authenticate("marissa", (String) null)); assertEquals(null, adapter.authenticate("rod", (String) null));
} }
public void testAuthenticationWithNullUserNameHandledGracefully() public void testAuthenticationWithNullUserNameHandledGracefully()

View File

@ -187,7 +187,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml"); props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
Subject subject = new Subject(); Subject subject = new Subject();
CallbackHandler callback = new MockCallbackHandler("marissa", "kangaroo"); CallbackHandler callback = new MockCallbackHandler("rod", "kangaroo");
adapter.initialize(subject, callback, null, props); adapter.initialize(subject, callback, null, props);
@ -226,7 +226,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml"); props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
Subject subject = new Subject(); Subject subject = new Subject();
CallbackHandler callback = new MockCallbackHandler("marissa", "koala"); CallbackHandler callback = new MockCallbackHandler("rod", "koala");
adapter.initialize(subject, callback, null, props); adapter.initialize(subject, callback, null, props);
assertTrue(adapter.login()); assertTrue(adapter.login());
@ -238,7 +238,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
} }
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -253,7 +253,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml"); props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
Subject subject = new Subject(); Subject subject = new Subject();
CallbackHandler callback = new MockCallbackHandler("marissa", null); CallbackHandler callback = new MockCallbackHandler("rod", null);
adapter.initialize(subject, callback, null, props); adapter.initialize(subject, callback, null, props);
@ -312,7 +312,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml"); props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
Subject subject = new Subject(); Subject subject = new Subject();
CallbackHandler callback = new MockCallbackHandler("marissa", "koala"); CallbackHandler callback = new MockCallbackHandler("rod", "koala");
adapter.initialize(subject, callback, null, props); adapter.initialize(subject, callback, null, props);
assertTrue(adapter.login()); assertTrue(adapter.login());

View File

@ -144,7 +144,7 @@ public class JettyAcegiUserRealmTests extends TestCase {
public void testAuthenticationFailsForIncorrectPassword() public void testAuthenticationFailsForIncorrectPassword()
throws Exception { throws Exception {
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml"); JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
assertEquals(null, adapter.authenticate("marissa", "kangaroo", null)); assertEquals(null, adapter.authenticate("rod", "kangaroo", null));
} }
public void testAuthenticationFailsForIncorrectUserName() public void testAuthenticationFailsForIncorrectUserName()
@ -155,14 +155,14 @@ public class JettyAcegiUserRealmTests extends TestCase {
public void testAuthenticationSuccess() throws Exception { public void testAuthenticationSuccess() throws Exception {
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml"); JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
UserPrincipal result = adapter.authenticate("marissa", "koala", null); UserPrincipal result = adapter.authenticate("rod", "koala", null);
if (!(result instanceof JettySpringSecurityUserToken)) { if (!(result instanceof JettySpringSecurityUserToken)) {
fail("Should have returned JettySpringSecurityUserToken"); fail("Should have returned JettySpringSecurityUserToken");
} }
JettySpringSecurityUserToken castResult = (JettySpringSecurityUserToken) result; JettySpringSecurityUserToken castResult = (JettySpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -172,7 +172,7 @@ public class JettyAcegiUserRealmTests extends TestCase {
public void testAuthenticationWithNullPasswordHandledGracefully() public void testAuthenticationWithNullPasswordHandledGracefully()
throws Exception { throws Exception {
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml"); JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
assertEquals(null, adapter.authenticate("marissa", null, null)); assertEquals(null, adapter.authenticate("rod", null, null));
} }
public void testAuthenticationWithNullUserNameHandledGracefully() public void testAuthenticationWithNullUserNameHandledGracefully()

View File

@ -144,7 +144,7 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml");
adapter.setKey(ADAPTER_KEY); adapter.setKey(ADAPTER_KEY);
adapter.init(); adapter.init();
assertEquals(null, adapter.loginImpl("marissa", "kangaroo")); assertEquals(null, adapter.loginImpl("rod", "kangaroo"));
} }
public void testAuthenticationFailsForIncorrectUserName() public void testAuthenticationFailsForIncorrectUserName()
@ -162,14 +162,14 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
adapter.setKey(ADAPTER_KEY); adapter.setKey(ADAPTER_KEY);
adapter.init(); adapter.init();
Principal result = adapter.loginImpl("marissa", "koala"); Principal result = adapter.loginImpl("rod", "koala");
if (!(result instanceof PrincipalSpringSecurityUserToken)) { if (!(result instanceof PrincipalSpringSecurityUserToken)) {
fail("Should have returned PrincipalSpringSecurityUserToken"); fail("Should have returned PrincipalSpringSecurityUserToken");
} }
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -183,14 +183,14 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
adapter.setKey(ADAPTER_KEY); adapter.setKey(ADAPTER_KEY);
adapter.init(); adapter.init();
Principal result = adapter.loginImpl(null, null, null, "marissa", "koala"); Principal result = adapter.loginImpl(null, null, null, "rod", "koala");
if (!(result instanceof PrincipalSpringSecurityUserToken)) { if (!(result instanceof PrincipalSpringSecurityUserToken)) {
fail("Should have returned PrincipalSpringSecurityUserToken"); fail("Should have returned PrincipalSpringSecurityUserToken");
} }
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
assertEquals("koala", castResult.getCredentials()); assertEquals("koala", castResult.getCredentials());
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority()); assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority()); assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
@ -203,7 +203,7 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml");
adapter.setKey(ADAPTER_KEY); adapter.setKey(ADAPTER_KEY);
adapter.init(); adapter.init();
assertEquals(null, adapter.loginImpl("marissa", null)); assertEquals(null, adapter.loginImpl("rod", null));
} }
public void testAuthenticationWithNullUserNameHandledGracefully() public void testAuthenticationWithNullUserNameHandledGracefully()

View File

@ -40,7 +40,7 @@ import java.util.Set;
* (or <tt>groupOfUniqueNames</tt>) LDAP objectClass and the user's DN is listed in the <tt>member</tt> (or * (or <tt>groupOfUniqueNames</tt>) LDAP objectClass and the user's DN is listed in the <tt>member</tt> (or
* <tt>uniqueMember</tt>) attribute to indicate that they should be assigned that role. The following LDIF sample has * <tt>uniqueMember</tt>) attribute to indicate that they should be assigned that role. The following LDIF sample has
* the groups stored under the DN <tt>ou=groups,dc=springframework,dc=org</tt> and a group called "developers" with * the groups stored under the DN <tt>ou=groups,dc=springframework,dc=org</tt> and a group called "developers" with
* "ben" and "marissa" as members: * "ben" and "luke" as members:
* <pre> * <pre>
* dn: ou=groups,dc=springframework,dc=org * dn: ou=groups,dc=springframework,dc=org
* objectClass: top * objectClass: top
@ -53,7 +53,7 @@ import java.util.Set;
* cn: developers * cn: developers
* description: Spring Security Developers * description: Spring Security Developers
* member: uid=ben,ou=people,dc=springframework,dc=org * member: uid=ben,ou=people,dc=springframework,dc=org
* member: uid=marissa,ou=people,dc=springframework,dc=org * member: uid=luke,ou=people,dc=springframework,dc=org
* ou: developer * ou: developer
* </pre> * </pre>
* </p> * </p>

View File

@ -27,6 +27,6 @@ CREATE TABLE acl_permission (
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'marissa', 2); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'rod', 2);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1);

View File

@ -25,6 +25,6 @@ CREATE TABLE acl_permission (
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'marissa', 2); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'rod', 2);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1);

View File

@ -25,6 +25,6 @@ CREATE TABLE acl_permission (
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'marissa', 2); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'rod', 2);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1);

View File

@ -29,6 +29,6 @@ CREATE TABLE acl_permission (
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (1, 'ROLE_ADMIN', 1);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'ROLE_ADMIN', 0);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'marissa', 2); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (2, 'rod', 2);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (3, 'scott', 14);
--INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1); --INSERT INTO acl_permission (acl_object_identity, recipient, mask) VALUES (6, 'scott', 1);

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -66,12 +66,12 @@ public class PopulatedDatabase {
"CREATE TABLE ACL_PERMISSION(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY BIGINT NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))"); "CREATE TABLE ACL_PERMISSION(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY BIGINT NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
template.execute("SET IGNORECASE TRUE"); template.execute("SET IGNORECASE TRUE");
template.execute("INSERT INTO USERS VALUES('dianne','emu',TRUE)"); template.execute("INSERT INTO USERS VALUES('dianne','emu',TRUE)");
template.execute("INSERT INTO USERS VALUES('marissa','koala',TRUE)"); template.execute("INSERT INTO USERS VALUES('rod','koala',TRUE)");
template.execute("INSERT INTO USERS VALUES('peter','opal',FALSE)"); template.execute("INSERT INTO USERS VALUES('peter','opal',FALSE)");
template.execute("INSERT INTO USERS VALUES('scott','wombat',TRUE)"); template.execute("INSERT INTO USERS VALUES('scott','wombat',TRUE)");
template.execute("INSERT INTO USERS VALUES('cooper','kookaburra',TRUE)"); template.execute("INSERT INTO USERS VALUES('cooper','kookaburra',TRUE)");
template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_TELLER')"); template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_TELLER')");
template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR')"); template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR')");
template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_TELLER')"); template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_TELLER')");
template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_TELLER')"); template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_TELLER')");
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_TELLER')"); template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_TELLER')");
@ -95,7 +95,7 @@ public class PopulatedDatabase {
// ----- FINISH deviation from normal sample data load script ----- // ----- FINISH deviation from normal sample data load script -----
template.execute("INSERT INTO acl_permission VALUES (null, 1, 'ROLE_SUPERVISOR', 1);"); template.execute("INSERT INTO acl_permission VALUES (null, 1, 'ROLE_SUPERVISOR', 1);");
template.execute("INSERT INTO acl_permission VALUES (null, 2, 'ROLE_SUPERVISOR', 0);"); template.execute("INSERT INTO acl_permission VALUES (null, 2, 'ROLE_SUPERVISOR', 0);");
template.execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); template.execute("INSERT INTO acl_permission VALUES (null, 2, 'rod', 2);");
template.execute("INSERT INTO acl_permission VALUES (null, 3, 'scott', 14);"); template.execute("INSERT INTO acl_permission VALUES (null, 3, 'scott', 14);");
template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 1);"); template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 1);");

View File

@ -75,7 +75,7 @@ public class AclProviderManagerTests extends TestCase {
public void testAclLookupForGivenAuthenticationSuccess() { public void testAclLookupForGivenAuthenticationSuccess() {
AclProviderManager mgr = makeProviderManager(); AclProviderManager mgr = makeProviderManager();
assertNotNull(mgr.getAcls("STRING", new UsernamePasswordAuthenticationToken("marissa", "not used"))); assertNotNull(mgr.getAcls("STRING", new UsernamePasswordAuthenticationToken("rod", "not used")));
} }
public void testAclLookupSuccess() { public void testAclLookupSuccess() {
@ -94,7 +94,7 @@ public class AclProviderManagerTests extends TestCase {
} }
try { try {
mgr.getAcls(null, new UsernamePasswordAuthenticationToken("marissa", "not used")); mgr.getAcls(null, new UsernamePasswordAuthenticationToken("rod", "not used"));
fail("Should have thrown IllegalArgumentException"); fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
assertTrue(true); assertTrue(true);
@ -110,7 +110,7 @@ public class AclProviderManagerTests extends TestCase {
public void testReturnsNullIfNoSupportingProvider() { public void testReturnsNullIfNoSupportingProvider() {
AclProviderManager mgr = makeProviderManager(); AclProviderManager mgr = makeProviderManager();
assertNull(mgr.getAcls(new Integer(4), new UsernamePasswordAuthenticationToken("marissa", "not used"))); assertNull(mgr.getAcls(new Integer(4), new UsernamePasswordAuthenticationToken("rod", "not used")));
assertNull(mgr.getAcls(new Integer(4))); assertNull(mgr.getAcls(new Integer(4)));
} }
@ -162,10 +162,10 @@ public class AclProviderManagerTests extends TestCase {
//~ Inner Classes ================================================================================================== //~ Inner Classes ==================================================================================================
private class MockProvider implements AclProvider { private class MockProvider implements AclProvider {
private UsernamePasswordAuthenticationToken marissa = new UsernamePasswordAuthenticationToken("marissa", private UsernamePasswordAuthenticationToken rod = new UsernamePasswordAuthenticationToken("rod",
"not used", "not used",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO"), new GrantedAuthorityImpl("ROLE_BAR")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO"), new GrantedAuthorityImpl("ROLE_BAR")});
private SimpleAclEntry entry100Marissa = new SimpleAclEntry(marissa.getPrincipal(), private SimpleAclEntry entry100rod = new SimpleAclEntry(rod.getPrincipal(),
new NamedEntityObjectIdentity("OBJECT", "100"), null, 2); new NamedEntityObjectIdentity("OBJECT", "100"), null, 2);
private UsernamePasswordAuthenticationToken scott = new UsernamePasswordAuthenticationToken("scott", private UsernamePasswordAuthenticationToken scott = new UsernamePasswordAuthenticationToken("scott",
"not used", "not used",
@ -181,15 +181,15 @@ public class AclProviderManagerTests extends TestCase {
return new AclEntry[] {entry100Scott}; return new AclEntry[] {entry100Scott};
} }
if (authentication.getPrincipal().equals(marissa.getPrincipal())) { if (authentication.getPrincipal().equals(rod.getPrincipal())) {
return new AclEntry[] {entry100Marissa}; return new AclEntry[] {entry100rod};
} }
return null; return null;
} }
public AclEntry[] getAcls(Object domainInstance) { public AclEntry[] getAcls(Object domainInstance) {
return new AclEntry[] {entry100Marissa, entry100Scott}; return new AclEntry[] {entry100rod, entry100Scott};
} }
/** /**

View File

@ -47,10 +47,10 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
private SimpleAclEntry entry100Scott = new SimpleAclEntry(scott.getPrincipal(), private SimpleAclEntry entry100Scott = new SimpleAclEntry(scott.getPrincipal(),
new NamedEntityObjectIdentity("OBJECT", "100"), null, 4); new NamedEntityObjectIdentity("OBJECT", "100"), null, 4);
private UsernamePasswordAuthenticationToken dianne = new UsernamePasswordAuthenticationToken("dianne", "not used"); private UsernamePasswordAuthenticationToken dianne = new UsernamePasswordAuthenticationToken("dianne", "not used");
private UsernamePasswordAuthenticationToken marissa = new UsernamePasswordAuthenticationToken("marissa", private UsernamePasswordAuthenticationToken rod = new UsernamePasswordAuthenticationToken("rod",
"not used", "not used",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_EVERYBODY"), new GrantedAuthorityImpl("ROLE_ONE")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_EVERYBODY"), new GrantedAuthorityImpl("ROLE_ONE")});
private SimpleAclEntry entry100Marissa = new SimpleAclEntry(marissa.getPrincipal(), private SimpleAclEntry entry100rod = new SimpleAclEntry(rod.getPrincipal(),
new NamedEntityObjectIdentity("OBJECT", "100"), null, 2); new NamedEntityObjectIdentity("OBJECT", "100"), null, 2);
private UsernamePasswordAuthenticationToken scottWithUserDetails = new UsernamePasswordAuthenticationToken(new User( private UsernamePasswordAuthenticationToken scottWithUserDetails = new UsernamePasswordAuthenticationToken(new User(
"scott", "NOT_USED", true, true, true, true, "scott", "NOT_USED", true, true, true, true,
@ -59,7 +59,7 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
// convenience group // convenience group
private SimpleAclEntry[] acls = { private SimpleAclEntry[] acls = {
entry100Marissa, entry100Scott, entry100RoleEverybody, entry100RoleOne, entry100RoleTwo entry100rod, entry100Scott, entry100RoleEverybody, entry100RoleOne, entry100RoleTwo
}; };
//~ Constructors =================================================================================================== //~ Constructors ===================================================================================================
@ -87,12 +87,12 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
assertNull(resolver.resolveEffectiveAcls(acls, dianne)); assertNull(resolver.resolveEffectiveAcls(acls, dianne));
} }
public void testResolveAclsForMarissa() { public void testResolveAclsForrod() {
GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver(); GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver();
assertEquals(3, resolver.resolveEffectiveAcls(acls, marissa).length); assertEquals(3, resolver.resolveEffectiveAcls(acls, rod).length);
assertEquals(entry100Marissa, resolver.resolveEffectiveAcls(acls, marissa)[0]); assertEquals(entry100rod, resolver.resolveEffectiveAcls(acls, rod)[0]);
assertEquals(entry100RoleEverybody, resolver.resolveEffectiveAcls(acls, marissa)[1]); assertEquals(entry100RoleEverybody, resolver.resolveEffectiveAcls(acls, rod)[1]);
assertEquals(entry100RoleOne, resolver.resolveEffectiveAcls(acls, marissa)[2]); assertEquals(entry100RoleOne, resolver.resolveEffectiveAcls(acls, rod)[2]);
} }
public void testResolveAclsForScottWithStringObjectAsPrincipal() { public void testResolveAclsForScottWithStringObjectAsPrincipal() {
@ -119,9 +119,9 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
public void testSkipsNonBasicAclEntryObjects() { public void testSkipsNonBasicAclEntryObjects() {
GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver(); GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver();
AclEntry[] basicAcls = { AclEntry[] basicAcls = {
entry100Marissa, entry100Scott, entry100RoleEverybody, entry100RoleOne, new MockAcl(), entry100RoleTwo entry100rod, entry100Scott, entry100RoleEverybody, entry100RoleOne, new MockAcl(), entry100RoleTwo
}; };
assertEquals(3, resolver.resolveEffectiveAcls(basicAcls, marissa).length); assertEquals(3, resolver.resolveEffectiveAcls(basicAcls, rod).length);
} }
//~ Inner Classes ================================================================================================== //~ Inner Classes ==================================================================================================

View File

@ -45,7 +45,7 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testCorrectOperation() { public void testCorrectOperation() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0); SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
@ -86,7 +86,7 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testDetectsNullOnMainConstructor() { public void testDetectsNullOnMainConstructor() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
try { try {
@ -123,7 +123,7 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testRejectsInvalidMasksInAddMethod() { public void testRejectsInvalidMasksInAddMethod() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 4); SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 4);
@ -136,7 +136,7 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testRejectsInvalidMasksInDeleteMethod() { public void testRejectsInvalidMasksInDeleteMethod() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0); SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE}); acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE});
@ -150,7 +150,7 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testRejectsInvalidMasksInTogglePermissionMethod() { public void testRejectsInvalidMasksInTogglePermissionMethod() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0); SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE}); acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE});
@ -164,11 +164,11 @@ public class SimpleAclEntryTests extends TestCase {
} }
public void testToString() { public void testToString() {
String recipient = "marissa"; String recipient = "rod";
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12"); AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0); SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE}); acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE});
assertTrue(acl.toString().endsWith("marissa=-RWC- ............................111. (14)]")); assertTrue(acl.toString().endsWith("rod=-RWC- ............................111. (14)]"));
} }
public void testParsePermission() { public void testParsePermission() {

View File

@ -40,7 +40,7 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
private static final AclObjectIdentity OBJECT_100 = new NamedEntityObjectIdentity("OBJECT", "100"); private static final AclObjectIdentity OBJECT_100 = new NamedEntityObjectIdentity("OBJECT", "100");
private static final AclObjectIdentity OBJECT_200 = new NamedEntityObjectIdentity("OBJECT", "200"); private static final AclObjectIdentity OBJECT_200 = new NamedEntityObjectIdentity("OBJECT", "200");
private static final BasicAclEntry OBJECT_100_MARISSA = new SimpleAclEntry("marissa", OBJECT_100, null, 2); private static final BasicAclEntry OBJECT_100_ROD = new SimpleAclEntry("rod", OBJECT_100, null, 2);
private static final BasicAclEntry OBJECT_100_SCOTT = new SimpleAclEntry("scott", OBJECT_100, null, 4); private static final BasicAclEntry OBJECT_100_SCOTT = new SimpleAclEntry("scott", OBJECT_100, null, 4);
private static final BasicAclEntry OBJECT_200_PETER = new SimpleAclEntry("peter", OBJECT_200, null, 4); private static final BasicAclEntry OBJECT_200_PETER = new SimpleAclEntry("peter", OBJECT_200, null, 4);
@ -71,12 +71,12 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
cache.setCache(getCache()); cache.setCache(getCache());
cache.afterPropertiesSet(); cache.afterPropertiesSet();
cache.putEntriesInCache(new BasicAclEntry[] {OBJECT_100_SCOTT, OBJECT_100_MARISSA}); cache.putEntriesInCache(new BasicAclEntry[] {OBJECT_100_SCOTT, OBJECT_100_ROD});
cache.putEntriesInCache(new BasicAclEntry[] {OBJECT_200_PETER}); cache.putEntriesInCache(new BasicAclEntry[] {OBJECT_200_PETER});
// Check we can get them from cache again // Check we can get them from cache again
assertEquals(OBJECT_100_SCOTT, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "100"))[0]); assertEquals(OBJECT_100_SCOTT, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "100"))[0]);
assertEquals(OBJECT_100_MARISSA, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "100"))[1]); assertEquals(OBJECT_100_ROD, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "100"))[1]);
assertEquals(OBJECT_200_PETER, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "200"))[0]); assertEquals(OBJECT_200_PETER, cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "200"))[0]);
assertNull(cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "NOT_IN_CACHE"))); assertNull(cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "NOT_IN_CACHE")));

View File

@ -79,7 +79,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1"); AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
// Create a BasicAclEntry for this AclObjectIdentity // Create a BasicAclEntry for this AclObjectIdentity
SimpleAclEntry simpleAcl1 = new SimpleAclEntry("marissa", identity, parentIdentity, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl1 = new SimpleAclEntry("rod", identity, parentIdentity, SimpleAclEntry.CREATE);
dao.create(simpleAcl1); dao.create(simpleAcl1);
// Create another BasicAclEntry for this AclObjectIdentity // Create another BasicAclEntry for this AclObjectIdentity
@ -93,11 +93,11 @@ public class JdbcExtendedDaoImplTests extends TestCase {
assertEquals(SimpleAclEntry.READ, acls[1].getMask()); assertEquals(SimpleAclEntry.READ, acls[1].getMask());
// Attempt to change mask // Attempt to change mask
dao.changeMask(identity, "marissa", new Integer(SimpleAclEntry.ADMINISTRATION)); dao.changeMask(identity, "rod", new Integer(SimpleAclEntry.ADMINISTRATION));
dao.changeMask(identity, "scott", new Integer(SimpleAclEntry.NOTHING)); dao.changeMask(identity, "scott", new Integer(SimpleAclEntry.NOTHING));
acls = dao.getAcls(identity); acls = dao.getAcls(identity);
assertEquals(2, acls.length); assertEquals(2, acls.length);
assertEquals("marissa", acls[0].getRecipient()); assertEquals("rod", acls[0].getRecipient());
assertEquals(SimpleAclEntry.ADMINISTRATION, acls[0].getMask()); assertEquals(SimpleAclEntry.ADMINISTRATION, acls[0].getMask());
assertEquals("scott", acls[1].getRecipient()); assertEquals("scott", acls[1].getRecipient());
assertEquals(SimpleAclEntry.NOTHING, acls[1].getMask()); assertEquals(SimpleAclEntry.NOTHING, acls[1].getMask());
@ -110,7 +110,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1"); AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
// Create at least one record for this AclObjectIdentity // Create at least one record for this AclObjectIdentity
SimpleAclEntry simpleAcl1 = new SimpleAclEntry("marissa", identity, parentIdentity, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl1 = new SimpleAclEntry("rod", identity, parentIdentity, SimpleAclEntry.CREATE);
dao.create(simpleAcl1); dao.create(simpleAcl1);
// Attempt to change mask, but for a recipient we don't have // Attempt to change mask, but for a recipient we don't have
@ -156,7 +156,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
AclObjectIdentity identity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "203"); AclObjectIdentity identity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "203");
// Create a BasicAclEntry for this AclObjectIdentity // Create a BasicAclEntry for this AclObjectIdentity
SimpleAclEntry simpleAcl1 = new SimpleAclEntry("marissa", identity, null, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl1 = new SimpleAclEntry("rod", identity, null, SimpleAclEntry.CREATE);
dao.create(simpleAcl1); dao.create(simpleAcl1);
// Create another BasicAclEntry for this AclObjectIdentity // Create another BasicAclEntry for this AclObjectIdentity
@ -178,7 +178,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1"); AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
// Create a BasicAclEntry for this AclObjectIdentity // Create a BasicAclEntry for this AclObjectIdentity
SimpleAclEntry simpleAcl1 = new SimpleAclEntry("marissa", identity, parentIdentity, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl1 = new SimpleAclEntry("rod", identity, parentIdentity, SimpleAclEntry.CREATE);
dao.create(simpleAcl1); dao.create(simpleAcl1);
// Create another BasicAclEntry for this AclObjectIdentity // Create another BasicAclEntry for this AclObjectIdentity
@ -263,7 +263,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1"); AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
// Create a BasicAclEntry for this AclObjectIdentity // Create a BasicAclEntry for this AclObjectIdentity
SimpleAclEntry simpleAcl1 = new SimpleAclEntry("marissa", identity, parentIdentity, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl1 = new SimpleAclEntry("rod", identity, parentIdentity, SimpleAclEntry.CREATE);
dao.create(simpleAcl1); dao.create(simpleAcl1);
// Create another BasicAclEntry for this AclObjectIdentity // Create another BasicAclEntry for this AclObjectIdentity
@ -291,7 +291,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
JdbcExtendedDaoImpl dao = makePopulatedJdbcDao(); JdbcExtendedDaoImpl dao = makePopulatedJdbcDao();
AclObjectIdentity identity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "201"); AclObjectIdentity identity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "201");
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "987987987987986"); AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "987987987987986");
SimpleAclEntry simpleAcl = new SimpleAclEntry("marissa", identity, parentIdentity, SimpleAclEntry.CREATE); SimpleAclEntry simpleAcl = new SimpleAclEntry("rod", identity, parentIdentity, SimpleAclEntry.CREATE);
try { try {
dao.create(simpleAcl); dao.create(simpleAcl);

View File

@ -95,12 +95,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject() public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider(); BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
@ -129,12 +129,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testCorrectOperationWhenPrincipalIsAuthorised() public void testCorrectOperationWhenPrincipalIsAuthorised()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider(); BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
@ -151,7 +151,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
list.add("brisbane"); list.add("brisbane");
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -165,12 +165,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testCorrectOperationWhenReturnedObjectIsArray() public void testCorrectOperationWhenReturnedObjectIsArray()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider(); BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
@ -187,7 +187,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
list[3] = "brisbane"; list[3] = "brisbane";
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -201,11 +201,11 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testDetectsIfReturnedObjectIsNotACollection() public void testDetectsIfReturnedObjectIsNotACollection()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
new MockAclEntry() new MockAclEntry()
}); });
@ -214,7 +214,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -230,11 +230,11 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testGrantsAccessIfReturnedObjectIsNull() public void testGrantsAccessIfReturnedObjectIsNull()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
new MockAclEntry() new MockAclEntry()
}); });
@ -243,7 +243,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -256,9 +256,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testRespectsModificationsToProcessConfigAttribute() public void testRespectsModificationsToProcessConfigAttribute()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new MockAclEntry() new MockAclEntry()
}); });
@ -278,7 +278,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
list.add("brisbane"); list.add("brisbane");
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -297,9 +297,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testRespectsModificationsToRequirePermissions() public void testRespectsModificationsToRequirePermissions()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
@ -319,7 +319,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
list.add("brisbane"); list.add("brisbane");
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
@ -344,9 +344,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testStartupDetectsMissingProcessConfigAttribute() public void testStartupDetectsMissingProcessConfigAttribute()
throws Exception { throws Exception {
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider(); BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
provider.setAclManager(aclManager); provider.setAclManager(aclManager);
@ -364,9 +364,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
public void testStartupDetectsMissingRequirePermission() public void testStartupDetectsMissingRequirePermission()
throws Exception { throws Exception {
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider(); BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
provider.setAclManager(aclManager); provider.setAclManager(aclManager);

View File

@ -87,12 +87,12 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject() public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider(); BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
@ -115,12 +115,12 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testCorrectOperationWhenPrincipalIsAuthorised() public void testCorrectOperationWhenPrincipalIsAuthorised()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider(); BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
@ -129,7 +129,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
@ -140,11 +140,11 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testGrantsAccessIfReturnedObjectIsNull() public void testGrantsAccessIfReturnedObjectIsNull()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("belmont", "marissa", AclManager aclManager = new MockAclManager("belmont", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
new MockAclEntry() new MockAclEntry()
}); });
@ -153,7 +153,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
@ -164,9 +164,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testRespectsModificationsToProcessConfigAttribute() public void testRespectsModificationsToProcessConfigAttribute()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new MockAclEntry() new MockAclEntry()
}); });
@ -178,7 +178,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
@ -193,9 +193,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testRespectsModificationsToRequirePermissions() public void testRespectsModificationsToRequirePermissions()
throws Exception { throws Exception {
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
@ -207,7 +207,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
provider.afterPropertiesSet(); provider.afterPropertiesSet();
// Create the Authentication and Config Attribs we'll be presenting // Create the Authentication and Config Attribs we'll be presenting
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("marissa", "NOT_USED"); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("rod", "NOT_USED");
ConfigAttributeDefinition attr = new ConfigAttributeDefinition(); ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ")); attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
@ -229,9 +229,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testStartupDetectsMissingProcessConfigAttribute() public void testStartupDetectsMissingProcessConfigAttribute()
throws Exception { throws Exception {
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider(); BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
provider.setAclManager(aclManager); provider.setAclManager(aclManager);
@ -249,9 +249,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
public void testStartupDetectsMissingRequirePermission() public void testStartupDetectsMissingRequirePermission()
throws Exception { throws Exception {
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider(); BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
AclManager aclManager = new MockAclManager("sydney", "marissa", AclManager aclManager = new MockAclManager("sydney", "rod",
new AclEntry[] { new AclEntry[] {
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new MockAclEntry() new MockAclEntry()
}); });
provider.setAclManager(aclManager); provider.setAclManager(aclManager);

View File

@ -57,9 +57,9 @@ public class SecurityContextImplTests extends TestCase {
public void testSecurityContextCorrectOperation() { public void testSecurityContextCorrectOperation() {
SecurityContext context = new SecurityContextImpl(); SecurityContext context = new SecurityContextImpl();
Authentication auth = new UsernamePasswordAuthenticationToken("marissa", "koala"); Authentication auth = new UsernamePasswordAuthenticationToken("rod", "koala");
context.setAuthentication(auth); context.setAuthentication(auth);
assertEquals(auth, context.getAuthentication()); assertEquals(auth, context.getAuthentication());
assertTrue(context.toString().lastIndexOf("marissa") != -1); assertTrue(context.toString().lastIndexOf("rod") != -1);
} }
} }

View File

@ -69,7 +69,7 @@ public class ContextPropagatingRemoteInvocationTests extends TestCase {
public void testContextIsResetEvenIfExceptionOccurs() public void testContextIsResetEvenIfExceptionOccurs()
throws Exception { throws Exception {
// Setup client-side context // Setup client-side context
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("marissa", "koala"); Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication); SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation(); ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
@ -88,7 +88,7 @@ public class ContextPropagatingRemoteInvocationTests extends TestCase {
public void testNormalOperation() throws Exception { public void testNormalOperation() throws Exception {
// Setup client-side context // Setup client-side context
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("marissa", "koala"); Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication); SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation(); ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();

View File

@ -67,12 +67,12 @@ public class InterceptorStatusTokenTests extends TestCase {
MethodInvocation mi = new SimpleMethodInvocation(); MethodInvocation mi = new SimpleMethodInvocation();
InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken("marissa", InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken("rod",
"koala"), true, attr, mi); "koala"), true, attr, mi);
assertTrue(token.isContextHolderRefreshRequired()); assertTrue(token.isContextHolderRefreshRequired());
assertEquals(attr, token.getAttr()); assertEquals(attr, token.getAttr());
assertEquals(mi, token.getSecureObject()); assertEquals(mi, token.getSecureObject());
assertEquals("marissa", token.getAuthentication().getPrincipal()); assertEquals("rod", token.getAuthentication().getPrincipal());
} }
} }

View File

@ -88,7 +88,7 @@ public class AspectJSecurityInterceptorTests extends TestCase {
MockAspectJCallback aspectJCallback = new MockAspectJCallback(); MockAspectJCallback aspectJCallback = new MockAspectJCallback();
SecurityContextHolder.getContext() SecurityContextHolder.getContext()
.setAuthentication(new TestingAuthenticationToken("marissa", "koala", .setAuthentication(new TestingAuthenticationToken("rod", "koala",
new GrantedAuthority[] {new GrantedAuthorityImpl("MOCK_ONE")})); new GrantedAuthority[] {new GrantedAuthorityImpl("MOCK_ONE")}));
Object result = si.invoke(joinPoint, aspectJCallback); Object result = si.invoke(joinPoint, aspectJCallback);
@ -120,7 +120,7 @@ public class AspectJSecurityInterceptorTests extends TestCase {
aspectJCallback.setThrowExceptionIfInvoked(true); aspectJCallback.setThrowExceptionIfInvoked(true);
SecurityContextHolder.getContext() SecurityContextHolder.getContext()
.setAuthentication(new TestingAuthenticationToken("marissa", "koala", .setAuthentication(new TestingAuthenticationToken("rod", "koala",
new GrantedAuthority[] {})); new GrantedAuthority[] {}));
try { try {

View File

@ -60,7 +60,7 @@ public class FilterBasedLdapUserSearchTests extends AbstractLdapIntegrationTests
@Test @Test
public void testExtraFilterPartToExcludeBob() throws Exception { public void testExtraFilterPartToExcludeBob() throws Exception {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=people", FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=people",
"(&(cn=*)(!(|(uid={0})(uid=marissa))))", dirCtxFactory); "(&(cn=*)(!(|(uid={0})(uid=rod))))", dirCtxFactory);
// Search for bob, get back ben... // Search for bob, get back ben...
DirContextOperations ben = locator.searchForUser("bob"); DirContextOperations ben = locator.searchForUser("bob");

View File

@ -390,7 +390,7 @@ public class CasAuthenticationProviderTests extends TestCase {
List list = new Vector(); List list = new Vector();
list.add("https://localhost/portal/j_spring_cas_security_check"); list.add("https://localhost/portal/j_spring_cas_security_check");
return new TicketResponse("marissa", list, "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt"); return new TicketResponse("rod", list, "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
} }
throw new BadCredentialsException("As requested from mock"); throw new BadCredentialsException("As requested from mock");

View File

@ -49,12 +49,12 @@ public class TicketResponseTests extends TestCase {
} }
public void testConstructorAcceptsNullProxyGrantingTicketIOU() { public void testConstructorAcceptsNullProxyGrantingTicketIOU() {
TicketResponse ticket = new TicketResponse("marissa", new Vector(), null); TicketResponse ticket = new TicketResponse("rod", new Vector(), null);
assertEquals("", ticket.getProxyGrantingTicketIou()); assertEquals("", ticket.getProxyGrantingTicketIou());
} }
public void testConstructorAcceptsNullProxyList() { public void testConstructorAcceptsNullProxyList() {
TicketResponse ticket = new TicketResponse("marissa", null, TicketResponse ticket = new TicketResponse("rod", null,
"PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt"); "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
assertEquals(new Vector(), ticket.getProxyList()); assertEquals(new Vector(), ticket.getProxyList());
} }
@ -73,9 +73,9 @@ public class TicketResponseTests extends TestCase {
List proxyList = new Vector(); List proxyList = new Vector();
proxyList.add("https://localhost/newPortal/j_spring_cas_security_check"); proxyList.add("https://localhost/newPortal/j_spring_cas_security_check");
TicketResponse ticket = new TicketResponse("marissa", proxyList, TicketResponse ticket = new TicketResponse("rod", proxyList,
"PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt"); "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
assertEquals("marissa", ticket.getUser()); assertEquals("rod", ticket.getUser());
assertEquals(proxyList, ticket.getProxyList()); assertEquals(proxyList, ticket.getProxyList());
assertEquals("PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt", ticket.getProxyGrantingTicketIou()); assertEquals("PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt", ticket.getProxyGrantingTicketIou());
} }
@ -92,7 +92,7 @@ public class TicketResponseTests extends TestCase {
} }
public void testToString() { public void testToString() {
TicketResponse ticket = new TicketResponse("marissa", null, TicketResponse ticket = new TicketResponse("rod", null,
"PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt"); "PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
String result = ticket.toString(); String result = ticket.toString();
assertTrue(result.lastIndexOf("Proxy List:") != -1); assertTrue(result.lastIndexOf("Proxy List:") != -1);

View File

@ -61,7 +61,7 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
List proxyList = new Vector(); List proxyList = new Vector();
proxyList.add("https://localhost/newPortal/j_spring_cas_security_check"); proxyList.add("https://localhost/newPortal/j_spring_cas_security_check");
User user = new User("marissa", "password", true, true, true, true, User user = new User("rod", "password", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ", return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",

View File

@ -51,7 +51,7 @@ public class NullStatelessTicketCacheTests extends TestCase {
List<String> proxyList = new ArrayList<String>(); List<String> proxyList = new ArrayList<String>();
proxyList.add("https://localhost/newPortal/j_spring_cas_security_check"); proxyList.add("https://localhost/newPortal/j_spring_cas_security_check");
User user = new User("marissa", "password", true, true, true, true, User user = new User("rod", "password", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ", return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",

View File

@ -70,7 +70,7 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
public void testGetGrantedAuthoritiesForInvalidUsername() public void testGetGrantedAuthoritiesForInvalidUsername()
throws Exception { throws Exception {
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator(); DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
populator.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); populator.setUserDetailsService(new MockAuthenticationDaoUserrod());
populator.afterPropertiesSet(); populator.afterPropertiesSet();
try { try {
@ -84,10 +84,10 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
public void testGetGrantedAuthoritiesForValidUsername() public void testGetGrantedAuthoritiesForValidUsername()
throws Exception { throws Exception {
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator(); DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
populator.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); populator.setUserDetailsService(new MockAuthenticationDaoUserrod());
populator.afterPropertiesSet(); populator.afterPropertiesSet();
UserDetails results = populator.getUserDetails("marissa"); UserDetails results = populator.getUserDetails("rod");
assertEquals(2, results.getAuthorities().length); assertEquals(2, results.getAuthorities().length);
assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), results.getAuthorities()[0]); assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), results.getAuthorities()[0]);
assertEquals(new GrantedAuthorityImpl("ROLE_TWO"), results.getAuthorities()[1]); assertEquals(new GrantedAuthorityImpl("ROLE_TWO"), results.getAuthorities()[1]);
@ -109,7 +109,7 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
public void testGettersSetters() { public void testGettersSetters() {
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator(); DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
UserDetailsService dao = new MockAuthenticationDaoUserMarissa(); UserDetailsService dao = new MockAuthenticationDaoUserrod();
populator.setUserDetailsService(dao); populator.setUserDetailsService(dao);
assertEquals(dao, populator.getUserDetailsService()); assertEquals(dao, populator.getUserDetailsService());
} }
@ -127,15 +127,15 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
} }
} }
private class MockAuthenticationDaoUserMarissa implements UserDetailsService { private class MockAuthenticationDaoUserrod implements UserDetailsService {
public long getRefreshDuration() { public long getRefreshDuration() {
return 0; return 0;
} }
public UserDetails loadUserByUsername(String username) public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException { throws UsernameNotFoundException, DataAccessException {
if ("marissa".equals(username)) { if ("rod".equals(username)) {
return new User("marissa", "koala", true, true, true, true, return new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
} else { } else {
throw new UsernameNotFoundException("Could not find: " + username); throw new UsernameNotFoundException("Could not find: " + username);

View File

@ -56,10 +56,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
public void testAuthenticateFailsForIncorrectPasswordCase() { public void testAuthenticateFailsForIncorrectPasswordCase() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "KOala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "KOala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -73,10 +73,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
public void testReceivedBadCredentialsWhenCredentialsNotProvided() { public void testReceivedBadCredentialsWhenCredentialsNotProvided() {
// Test related to SEC-434 // Test related to SEC-434
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("marissa", null); UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("rod", null);
try { try {
provider.authenticate(authenticationToken); provider.authenticate(authenticationToken);
fail("Expected BadCredenialsException"); fail("Expected BadCredenialsException");
@ -156,7 +156,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticateFailsWhenAuthenticationDaoHasBackendFailure() { public void testAuthenticateFailsWhenAuthenticationDaoHasBackendFailure() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoSimulateBackendError()); provider.setUserDetailsService(new MockAuthenticationDaoSimulateBackendError());
@ -174,7 +174,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -186,11 +186,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticateFailsWithInvalidPassword() { public void testAuthenticateFailsWithInvalidPassword() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod",
"INVALID_PASSWORD"); "INVALID_PASSWORD");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -206,7 +206,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -222,7 +222,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
assertTrue(provider.isHideUserNotFoundExceptions()); assertTrue(provider.isHideUserNotFoundExceptions());
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -234,10 +234,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() { public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("MaRiSSA", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("RoD", "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -249,11 +249,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticates() { public void testAuthenticates() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
token.setDetails("192.168.0.1"); token.setDetails("192.168.0.1");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
Authentication result = provider.authenticate(token); Authentication result = provider.authenticate(token);
@ -271,10 +271,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticatesASecondTime() { public void testAuthenticatesASecondTime() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
Authentication result = provider.authenticate(token); Authentication result = provider.authenticate(token);
@ -294,13 +294,13 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticatesWhenASaltIsUsed() { public void testAuthenticatesWhenASaltIsUsed() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
SystemWideSaltSource salt = new SystemWideSaltSource(); SystemWideSaltSource salt = new SystemWideSaltSource();
salt.setSystemWideSalt("SYSTEM_SALT_VALUE"); salt.setSystemWideSalt("SYSTEM_SALT_VALUE");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissaWithSalt()); provider.setUserDetailsService(new MockAuthenticationDaoUserrodWithSalt());
provider.setSaltSource(salt); provider.setSaltSource(salt);
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
@ -320,10 +320,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticatesWithForcePrincipalAsString() { public void testAuthenticatesWithForcePrincipalAsString() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
provider.setForcePrincipalAsString(true); provider.setForcePrincipalAsString(true);
@ -335,11 +335,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result; UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result;
assertEquals(String.class, castResult.getPrincipal().getClass()); assertEquals(String.class, castResult.getPrincipal().getClass());
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
} }
public void testDetectsNullBeingReturnedFromAuthenticationDao() { public void testDetectsNullBeingReturnedFromAuthenticationDao() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoReturnsNull()); provider.setUserDetailsService(new MockAuthenticationDaoReturnsNull());
@ -370,9 +370,9 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
public void testGoesBackToAuthenticationDaoToObtainLatestPasswordIfCachedPasswordSeemsIncorrect() { public void testGoesBackToAuthenticationDaoToObtainLatestPasswordIfCachedPasswordSeemsIncorrect() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
MockAuthenticationDaoUserMarissa authenticationDao = new MockAuthenticationDaoUserMarissa(); MockAuthenticationDaoUserrod authenticationDao = new MockAuthenticationDaoUserrod();
MockUserCache cache = new MockUserCache(); MockUserCache cache = new MockUserCache();
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(authenticationDao); provider.setUserDetailsService(authenticationDao);
@ -381,19 +381,19 @@ public class DaoAuthenticationProviderTests extends TestCase {
// This will work, as password still "koala" // This will work, as password still "koala"
provider.authenticate(token); provider.authenticate(token);
// Check "marissa = koala" ended up in the cache // Check "rod = koala" ended up in the cache
assertEquals("koala", cache.getUserFromCache("marissa").getPassword()); assertEquals("koala", cache.getUserFromCache("rod").getPassword());
// Now change the password the AuthenticationDao will return // Now change the password the AuthenticationDao will return
authenticationDao.setPassword("easternLongNeckTurtle"); authenticationDao.setPassword("easternLongNeckTurtle");
// Now try authentication again, with the new password // Now try authentication again, with the new password
token = new UsernamePasswordAuthenticationToken("marissa", "easternLongNeckTurtle"); token = new UsernamePasswordAuthenticationToken("rod", "easternLongNeckTurtle");
provider.authenticate(token); provider.authenticate(token);
// To get this far, the new password was accepted // To get this far, the new password was accepted
// Check the cache was updated // Check the cache was updated
assertEquals("easternLongNeckTurtle", cache.getUserFromCache("marissa").getPassword()); assertEquals("easternLongNeckTurtle", cache.getUserFromCache("rod").getPassword());
} }
public void testStartupFailsIfNoAuthenticationDao() public void testStartupFailsIfNoAuthenticationDao()
@ -410,7 +410,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
public void testStartupFailsIfNoUserCacheSet() throws Exception { public void testStartupFailsIfNoUserCacheSet() throws Exception {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa()); provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
assertEquals(NullUserCache.class, provider.getUserCache().getClass()); assertEquals(NullUserCache.class, provider.getUserCache().getClass());
provider.setUserCache(null); provider.setUserCache(null);
@ -424,7 +424,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
public void testStartupSuccess() throws Exception { public void testStartupSuccess() throws Exception {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
UserDetailsService userDetailsService = new MockAuthenticationDaoUserMarissa(); UserDetailsService userDetailsService = new MockAuthenticationDaoUserrod();
provider.setUserDetailsService(userDetailsService); provider.setUserDetailsService(userDetailsService);
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
assertEquals(userDetailsService, provider.getUserDetailsService()); assertEquals(userDetailsService, provider.getUserDetailsService());
@ -454,13 +454,13 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
} }
private class MockAuthenticationDaoUserMarissa implements UserDetailsService { private class MockAuthenticationDaoUserrod implements UserDetailsService {
private String password = "koala"; private String password = "koala";
public UserDetails loadUserByUsername(String username) public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException { throws UsernameNotFoundException, DataAccessException {
if ("marissa".equals(username)) { if ("rod".equals(username)) {
return new User("marissa", password, true, true, true, true, return new User("rod", password, true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
} else { } else {
throw new UsernameNotFoundException("Could not find: " + username); throw new UsernameNotFoundException("Could not find: " + username);
@ -472,11 +472,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
} }
} }
private class MockAuthenticationDaoUserMarissaWithSalt implements UserDetailsService { private class MockAuthenticationDaoUserrodWithSalt implements UserDetailsService {
public UserDetails loadUserByUsername(String username) public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException { throws UsernameNotFoundException, DataAccessException {
if ("marissa".equals(username)) { if ("rod".equals(username)) {
return new User("marissa", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
} else { } else {
throw new UsernameNotFoundException("Could not find: " + username); throw new UsernameNotFoundException("Could not find: " + username);

View File

@ -43,7 +43,7 @@ public class RemoteAuthenticationManagerImplTests extends TestCase {
manager.setAuthenticationManager(new MockAuthenticationManager(false)); manager.setAuthenticationManager(new MockAuthenticationManager(false));
try { try {
manager.attemptAuthentication("marissa", "password"); manager.attemptAuthentication("rod", "password");
fail("Should have thrown RemoteAuthenticationException"); fail("Should have thrown RemoteAuthenticationException");
} catch (RemoteAuthenticationException expected) { } catch (RemoteAuthenticationException expected) {
assertTrue(true); assertTrue(true);
@ -76,7 +76,7 @@ public class RemoteAuthenticationManagerImplTests extends TestCase {
RemoteAuthenticationManagerImpl manager = new RemoteAuthenticationManagerImpl(); RemoteAuthenticationManagerImpl manager = new RemoteAuthenticationManagerImpl();
manager.setAuthenticationManager(new MockAuthenticationManager(true)); manager.setAuthenticationManager(new MockAuthenticationManager(true));
GrantedAuthority[] result = manager.attemptAuthentication("marissa", "password"); GrantedAuthority[] result = manager.attemptAuthentication("rod", "password");
assertTrue(true); assertTrue(true);
} }
} }

View File

@ -46,7 +46,7 @@ public class RemoteAuthenticationProviderTests extends TestCase {
provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(false)); provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(false));
try { try {
provider.authenticate(new UsernamePasswordAuthenticationToken("marissa", "password")); provider.authenticate(new UsernamePasswordAuthenticationToken("rod", "password"));
fail("Should have thrown RemoteAuthenticationException"); fail("Should have thrown RemoteAuthenticationException");
} catch (RemoteAuthenticationException expected) { } catch (RemoteAuthenticationException expected) {
assertTrue(true); assertTrue(true);
@ -79,8 +79,8 @@ public class RemoteAuthenticationProviderTests extends TestCase {
RemoteAuthenticationProvider provider = new RemoteAuthenticationProvider(); RemoteAuthenticationProvider provider = new RemoteAuthenticationProvider();
provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(true)); provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(true));
Authentication result = provider.authenticate(new UsernamePasswordAuthenticationToken("marissa", "password")); Authentication result = provider.authenticate(new UsernamePasswordAuthenticationToken("rod", "password"));
assertEquals("marissa", result.getPrincipal()); assertEquals("rod", result.getPrincipal());
assertEquals("password", result.getCredentials()); assertEquals("password", result.getCredentials());
assertEquals("foo", result.getAuthorities()[0].getAuthority()); assertEquals("foo", result.getAuthorities()[0].getAuthority());
} }

View File

@ -120,7 +120,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticateFailsWhenUserDetailsServiceHasBackendFailure() { public void testAuthenticateFailsWhenUserDetailsServiceHasBackendFailure() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceSimulateBackendError()); provider.setUserDetailsService(new MockUserDetailsServiceSimulateBackendError());
@ -138,7 +138,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -154,7 +154,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -170,7 +170,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
assertTrue(provider.isHideUserNotFoundExceptions()); assertTrue(provider.isHideUserNotFoundExceptions());
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -182,10 +182,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() { public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("MaRiSSA", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("RDd", "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
try { try {
@ -197,11 +197,11 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticates() { public void testAuthenticates() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
token.setDetails("192.168.0.1"); token.setDetails("192.168.0.1");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
Authentication result = provider.authenticate(token); Authentication result = provider.authenticate(token);
@ -219,10 +219,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticatesASecondTime() { public void testAuthenticatesASecondTime() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
Authentication result = provider.authenticate(token); Authentication result = provider.authenticate(token);
@ -242,10 +242,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
public void testAuthenticatesWithForcePrincipalAsString() { public void testAuthenticatesWithForcePrincipalAsString() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
provider.setForcePrincipalAsString(true); provider.setForcePrincipalAsString(true);
@ -257,11 +257,11 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result; UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result;
assertEquals(String.class, castResult.getPrincipal().getClass()); assertEquals(String.class, castResult.getPrincipal().getClass());
assertEquals("marissa", castResult.getPrincipal()); assertEquals("rod", castResult.getPrincipal());
} }
public void testDetectsNullBeingReturnedFromUserDetailsService() { public void testDetectsNullBeingReturnedFromUserDetailsService() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceReturnsNull()); provider.setUserDetailsService(new MockUserDetailsServiceReturnsNull());
@ -299,7 +299,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
public void testStartupFailsIfNoUserCacheSet() throws Exception { public void testStartupFailsIfNoUserCacheSet() throws Exception {
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa()); provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
assertEquals(NullUserCache.class, provider.getUserCache().getClass()); assertEquals(NullUserCache.class, provider.getUserCache().getClass());
provider.setUserCache(null); provider.setUserCache(null);
@ -313,7 +313,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
public void testStartupSuccess() throws Exception { public void testStartupSuccess() throws Exception {
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider(); SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
UserDetailsService userDetailsService = new MockUserDetailsServiceUserMarissa(); UserDetailsService userDetailsService = new MockUserDetailsServiceUserrod();
provider.setUserDetailsService(userDetailsService); provider.setUserDetailsService(userDetailsService);
provider.setUserCache(new MockUserCache()); provider.setUserCache(new MockUserCache());
assertEquals(userDetailsService, provider.getUserDetailsService()); assertEquals(userDetailsService, provider.getUserDetailsService());
@ -341,12 +341,12 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
} }
private class MockUserDetailsServiceUserMarissa implements UserDetailsService { private class MockUserDetailsServiceUserrod implements UserDetailsService {
private String password = "koala"; private String password = "koala";
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
if ("marissa".equals(username)) { if ("rod".equals(username)) {
return new User("marissa", password, true, true, true, true, new GrantedAuthority[] { return new User("rod", password, true, true, true, true, new GrantedAuthority[] {
new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") }); new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") });
} else { } else {
throw new UsernameNotFoundException("Could not find: " + username); throw new UsernameNotFoundException("Could not find: " + username);
@ -358,10 +358,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
} }
} }
private class MockUserDetailsServiceUserMarissaWithSalt implements UserDetailsService { private class MockUserDetailsServiceUserrodWithSalt implements UserDetailsService {
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
if ("marissa".equals(username)) { if ("rod".equals(username)) {
return new User("marissa", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, new GrantedAuthority[] { return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, new GrantedAuthority[] {
new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") }); new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") });
} else { } else {
throw new UsernameNotFoundException("Could not find: " + username); throw new UsernameNotFoundException("Could not find: " + username);

View File

@ -56,7 +56,7 @@ public class EhCacheBasedX509UserCacheTests extends TestCase {
} }
private UserDetails getUser() { private UserDetails getUser() {
return new User("marissa", "password", true, true, true, true, return new User("rod", "password", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
} }

View File

@ -59,7 +59,7 @@ public class AclTagTests extends TestCase {
public void testInclusionDeniedWhenAclManagerUnawareOfObject() public void testInclusionDeniedWhenAclManagerUnawareOfObject()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
aclTag.setHasPermission(new Long(SimpleAclEntry.ADMINISTRATION).toString()); aclTag.setHasPermission(new Long(SimpleAclEntry.ADMINISTRATION).toString());
@ -69,7 +69,7 @@ public class AclTagTests extends TestCase {
public void testInclusionDeniedWhenNoListOfPermissionsGiven() public void testInclusionDeniedWhenNoListOfPermissionsGiven()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
aclTag.setHasPermission(null); aclTag.setHasPermission(null);
@ -92,7 +92,7 @@ public class AclTagTests extends TestCase {
public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions() public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
aclTag.setHasPermission(new Integer(SimpleAclEntry.DELETE).toString()); aclTag.setHasPermission(new Integer(SimpleAclEntry.DELETE).toString());
@ -133,7 +133,7 @@ public class AclTagTests extends TestCase {
public void testOperationWhenPrincipalHoldsPermissionOfMultipleList() public void testOperationWhenPrincipalHoldsPermissionOfMultipleList()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
aclTag.setHasPermission(new Integer(SimpleAclEntry.ADMINISTRATION) + "," + new Integer(SimpleAclEntry.READ)); aclTag.setHasPermission(new Integer(SimpleAclEntry.ADMINISTRATION) + "," + new Integer(SimpleAclEntry.READ));
@ -143,7 +143,7 @@ public class AclTagTests extends TestCase {
public void testOperationWhenPrincipalHoldsPermissionOfSingleList() public void testOperationWhenPrincipalHoldsPermissionOfSingleList()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
aclTag.setHasPermission(new Integer(SimpleAclEntry.READ).toString()); aclTag.setHasPermission(new Integer(SimpleAclEntry.READ).toString());
@ -162,11 +162,11 @@ public class AclTagTests extends TestCase {
ConfigurableApplicationContext context = MockApplicationContext.getContext(); ConfigurableApplicationContext context = MockApplicationContext.getContext();
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("object1", "marissa", AclManager aclManager = new MockAclManager("object1", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
}); });
// Register the AclManager into our ApplicationContext // Register the AclManager into our ApplicationContext

View File

@ -49,34 +49,34 @@ public class AuthenticationTagTests extends TestCase {
public void testOperationAndMethodPrefixWhenPrincipalIsAUserDetailsInstance() public void testOperationAndMethodPrefixWhenPrincipalIsAUserDetailsInstance()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken(new User("marissaUserDetails", "koala", true, true, true, Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {}); true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authenticationTag.setOperation("username"); authenticationTag.setOperation("username");
authenticationTag.setMethodPrefix("get"); authenticationTag.setMethodPrefix("get");
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag()); assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
assertEquals("marissaUserDetails", authenticationTag.getLastMessage()); assertEquals("rodUserDetails", authenticationTag.getLastMessage());
} }
public void testOperationWhenPrincipalIsAString() throws JspException { public void testOperationWhenPrincipalIsAString() throws JspException {
Authentication auth = new TestingAuthenticationToken("marissaAsString", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rodAsString", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authenticationTag.setOperation("principal"); authenticationTag.setOperation("principal");
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag()); assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
assertEquals("marissaAsString", authenticationTag.getLastMessage()); assertEquals("rodAsString", authenticationTag.getLastMessage());
} }
public void testOperationWhenPrincipalIsAUserDetailsInstance() public void testOperationWhenPrincipalIsAUserDetailsInstance()
throws JspException { throws JspException {
Authentication auth = new TestingAuthenticationToken(new User("marissaUserDetails", "koala", true, true, true, Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {}); true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authenticationTag.setOperation("username"); authenticationTag.setOperation("username");
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag()); assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
assertEquals("marissaUserDetails", authenticationTag.getLastMessage()); assertEquals("rodUserDetails", authenticationTag.getLastMessage());
} }
public void testOperationWhenPrincipalIsNull() throws JspException { public void testOperationWhenPrincipalIsNull() throws JspException {
@ -102,7 +102,7 @@ public class AuthenticationTagTests extends TestCase {
} }
public void testThrowsExceptionForUnrecognisedMethodPrefix() { public void testThrowsExceptionForUnrecognisedMethodPrefix() {
Authentication auth = new TestingAuthenticationToken(new User("marissaUserDetails", "koala", true, true, true, Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {}); true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authenticationTag.setOperation("username"); authenticationTag.setOperation("username");
@ -117,7 +117,7 @@ public class AuthenticationTagTests extends TestCase {
} }
public void testThrowsExceptionForUnrecognisedOperation() { public void testThrowsExceptionForUnrecognisedOperation() {
Authentication auth = new TestingAuthenticationToken(new User("marissaUserDetails", "koala", true, true, true, Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {}); true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authenticationTag.setOperation("qsq"); authenticationTag.setOperation("qsq");

View File

@ -55,11 +55,11 @@ public class AuthzImplTest extends TestCase {
ctx = new StaticApplicationContext(); ctx = new StaticApplicationContext();
// Create an AclManager // Create an AclManager
AclManager aclManager = new MockAclManager("object1", "marissa", AclManager aclManager = new MockAclManager("object1", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
}); });
// Register the AclManager into our ApplicationContext // Register the AclManager into our ApplicationContext
@ -84,7 +84,7 @@ public class AuthzImplTest extends TestCase {
} }
public void testInclusionDeniedWhenAclManagerUnawareOfObject() { public void testInclusionDeniedWhenAclManagerUnawareOfObject() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authz.setAppCtx(ctx); authz.setAppCtx(ctx);
@ -97,7 +97,7 @@ public class AuthzImplTest extends TestCase {
} }
public void testInclusionDeniedWhenNoListOfPermissionsGiven() { public void testInclusionDeniedWhenNoListOfPermissionsGiven() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authz.setAppCtx(ctx); authz.setAppCtx(ctx);
@ -124,7 +124,7 @@ public class AuthzImplTest extends TestCase {
} }
public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions() { public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authz.setAppCtx(ctx); authz.setAppCtx(ctx);
@ -162,7 +162,7 @@ public class AuthzImplTest extends TestCase {
} }
public void testOperationWhenPrincipalHoldsPermissionOfMultipleList() { public void testOperationWhenPrincipalHoldsPermissionOfMultipleList() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authz.setAppCtx(ctx); authz.setAppCtx(ctx);
@ -177,7 +177,7 @@ public class AuthzImplTest extends TestCase {
} }
public void testOperationWhenPrincipalHoldsPermissionOfSingleList() { public void testOperationWhenPrincipalHoldsPermissionOfSingleList() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authz.setAppCtx(ctx); authz.setAppCtx(ctx);
@ -194,18 +194,18 @@ public class AuthzImplTest extends TestCase {
* Test method for 'com.alibaba.exodus2.web.common.security.pulltool.AuthzImpl.getPrincipal()' * Test method for 'com.alibaba.exodus2.web.common.security.pulltool.AuthzImpl.getPrincipal()'
*/ */
public void testOperationWhenPrincipalIsAString() { public void testOperationWhenPrincipalIsAString() {
Authentication auth = new TestingAuthenticationToken("marissaAsString", "koala", new GrantedAuthority[] {}); Authentication auth = new TestingAuthenticationToken("rodAsString", "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
assertEquals("marissaAsString", authz.getPrincipal()); assertEquals("rodAsString", authz.getPrincipal());
} }
public void testOperationWhenPrincipalIsAUserDetailsInstance() { public void testOperationWhenPrincipalIsAUserDetailsInstance() {
Authentication auth = new TestingAuthenticationToken(new User("marissaUserDetails", "koala", true, true, true, Authentication auth = new TestingAuthenticationToken(new User("rodUserDetails", "koala", true, true, true,
true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {}); true, new GrantedAuthority[] {}), "koala", new GrantedAuthority[] {});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
assertEquals("marissaUserDetails", authz.getPrincipal()); assertEquals("rodUserDetails", authz.getPrincipal());
} }
public void testOperationWhenPrincipalIsNull() { public void testOperationWhenPrincipalIsNull() {

View File

@ -102,7 +102,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
// Create User Details Service, provider and authentication manager // Create User Details Service, provider and authentication manager
InMemoryDaoImpl dao = new InMemoryDaoImpl(); InMemoryDaoImpl dao = new InMemoryDaoImpl();
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa=koala,ROLE_ONE,ROLE_TWO,enabled\r\n"); editor.setAsText("rod=koala,ROLE_ONE,ROLE_TWO,enabled\r\n");
dao.setUserMap((UserMap) editor.getValue()); dao.setUserMap((UserMap) editor.getValue());
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
@ -185,7 +185,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
public void testNormalOperation() throws Exception { public void testNormalOperation() throws Exception {
// Setup our HTTP request // Setup our HTTP request
String token = "marissa:koala"; String token = "rod:koala";
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
request.setServletPath("/some_file.html"); request.setServletPath("/some_file.html");
@ -196,7 +196,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
executeFilterInContainerSimulator(filter, request, true); executeFilterInContainerSimulator(filter, request, true);
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals("marissa", assertEquals("rod",
((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername()); ((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername());
} }
@ -240,7 +240,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
public void testSuccessLoginThenFailureLoginResultsInSessionLoosingToken() public void testSuccessLoginThenFailureLoginResultsInSessionLoosingToken()
throws Exception { throws Exception {
// Setup our HTTP request // Setup our HTTP request
String token = "marissa:koala"; String token = "rod:koala";
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
request.setServletPath("/some_file.html"); request.setServletPath("/some_file.html");
@ -250,7 +250,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
executeFilterInContainerSimulator(filter, request, true); executeFilterInContainerSimulator(filter, request, true);
assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertNotNull(SecurityContextHolder.getContext().getAuthentication());
assertEquals("marissa", assertEquals("rod",
((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername()); ((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername());
// NOW PERFORM FAILED AUTHENTICATION // NOW PERFORM FAILED AUTHENTICATION
@ -271,7 +271,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
public void testWrongPasswordContinuesFilterChainIfIgnoreFailureIsTrue() public void testWrongPasswordContinuesFilterChainIfIgnoreFailureIsTrue()
throws Exception { throws Exception {
// Setup our HTTP request // Setup our HTTP request
String token = "marissa:WRONG_PASSWORD"; String token = "rod:WRONG_PASSWORD";
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
request.setServletPath("/some_file.html"); request.setServletPath("/some_file.html");
@ -289,7 +289,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
public void testWrongPasswordReturnsForbiddenIfIgnoreFailureIsFalse() public void testWrongPasswordReturnsForbiddenIfIgnoreFailureIsFalse()
throws Exception { throws Exception {
// Setup our HTTP request // Setup our HTTP request
String token = "marissa:WRONG_PASSWORD"; String token = "rod:WRONG_PASSWORD";
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes()))); request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
request.setServletPath("/some_file.html"); request.setServletPath("/some_file.html");

View File

@ -65,7 +65,7 @@ public class DigestProcessingFilterTests extends MockObjectTestCase {
private static final String REALM = "The Actual, Correct Realm Name"; private static final String REALM = "The Actual, Correct Realm Name";
private static final String KEY = "springsecurity"; private static final String KEY = "springsecurity";
private static final String QOP = "auth"; private static final String QOP = "auth";
private static final String USERNAME = "marissa,ok"; private static final String USERNAME = "rod,ok";
private static final String PASSWORD = "koala"; private static final String PASSWORD = "koala";
private static final String REQUEST_URI = "/some_file.html"; private static final String REQUEST_URI = "/some_file.html";
@ -128,7 +128,7 @@ public class DigestProcessingFilterTests extends MockObjectTestCase {
// Create User Details Service // Create User Details Service
InMemoryDaoImpl dao = new InMemoryDaoImpl(); InMemoryDaoImpl dao = new InMemoryDaoImpl();
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa,ok=koala,ROLE_ONE,ROLE_TWO,enabled\r\n"); editor.setAsText("rod,ok=koala,ROLE_ONE,ROLE_TWO,enabled\r\n");
dao.setUserMap((UserMap) editor.getValue()); dao.setUserMap((UserMap) editor.getValue());
DigestProcessingFilterEntryPoint ep = new DigestProcessingFilterEntryPoint(); DigestProcessingFilterEntryPoint ep = new DigestProcessingFilterEntryPoint();

View File

@ -52,7 +52,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
public void testNormalOperation() throws Exception { public void testNormalOperation() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "marissa"); request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod");
request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala");
AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter(); AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter();
@ -66,7 +66,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
public void testNullPasswordHandledGracefully() throws Exception { public void testNullPasswordHandledGracefully() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "marissa"); request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod");
AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter(); AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter();
filter.setAuthenticationManager(new MockAuthenticationManager(true)); filter.setAuthenticationManager(new MockAuthenticationManager(true));
@ -96,7 +96,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
filter.init(null); filter.init(null);
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("x", "marissa"); request.addParameter("x", "rod");
request.addParameter("y", "koala"); request.addParameter("y", "koala");
Authentication result = filter.attemptAuthentication(request); Authentication result = filter.attemptAuthentication(request);
@ -106,7 +106,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
public void testSpacesAreTrimmedCorrectlyFromUsername() throws Exception { public void testSpacesAreTrimmedCorrectlyFromUsername() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, " marissa "); request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, " rod ");
request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); request.addParameter(AuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala");
AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter(); AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter();
@ -114,6 +114,6 @@ public class AuthenticationProcessingFilterTests extends TestCase {
filter.init(null); filter.init(null);
Authentication result = filter.attemptAuthentication(request); Authentication result = filter.attemptAuthentication(request);
assertEquals("marissa", result.getName()); assertEquals("rod", result.getName());
} }
} }

View File

@ -103,7 +103,7 @@ public class SiteminderAuthenticationProcessingFilterTests extends TestCase {
*/ */
public void testFormNormalOperation() throws Exception { public void testFormNormalOperation() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "marissa"); request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod");
request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala");
MockAuthenticationManager authMgr = new MockAuthenticationManager(true); MockAuthenticationManager authMgr = new MockAuthenticationManager(true);
@ -124,7 +124,7 @@ public class SiteminderAuthenticationProcessingFilterTests extends TestCase {
*/ */
public void testFormNullPasswordHandledGracefully() throws Exception { public void testFormNullPasswordHandledGracefully() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "marissa"); request.addParameter(SiteminderAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod");
MockAuthenticationManager authMgr = new MockAuthenticationManager(true); MockAuthenticationManager authMgr = new MockAuthenticationManager(true);

View File

@ -52,7 +52,7 @@ public class UserTests extends TestCase {
} }
public void testEquals() { public void testEquals() {
User user1 = new User("marissa", "koala", true, true, true, true, User user1 = new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
assertFalse(user1.equals(null)); assertFalse(user1.equals(null));
@ -61,7 +61,7 @@ public class UserTests extends TestCase {
assertTrue(user1.equals(user1)); assertTrue(user1.equals(user1));
assertTrue(user1.equals( assertTrue(user1.equals(
new User("marissa", "koala", true, true, true, true, new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
@ -69,27 +69,27 @@ public class UserTests extends TestCase {
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "DIFFERENT_PASSWORD", true, true, true, true, new User("rod", "DIFFERENT_PASSWORD", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "koala", false, true, true, true, new User("rod", "koala", false, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "koala", true, false, true, true, new User("rod", "koala", true, false, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "koala", true, true, false, true, new User("rod", "koala", true, true, false, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "koala", true, true, true, false, new User("rod", "koala", true, true, true, false,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
assertFalse(user1.equals( assertFalse(user1.equals(
new User("marissa", "koala", true, true, true, true, new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE")}))); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE")})));
} }
@ -114,7 +114,7 @@ public class UserTests extends TestCase {
} }
try { try {
UserDetails user = new User("marissa", null, true, true, true, true, UserDetails user = new User("rod", null, true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
fail("Should have thrown IllegalArgumentException"); fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -122,14 +122,14 @@ public class UserTests extends TestCase {
} }
try { try {
UserDetails user = new User("marissa", "koala", true, true, true, true, null); UserDetails user = new User("rod", "koala", true, true, true, true, null);
fail("Should have thrown IllegalArgumentException"); fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
assertTrue(true); assertTrue(true);
} }
try { try {
UserDetails user = new User("marissa", "koala", true, true, true, true, UserDetails user = new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), null}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), null});
fail("Should have thrown IllegalArgumentException"); fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -152,18 +152,18 @@ public class UserTests extends TestCase {
} }
public void testUserGettersSetter() throws Exception { public void testUserGettersSetter() throws Exception {
UserDetails user = new User("marissa", "koala", true, true, true, true, UserDetails user = new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
assertEquals("marissa", user.getUsername()); assertEquals("rod", user.getUsername());
assertEquals("koala", user.getPassword()); assertEquals("koala", user.getPassword());
assertTrue(user.isEnabled()); assertTrue(user.isEnabled());
assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), user.getAuthorities()[0]); assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), user.getAuthorities()[0]);
assertEquals(new GrantedAuthorityImpl("ROLE_TWO"), user.getAuthorities()[1]); assertEquals(new GrantedAuthorityImpl("ROLE_TWO"), user.getAuthorities()[1]);
assertTrue(user.toString().indexOf("marissa") != -1); assertTrue(user.toString().indexOf("rod") != -1);
} }
public void testUserIsEnabled() throws Exception { public void testUserIsEnabled() throws Exception {
UserDetails user = new User("marissa", "koala", false, true, true, true, UserDetails user = new User("rod", "koala", false, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
assertTrue(!user.isEnabled()); assertTrue(!user.isEnabled());
} }

View File

@ -67,8 +67,8 @@ public class JdbcDaoImplTests extends TestCase {
public void testCheckDaoAccessUserSuccess() throws Exception { public void testCheckDaoAccessUserSuccess() throws Exception {
JdbcDaoImpl dao = makePopulatedJdbcDao(); JdbcDaoImpl dao = makePopulatedJdbcDao();
UserDetails user = dao.loadUserByUsername("marissa"); UserDetails user = dao.loadUserByUsername("rod");
assertEquals("marissa", user.getUsername()); assertEquals("rod", user.getUsername());
assertEquals("koala", user.getPassword()); assertEquals("koala", user.getPassword());
assertTrue(user.isEnabled()); assertTrue(user.isEnabled());
@ -128,7 +128,7 @@ public class JdbcDaoImplTests extends TestCase {
public void testLookupSuccessWithMixedCase() throws Exception { public void testLookupSuccessWithMixedCase() throws Exception {
JdbcDaoImpl dao = makePopulatedJdbcDao(); JdbcDaoImpl dao = makePopulatedJdbcDao();
assertEquals("koala", dao.loadUserByUsername("MaRiSSA").getPassword()); assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword()); assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword());
} }
@ -136,8 +136,8 @@ public class JdbcDaoImplTests extends TestCase {
JdbcDaoImpl dao = makePopulatedJdbcDaoWithRolePrefix(); JdbcDaoImpl dao = makePopulatedJdbcDaoWithRolePrefix();
assertEquals("ARBITRARY_PREFIX_", dao.getRolePrefix()); assertEquals("ARBITRARY_PREFIX_", dao.getRolePrefix());
UserDetails user = dao.loadUserByUsername("marissa"); UserDetails user = dao.loadUserByUsername("rod");
assertEquals("marissa", user.getUsername()); assertEquals("rod", user.getUsername());
assertEquals(2, user.getAuthorities().length); assertEquals(2, user.getAuthorities().length);
HashSet authorities = new HashSet(2); HashSet authorities = new HashSet(2);

View File

@ -50,7 +50,7 @@ public class InMemoryDaoTests extends TestCase {
private UserMap makeUserMap() { private UserMap makeUserMap() {
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa=koala,ROLE_ONE,ROLE_TWO,enabled\r\nscott=wombat,ROLE_ONE,ROLE_TWO,enabled"); editor.setAsText("rod=koala,ROLE_ONE,ROLE_TWO,enabled\r\nscott=wombat,ROLE_ONE,ROLE_TWO,enabled");
return (UserMap) editor.getValue(); return (UserMap) editor.getValue();
} }
@ -76,7 +76,7 @@ public class InMemoryDaoTests extends TestCase {
InMemoryDaoImpl dao = new InMemoryDaoImpl(); InMemoryDaoImpl dao = new InMemoryDaoImpl();
dao.setUserMap(makeUserMap()); dao.setUserMap(makeUserMap());
dao.afterPropertiesSet(); dao.afterPropertiesSet();
assertEquals("koala", dao.loadUserByUsername("marissa").getPassword()); assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
assertEquals("wombat", dao.loadUserByUsername("scott").getPassword()); assertEquals("wombat", dao.loadUserByUsername("scott").getPassword());
} }
@ -84,7 +84,7 @@ public class InMemoryDaoTests extends TestCase {
InMemoryDaoImpl dao = new InMemoryDaoImpl(); InMemoryDaoImpl dao = new InMemoryDaoImpl();
dao.setUserMap(makeUserMap()); dao.setUserMap(makeUserMap());
dao.afterPropertiesSet(); dao.afterPropertiesSet();
assertEquals("koala", dao.loadUserByUsername("MaRiSSA").getPassword()); assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword()); assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword());
} }
@ -121,10 +121,10 @@ public class InMemoryDaoTests extends TestCase {
public void testUseOfExternalPropertiesObject() throws Exception { public void testUseOfExternalPropertiesObject() throws Exception {
InMemoryDaoImpl dao = new InMemoryDaoImpl(); InMemoryDaoImpl dao = new InMemoryDaoImpl();
Properties props = new Properties(); Properties props = new Properties();
props.put("marissa", "koala,ROLE_ONE,ROLE_TWO,enabled"); props.put("rod", "koala,ROLE_ONE,ROLE_TWO,enabled");
props.put("scott", "wombat,ROLE_ONE,ROLE_TWO,enabled"); props.put("scott", "wombat,ROLE_ONE,ROLE_TWO,enabled");
dao.setUserProperties(props); dao.setUserProperties(props);
assertEquals("koala", dao.loadUserByUsername("marissa").getPassword()); assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
assertEquals("wombat", dao.loadUserByUsername("scott").getPassword()); assertEquals("wombat", dao.loadUserByUsername("scott").getPassword());
} }
} }

View File

@ -50,22 +50,22 @@ public class UserMapEditorTests extends TestCase {
public void testConvertedIntoUserSuccessfullyWhenDisabled() { public void testConvertedIntoUserSuccessfullyWhenDisabled() {
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa=koala,ROLE_ONE,ROLE_TWO,disabled"); editor.setAsText("rod=koala,ROLE_ONE,ROLE_TWO,disabled");
UserMap map = (UserMap) editor.getValue(); UserMap map = (UserMap) editor.getValue();
assertTrue(!map.getUser("marissa").isEnabled()); assertTrue(!map.getUser("rod").isEnabled());
} }
public void testConvertedIntoUserSuccessfullyWhenEnabled() { public void testConvertedIntoUserSuccessfullyWhenEnabled() {
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa=koala,ROLE_ONE,ROLE_TWO"); editor.setAsText("rod=koala,ROLE_ONE,ROLE_TWO");
UserMap map = (UserMap) editor.getValue(); UserMap map = (UserMap) editor.getValue();
assertEquals("marissa", map.getUser("marissa").getUsername()); assertEquals("rod", map.getUser("rod").getUsername());
assertEquals("koala", map.getUser("marissa").getPassword()); assertEquals("koala", map.getUser("rod").getPassword());
assertEquals("ROLE_ONE", map.getUser("marissa").getAuthorities()[0].getAuthority()); assertEquals("ROLE_ONE", map.getUser("rod").getAuthorities()[0].getAuthority());
assertEquals("ROLE_TWO", map.getUser("marissa").getAuthorities()[1].getAuthority()); assertEquals("ROLE_TWO", map.getUser("rod").getAuthorities()[1].getAuthority());
assertTrue(map.getUser("marissa").isEnabled()); assertTrue(map.getUser("rod").isEnabled());
} }
public void testEmptyStringReturnsEmptyMap() { public void testEmptyStringReturnsEmptyMap() {
@ -86,10 +86,10 @@ public class UserMapEditorTests extends TestCase {
public void testMultiUserParsing() { public void testMultiUserParsing() {
UserMapEditor editor = new UserMapEditor(); UserMapEditor editor = new UserMapEditor();
editor.setAsText("marissa=koala,ROLE_ONE,ROLE_TWO,enabled\r\nscott=wombat,ROLE_ONE,ROLE_TWO,enabled"); editor.setAsText("rod=koala,ROLE_ONE,ROLE_TWO,enabled\r\nscott=wombat,ROLE_ONE,ROLE_TWO,enabled");
UserMap map = (UserMap) editor.getValue(); UserMap map = (UserMap) editor.getValue();
assertEquals("marissa", map.getUser("marissa").getUsername()); assertEquals("rod", map.getUser("rod").getUsername());
assertEquals("scott", map.getUser("scott").getUsername()); assertEquals("scott", map.getUser("scott").getUsername());
} }

View File

@ -54,19 +54,19 @@ public class UserMapTests extends TestCase {
} }
public void testAddAndRetrieveUser() { public void testAddAndRetrieveUser() {
UserDetails marissa = new User("marissa", "koala", true, true, true, true, UserDetails rod = new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
UserDetails scott = new User("scott", "wombat", true, true, true, true, UserDetails scott = new User("scott", "wombat", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_THREE")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_THREE")});
UserDetails peter = new User("peter", "opal", true, true, true, true, UserDetails peter = new User("peter", "opal", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_FOUR")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_FOUR")});
UserMap map = new UserMap(); UserMap map = new UserMap();
map.addUser(marissa); map.addUser(rod);
map.addUser(scott); map.addUser(scott);
map.addUser(peter); map.addUser(peter);
assertEquals(3, map.getUserCount()); assertEquals(3, map.getUserCount());
assertEquals(marissa, map.getUser("marissa")); assertEquals(rod, map.getUser("rod"));
assertEquals(scott, map.getUser("scott")); assertEquals(scott, map.getUser("scott"));
assertEquals(peter, map.getUser("peter")); assertEquals(peter, map.getUser("peter"));
} }
@ -84,11 +84,11 @@ public class UserMapTests extends TestCase {
} }
public void testUnknownUserIsNotRetrieved() { public void testUnknownUserIsNotRetrieved() {
UserDetails marissa = new User("marissa", "koala", true, true, true, true, UserDetails rod = new User("rod", "koala", true, true, true, true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
UserMap map = new UserMap(); UserMap map = new UserMap();
assertEquals(0, map.getUserCount()); assertEquals(0, map.getUserCount());
map.addUser(marissa); map.addUser(rod);
assertEquals(1, map.getUserCount()); assertEquals(1, map.getUserCount());
try { try {

View File

@ -51,11 +51,11 @@ public class StringSplitUtilsTests extends TestCase {
public void testSplitEachArrayElementAndCreateMapNormalOperation() { public void testSplitEachArrayElementAndCreateMapNormalOperation() {
// note it ignores malformed entries (ie those without an equals sign) // note it ignores malformed entries (ie those without an equals sign)
String unsplit = "username=\"marissa\", invalidEntryThatHasNoEqualsSign, realm=\"Contacts Realm\", nonce=\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\", uri=\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\", response=\"38644211cf9ac3da63ab639807e2baff\", qop=auth, nc=00000004, cnonce=\"2b8d329a8571b99a\""; String unsplit = "username=\"rod\", invalidEntryThatHasNoEqualsSign, realm=\"Contacts Realm\", nonce=\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\", uri=\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\", response=\"38644211cf9ac3da63ab639807e2baff\", qop=auth, nc=00000004, cnonce=\"2b8d329a8571b99a\"";
String[] headerEntries = StringUtils.commaDelimitedListToStringArray(unsplit); String[] headerEntries = StringUtils.commaDelimitedListToStringArray(unsplit);
Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", "\""); Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", "\"");
assertEquals("marissa", headerMap.get("username")); assertEquals("rod", headerMap.get("username"));
assertEquals("Contacts Realm", headerMap.get("realm")); assertEquals("Contacts Realm", headerMap.get("realm"));
assertEquals("MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==", headerMap.get("nonce")); assertEquals("MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==", headerMap.get("nonce"));
assertEquals("/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4", assertEquals("/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4",
@ -68,11 +68,11 @@ public class StringSplitUtilsTests extends TestCase {
} }
public void testSplitEachArrayElementAndCreateMapRespectsInstructionNotToRemoveCharacters() { public void testSplitEachArrayElementAndCreateMapRespectsInstructionNotToRemoveCharacters() {
String unsplit = "username=\"marissa\", realm=\"Contacts Realm\", nonce=\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\", uri=\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\", response=\"38644211cf9ac3da63ab639807e2baff\", qop=auth, nc=00000004, cnonce=\"2b8d329a8571b99a\""; String unsplit = "username=\"rod\", realm=\"Contacts Realm\", nonce=\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\", uri=\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\", response=\"38644211cf9ac3da63ab639807e2baff\", qop=auth, nc=00000004, cnonce=\"2b8d329a8571b99a\"";
String[] headerEntries = StringUtils.commaDelimitedListToStringArray(unsplit); String[] headerEntries = StringUtils.commaDelimitedListToStringArray(unsplit);
Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", null); Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", null);
assertEquals("\"marissa\"", headerMap.get("username")); assertEquals("\"rod\"", headerMap.get("username"));
assertEquals("\"Contacts Realm\"", headerMap.get("realm")); assertEquals("\"Contacts Realm\"", headerMap.get("realm"));
assertEquals("\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\"", headerMap.get("nonce")); assertEquals("\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\"", headerMap.get("nonce"));
assertEquals("\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\"", assertEquals("\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\"",
@ -90,9 +90,9 @@ public class StringSplitUtilsTests extends TestCase {
} }
public void testSplitNormalOperation() { public void testSplitNormalOperation() {
String unsplit = "username=\"marissa==\""; String unsplit = "username=\"rod==\"";
assertEquals("username", StringSplitUtils.split(unsplit, "=")[0]); assertEquals("username", StringSplitUtils.split(unsplit, "=")[0]);
assertEquals("\"marissa==\"", StringSplitUtils.split(unsplit, "=")[1]); // should not remove quotes or extra equals assertEquals("\"rod==\"", StringSplitUtils.split(unsplit, "=")[1]); // should not remove quotes or extra equals
} }
public void testSplitRejectsNullsAndIncorrectLengthStrings() { public void testSplitRejectsNullsAndIncorrectLengthStrings() {
@ -133,11 +133,11 @@ public class StringSplitUtilsTests extends TestCase {
} }
public void testSplitWorksWithDifferentDelimiters() { public void testSplitWorksWithDifferentDelimiters() {
assertEquals(2, StringSplitUtils.split("18/marissa", "/").length); assertEquals(2, StringSplitUtils.split("18/rod", "/").length);
assertNull(StringSplitUtils.split("18/marissa", "!")); assertNull(StringSplitUtils.split("18/rod", "!"));
// only guarantees to split at FIRST delimiter, not EACH delimiter // only guarantees to split at FIRST delimiter, not EACH delimiter
assertEquals(2, StringSplitUtils.split("18|marissa|foo|bar", "|").length); assertEquals(2, StringSplitUtils.split("18|rod|foo|bar", "|").length);
} }

View File

@ -72,12 +72,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject, "marissa", AclManager aclManager = new MockAclManager(domainObject, "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -100,7 +100,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, assertEquals(AccessDecisionVoter.ACCESS_GRANTED,
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
} }
public void testOnlySupportsMethodInvocationAndJoinPoint() { public void testOnlySupportsMethodInvocationAndJoinPoint() {
@ -111,12 +111,12 @@ public class BasicAclEntryVoterTests extends TestCase {
} }
public void testStartupRejectsMissingAclManager() throws Exception { public void testStartupRejectsMissingAclManager() throws Exception {
AclManager aclManager = new MockAclManager("domain1", "marissa", AclManager aclManager = new MockAclManager("domain1", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -135,12 +135,12 @@ public class BasicAclEntryVoterTests extends TestCase {
public void testStartupRejectsMissingProcessConfigAttribute() public void testStartupRejectsMissingProcessConfigAttribute()
throws Exception { throws Exception {
AclManager aclManager = new MockAclManager("domain1", "marissa", AclManager aclManager = new MockAclManager("domain1", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -171,12 +171,12 @@ public class BasicAclEntryVoterTests extends TestCase {
public void testStartupRejectsMissingRequirePermission() public void testStartupRejectsMissingRequirePermission()
throws Exception { throws Exception {
AclManager aclManager = new MockAclManager("domain1", "marissa", AclManager aclManager = new MockAclManager("domain1", "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -205,12 +205,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject, "marissa", AclManager aclManager = new MockAclManager(domainObject, "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -229,7 +229,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN, assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN,
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
} }
public void testVoterAbstainsIfNotMatchingConfigAttribute() public void testVoterAbstainsIfNotMatchingConfigAttribute()
@ -238,12 +238,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = null; SomeDomainObject domainObject = null;
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject, "marissa", AclManager aclManager = new MockAclManager(domainObject, "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -262,7 +262,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN, assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN,
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
} }
public void testVoterCanDenyAccessBasedOnInternalMethodOfDomainObject() public void testVoterCanDenyAccessBasedOnInternalMethodOfDomainObject()
@ -271,10 +271,10 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa", AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -294,7 +294,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
assertEquals(AccessDecisionVoter.ACCESS_DENIED, assertEquals(AccessDecisionVoter.ACCESS_DENIED,
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
} }
public void testVoterCanDenyAccessIfPrincipalHasNoPermissionsAtAllToDomainObject() public void testVoterCanDenyAccessIfPrincipalHasNoPermissionsAtAllToDomainObject()
@ -303,10 +303,10 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject, "marissa", AclManager aclManager = new MockAclManager(domainObject, "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -325,7 +325,7 @@ public class BasicAclEntryVoterTests extends TestCase {
// Setup a MockMethodInvocation, so voter can retrieve domainObject // Setup a MockMethodInvocation, so voter can retrieve domainObject
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
// NB: scott is the principal, not marissa // NB: scott is the principal, not rod
assertEquals(AccessDecisionVoter.ACCESS_DENIED, assertEquals(AccessDecisionVoter.ACCESS_DENIED,
voter.vote(new UsernamePasswordAuthenticationToken("scott", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("scott", null), mi, attr));
} }
@ -336,12 +336,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa", AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -363,7 +363,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, assertEquals(AccessDecisionVoter.ACCESS_GRANTED,
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr)); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
} }
public void testVoterThrowsExceptionIfInvalidInternalMethodOfDomainObject() public void testVoterThrowsExceptionIfInvalidInternalMethodOfDomainObject()
@ -372,12 +372,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa", AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -398,7 +398,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = getMethodInvocation(domainObject); MethodInvocation mi = getMethodInvocation(domainObject);
try { try {
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr);
fail("Should have thrown AuthorizationServiceException"); fail("Should have thrown AuthorizationServiceException");
} catch (AuthorizationServiceException expected) { } catch (AuthorizationServiceException expected) {
assertTrue(true); assertTrue(true);
@ -411,12 +411,12 @@ public class BasicAclEntryVoterTests extends TestCase {
SomeDomainObject domainObject = new SomeDomainObject("foo"); SomeDomainObject domainObject = new SomeDomainObject("foo");
// Setup an AclManager // Setup an AclManager
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa", AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
new AclEntry[] { new AclEntry[] {
new MockAclEntry(), new MockAclEntry(),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ), new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE) new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
}); });
// Wire up a voter // Wire up a voter
@ -438,7 +438,7 @@ public class BasicAclEntryVoterTests extends TestCase {
MethodInvocation mi = new SimpleMethodInvocation(method, new Object[] {domainObject}); MethodInvocation mi = new SimpleMethodInvocation(method, new Object[] {domainObject});
try { try {
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr); voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr);
fail("Should have thrown AuthorizationServiceException"); fail("Should have thrown AuthorizationServiceException");
} catch (AuthorizationServiceException expected) { } catch (AuthorizationServiceException expected) {
assertTrue(true); assertTrue(true);

View File

@ -51,7 +51,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
} }
public void testCorrectOperationWithStringBasedPrincipal() throws Exception { public void testCorrectOperationWithStringBasedPrincipal() throws Exception {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", Authentication auth = new TestingAuthenticationToken("rod", "koala",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
@ -60,14 +60,14 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), ""); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), "");
assertEquals("marissa", wrapper.getRemoteUser()); assertEquals("rod", wrapper.getRemoteUser());
assertTrue(wrapper.isUserInRole("ROLE_FOO")); assertTrue(wrapper.isUserInRole("ROLE_FOO"));
assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED")); assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED"));
assertEquals(auth, wrapper.getUserPrincipal()); assertEquals(auth, wrapper.getUserPrincipal());
} }
public void testUseOfRolePrefixMeansItIsntNeededWhenCallngIsUserInRole() { public void testUseOfRolePrefixMeansItIsntNeededWhenCallngIsUserInRole() {
Authentication auth = new TestingAuthenticationToken("marissa", "koala", Authentication auth = new TestingAuthenticationToken("rod", "koala",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
@ -80,7 +80,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
} }
public void testCorrectOperationWithUserDetailsBasedPrincipal() throws Exception { public void testCorrectOperationWithUserDetailsBasedPrincipal() throws Exception {
Authentication auth = new TestingAuthenticationToken(new User("marissaAsUserDetails", "koala", true, true, Authentication auth = new TestingAuthenticationToken(new User("rodAsUserDetails", "koala", true, true,
true, true, new GrantedAuthority[] {}), "koala", true, true, new GrantedAuthority[] {}), "koala",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_HELLO"), new GrantedAuthorityImpl("ROLE_FOOBAR")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_HELLO"), new GrantedAuthorityImpl("ROLE_FOOBAR")});
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
@ -90,7 +90,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), ""); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), "");
assertEquals("marissaAsUserDetails", wrapper.getRemoteUser()); assertEquals("rodAsUserDetails", wrapper.getRemoteUser());
assertFalse(wrapper.isUserInRole("ROLE_FOO")); assertFalse(wrapper.isUserInRole("ROLE_FOO"));
assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED")); assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED"));
assertTrue(wrapper.isUserInRole("ROLE_FOOBAR")); assertTrue(wrapper.isUserInRole("ROLE_FOOBAR"));

View File

@ -25,7 +25,7 @@
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap"> <property name="userMap">
<value> <value>
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
dianne=emu,ROLE_TELLER dianne=emu,ROLE_TELLER
scott=wombat,ROLE_TELLER scott=wombat,ROLE_TELLER
peter=opal,disabled,ROLE_TELLER peter=opal,disabled,ROLE_TELLER

View File

@ -3,8 +3,8 @@ This directory contains some example certificates for the X.509 version of the c
application. They have all been generated using openssl with a demo certificate authority. application. They have all been generated using openssl with a demo certificate authority.
The password for all the files is "password" The password for all the files is "password"
- marissa.p12 is a pkcs12 file containing the client certificate and private key for - user.p12 is a pkcs12 file containing the client certificate and private key for
the user marissa, and should be imported into your browser. a user, and should be imported into your browser.
- server.p12 is a pkcs12 file containing a server certificate and private key. - server.p12 is a pkcs12 file containing a server certificate and private key.
@ -30,7 +30,7 @@ To try out the application, first get the server running with client authenticat
[1] This was origially also a pkcs12 file. However I couldn't get tomcat to work with [1] This was originally also a pkcs12 file. However I couldn't get tomcat to work with
it unless it contained the CA's private key as well as the certificate, which is obviously it unless it contained the CA's private key as well as the certificate, which is obviously
not feasible. If anyone works out how to get Tomcat to work with a pkcs12 file containing not feasible. If anyone works out how to get Tomcat to work with a pkcs12 file containing
a single certificate, then please let me know. a single certificate, then please let me know.

View File

@ -129,9 +129,9 @@ public class ClientApplication {
if ("".equals(username) || "".equals(password)) { if ("".equals(username) || "".equals(password)) {
System.out.println( System.out.println(
"You need to specify the user ID to use, the password to use, and optionally a number of calls " "You need to specify the user ID to use, the password to use, and optionally a number of calls "
+ "using the username, password, and nrOfCalls system properties respectively. eg for user marissa, " + "using the username, password, and nrOfCalls system properties respectively. eg for user rod, "
+ "use: -Dusername=marissa -Dpassword=koala' for a single call per service and " + "use: -Dusername=rod -Dpassword=koala' for a single call per service and "
+ "use: -Dusername=marissa -Dpassword=koala -DnrOfCalls=10 for ten calls per service."); + "use: -Dusername=rod -Dpassword=koala -DnrOfCalls=10 for ten calls per service.");
System.exit(-1); System.exit(-1);
} else { } else {
int nrOfCalls = 1; int nrOfCalls = 1;

View File

@ -80,7 +80,7 @@ public class DataSourcePopulator implements InitializingBean {
Assert.notNull(tt, "platformTransactionManager required"); Assert.notNull(tt, "platformTransactionManager required");
// Set a user account that will initially own all the created data // Set a user account that will initially own all the created data
Authentication authRequest = new UsernamePasswordAuthenticationToken("marissa", "koala", Authentication authRequest = new UsernamePasswordAuthenticationToken("rod", "koala",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_IGNORED")}); new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_IGNORED")});
SecurityContextHolder.getContext().setAuthentication(authRequest); SecurityContextHolder.getContext().setAuthentication(authRequest);
@ -104,7 +104,7 @@ public class DataSourcePopulator implements InitializingBean {
/* /*
Passwords encoded using MD5, NOT in Base64 format, with null as salt Passwords encoded using MD5, NOT in Base64 format, with null as salt
Encoded password for marissa is "koala" Encoded password for rod is "koala"
Encoded password for dianne is "emu" Encoded password for dianne is "emu"
Encoded password for scott is "wombat" Encoded password for scott is "wombat"
Encoded password for peter is "opal" (but user is disabled) Encoded password for peter is "opal" (but user is disabled)
@ -113,15 +113,15 @@ public class DataSourcePopulator implements InitializingBean {
Encoded password for jane is "wombat" Encoded password for jane is "wombat"
*/ */
template.execute("INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);"); template.execute("INSERT INTO USERS VALUES('rod','a564de63c2d0da68cf47586ee05984d7',TRUE);");
template.execute("INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);"); template.execute("INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
template.execute("INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);"); template.execute("INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);"); template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
template.execute("INSERT INTO USERS VALUES('bill','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);"); template.execute("INSERT INTO USERS VALUES('bill','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
template.execute("INSERT INTO USERS VALUES('bob','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);"); template.execute("INSERT INTO USERS VALUES('bob','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
template.execute("INSERT INTO USERS VALUES('jane','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);"); template.execute("INSERT INTO USERS VALUES('jane','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');"); template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_USER');");
template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');"); template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR');");
template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');"); template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');"); template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');"); template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
@ -158,12 +158,12 @@ public class DataSourcePopulator implements InitializingBean {
} }
// Now grant some permissions // Now grant some permissions
grantPermissions(1, "marissa", BasePermission.ADMINISTRATION); grantPermissions(1, "rod", BasePermission.ADMINISTRATION);
grantPermissions(2, "marissa", BasePermission.READ); grantPermissions(2, "rod", BasePermission.READ);
grantPermissions(3, "marissa", BasePermission.READ); grantPermissions(3, "rod", BasePermission.READ);
grantPermissions(3, "marissa", BasePermission.WRITE); grantPermissions(3, "rod", BasePermission.WRITE);
grantPermissions(3, "marissa", BasePermission.DELETE); grantPermissions(3, "rod", BasePermission.DELETE);
grantPermissions(4, "marissa", BasePermission.ADMINISTRATION); grantPermissions(4, "rod", BasePermission.ADMINISTRATION);
grantPermissions(4, "dianne", BasePermission.ADMINISTRATION); grantPermissions(4, "dianne", BasePermission.ADMINISTRATION);
grantPermissions(4, "scott", BasePermission.READ); grantPermissions(4, "scott", BasePermission.READ);
grantPermissions(5, "dianne", BasePermission.ADMINISTRATION); grantPermissions(5, "dianne", BasePermission.ADMINISTRATION);
@ -182,7 +182,7 @@ public class DataSourcePopulator implements InitializingBean {
grantPermissions(9, "scott", BasePermission.DELETE); grantPermissions(9, "scott", BasePermission.DELETE);
// Now expressly change the owner of the first ten contacts // Now expressly change the owner of the first ten contacts
// We have to do this last, because "marissa" owns all of them (doing it sooner would prevent ACL updates) // We have to do this last, because "rod" owns all of them (doing it sooner would prevent ACL updates)
// Note that ownership has no impact on permissions - they're separate (ownership only allows ACl editing) // Note that ownership has no impact on permissions - they're separate (ownership only allows ACl editing)
changeOwner(5, "dianne"); changeOwner(5, "dianne");
changeOwner(6, "dianne"); changeOwner(6, "dianne");

View File

@ -201,7 +201,7 @@
<!-- Filter used to switch the user context. Note: the switch and exit url must be secured <!-- Filter used to switch the user context. Note: the switch and exit url must be secured
based on the role granted the ability to 'switch' to another user --> based on the role granted the ability to 'switch' to another user -->
<!-- In this example 'marissa' has ROLE_SUPERVISOR that can switch to regular ROLE_USER(s) --> <!-- In this example 'rod' has ROLE_SUPERVISOR that can switch to regular ROLE_USER(s) -->
<bean id="switchUserProcessingFilter" class="org.springframework.security.ui.switchuser.SwitchUserProcessingFilter"> <bean id="switchUserProcessingFilter" class="org.springframework.security.ui.switchuser.SwitchUserProcessingFilter">
<property name="userDetailsService" ref="jdbcDaoImpl" /> <property name="userDetailsService" ref="jdbcDaoImpl" />
<property name="switchUserUrl"><value>/j_spring_security_switch_user</value></property> <property name="switchUserUrl"><value>/j_spring_security_switch_user</value></property>

View File

@ -13,7 +13,7 @@
<P>Valid users: <P>Valid users:
<P> <P>
<P>username <b>marissa</b>, password <b>koala</b> <P>username <b>rod</b>, password <b>koala</b>
<P>username <b>dianne</b>, password <b>emu</b> <P>username <b>dianne</b>, password <b>emu</b>
<p>username <b>scott</b>, password <b>wombat</b> <p>username <b>scott</b>, password <b>wombat</b>
<p>username <b>peter</b>, password <b>opal</b> (user disabled) <p>username <b>peter</b>, password <b>opal</b> (user disabled)

View File

@ -12,7 +12,7 @@
<P>Valid users: <P>Valid users:
<P> <P>
<P>username <b>marissa</b>, password <b>koala</b> <P>username <b>rod</b>, password <b>koala</b>
<P>username <b>dianne</b>, password <b>emu</b> <P>username <b>dianne</b>, password <b>emu</b>
<p>username <b>scott</b>, password <b>wombat</b> <p>username <b>scott</b>, password <b>wombat</b>
<p>username <b>bill</b>, password <b>wombat</b> <p>username <b>bill</b>, password <b>wombat</b>

View File

@ -110,7 +110,7 @@ public class GetAllContactsTests extends AbstractTransactionalSpringContextTests
protected void makeActiveUser(String username) { protected void makeActiveUser(String username) {
String password = ""; String password = "";
if ("marissa".equals(username)) { if ("rod".equals(username)) {
password = "koala"; password = "koala";
} else if ("dianne".equals(username)) { } else if ("dianne".equals(username)) {
password = "emu"; password = "emu";
@ -148,8 +148,8 @@ public class GetAllContactsTests extends AbstractTransactionalSpringContextTests
assertNotContainsContact(Long.toString(3), contacts); assertNotContainsContact(Long.toString(3), contacts);
} }
public void testMarissa() { public void testrod() {
makeActiveUser("marissa"); // has ROLE_SUPERVISOR makeActiveUser("rod"); // has ROLE_SUPERVISOR
List contacts = contactManager.getAll(); List contacts = contactManager.getAll();

View File

@ -1,4 +1,4 @@
marissa=koala,ROLE_SUPERVISOR rod=koala,ROLE_SUPERVISOR
dianne=emu,ROLE_USER dianne=emu,ROLE_USER
scott=wombat,ROLE_USER scott=wombat,ROLE_USER
peter=opal,disabled,ROLE_USER peter=opal,disabled,ROLE_USER

View File

@ -13,7 +13,7 @@
<P>Valid users: <P>Valid users:
<P> <P>
<P>username <b>marissa</b>, password <b>koala</b> (supervisor) <P>username <b>rod</b>, password <b>koala</b> (supervisor)
<P>username <b>dianne</b>, password <b>emu</b> (normal user) <P>username <b>dianne</b>, password <b>emu</b> (normal user)
<p>username <b>scott</b>, password <b>wombat</b> (normal user) <p>username <b>scott</b>, password <b>wombat</b> (normal user)
<p>username <b>peter</b>, password <b>opal</b> (user disabled) <p>username <b>peter</b>, password <b>opal</b> (user disabled)