Make samples and tests use username "rod".
This commit is contained in:
parent
3123d24337
commit
47229be5cb
|
@ -27,7 +27,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLES_IGNORED_BY_CAS
|
||||
rod=koala,ROLES_IGNORED_BY_CAS
|
||||
dianne=emu,ROLES_IGNORED_BY_CAS
|
||||
scott=wombat,ROLES_IGNORED_BY_CAS
|
||||
peter=opal,disabled,ROLES_IGNORED_BY_CAS
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLES_IGNORED_BY_CAS
|
||||
rod=koala,ROLES_IGNORED_BY_CAS
|
||||
dianne=emu,ROLES_IGNORED_BY_CAS
|
||||
scott=wombat,ROLES_IGNORED_BY_CAS
|
||||
peter=opal,disabled,ROLES_IGNORED_BY_CAS
|
||||
|
|
|
@ -79,8 +79,8 @@ public class CasPasswordHandlerProxyTests extends TestCase {
|
|||
public void testNormalOperation() {
|
||||
CasPasswordHandlerProxy proxy = new MockCasPasswordHandlerProxy(
|
||||
"org/springframework/security/adapters/cas/applicationContext-valid.xml");
|
||||
assertTrue(proxy.authenticate(new MockHttpServletRequest(), "marissa", "koala"));
|
||||
assertFalse(proxy.authenticate(new MockHttpServletRequest(), "marissa", "WRONG_PASSWORD"));
|
||||
assertTrue(proxy.authenticate(new MockHttpServletRequest(), "rod", "koala"));
|
||||
assertFalse(proxy.authenticate(new MockHttpServletRequest(), "rod", "WRONG_PASSWORD"));
|
||||
assertFalse(proxy.authenticate(new MockHttpServletRequest(), "INVALID_USER_NAME", "WRONG_PASSWORD"));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -175,7 +175,7 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
|
|||
public void testAuthenticationFailsForIncorrectPassword()
|
||||
throws Exception {
|
||||
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
|
||||
assertEquals(null, adapter.authenticate("marissa", "kangaroo"));
|
||||
assertEquals(null, adapter.authenticate("rod", "kangaroo"));
|
||||
}
|
||||
|
||||
public void testAuthenticationFailsForIncorrectUserName()
|
||||
|
@ -188,14 +188,14 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
|
|||
throws Exception {
|
||||
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
|
||||
byte[] credentials = {'k', 'o', 'a', 'l', 'a'};
|
||||
Principal result = adapter.authenticate("marissa", credentials);
|
||||
Principal result = adapter.authenticate("rod", credentials);
|
||||
|
||||
if (!(result instanceof PrincipalSpringSecurityUserToken)) {
|
||||
fail("Should have returned PrincipalSpringSecurityUserToken");
|
||||
}
|
||||
|
||||
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
|
||||
|
@ -205,14 +205,14 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
|
|||
public void testAuthenticationUsingStringForCredentials()
|
||||
throws Exception {
|
||||
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
|
||||
Principal result = adapter.authenticate("marissa", "koala");
|
||||
Principal result = adapter.authenticate("rod", "koala");
|
||||
|
||||
if (!(result instanceof PrincipalSpringSecurityUserToken)) {
|
||||
fail("Should have returned PrincipalSpringSecurityUserToken");
|
||||
}
|
||||
|
||||
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
|
||||
|
@ -222,7 +222,7 @@ public class CatalinaSpringSecurityUserRealmTests extends TestCase {
|
|||
public void testAuthenticationWithNullPasswordHandledGracefully()
|
||||
throws Exception {
|
||||
CatalinaSpringSecurityUserRealm adapter = makeAdapter("catalinaAdapterTest-valid.xml");
|
||||
assertEquals(null, adapter.authenticate("marissa", (String) null));
|
||||
assertEquals(null, adapter.authenticate("rod", (String) null));
|
||||
}
|
||||
|
||||
public void testAuthenticationWithNullUserNameHandledGracefully()
|
||||
|
|
|
@ -187,7 +187,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
|
|||
props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
|
||||
|
||||
Subject subject = new Subject();
|
||||
CallbackHandler callback = new MockCallbackHandler("marissa", "kangaroo");
|
||||
CallbackHandler callback = new MockCallbackHandler("rod", "kangaroo");
|
||||
|
||||
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");
|
||||
|
||||
Subject subject = new Subject();
|
||||
CallbackHandler callback = new MockCallbackHandler("marissa", "koala");
|
||||
CallbackHandler callback = new MockCallbackHandler("rod", "koala");
|
||||
|
||||
adapter.initialize(subject, callback, null, props);
|
||||
assertTrue(adapter.login());
|
||||
|
@ -238,7 +238,7 @@ public class JbossSpringSecurityLoginModuleTests extends TestCase {
|
|||
}
|
||||
|
||||
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].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");
|
||||
|
||||
Subject subject = new Subject();
|
||||
CallbackHandler callback = new MockCallbackHandler("marissa", null);
|
||||
CallbackHandler callback = new MockCallbackHandler("rod", null);
|
||||
|
||||
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");
|
||||
|
||||
Subject subject = new Subject();
|
||||
CallbackHandler callback = new MockCallbackHandler("marissa", "koala");
|
||||
CallbackHandler callback = new MockCallbackHandler("rod", "koala");
|
||||
|
||||
adapter.initialize(subject, callback, null, props);
|
||||
assertTrue(adapter.login());
|
||||
|
|
|
@ -144,7 +144,7 @@ public class JettyAcegiUserRealmTests extends TestCase {
|
|||
public void testAuthenticationFailsForIncorrectPassword()
|
||||
throws Exception {
|
||||
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
|
||||
assertEquals(null, adapter.authenticate("marissa", "kangaroo", null));
|
||||
assertEquals(null, adapter.authenticate("rod", "kangaroo", null));
|
||||
}
|
||||
|
||||
public void testAuthenticationFailsForIncorrectUserName()
|
||||
|
@ -155,14 +155,14 @@ public class JettyAcegiUserRealmTests extends TestCase {
|
|||
|
||||
public void testAuthenticationSuccess() throws Exception {
|
||||
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
|
||||
UserPrincipal result = adapter.authenticate("marissa", "koala", null);
|
||||
UserPrincipal result = adapter.authenticate("rod", "koala", null);
|
||||
|
||||
if (!(result instanceof JettySpringSecurityUserToken)) {
|
||||
fail("Should have returned JettySpringSecurityUserToken");
|
||||
}
|
||||
|
||||
JettySpringSecurityUserToken castResult = (JettySpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
|
||||
|
@ -172,7 +172,7 @@ public class JettyAcegiUserRealmTests extends TestCase {
|
|||
public void testAuthenticationWithNullPasswordHandledGracefully()
|
||||
throws Exception {
|
||||
JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
|
||||
assertEquals(null, adapter.authenticate("marissa", null, null));
|
||||
assertEquals(null, adapter.authenticate("rod", null, null));
|
||||
}
|
||||
|
||||
public void testAuthenticationWithNullUserNameHandledGracefully()
|
||||
|
|
|
@ -144,7 +144,7 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
|
|||
adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml");
|
||||
adapter.setKey(ADAPTER_KEY);
|
||||
adapter.init();
|
||||
assertEquals(null, adapter.loginImpl("marissa", "kangaroo"));
|
||||
assertEquals(null, adapter.loginImpl("rod", "kangaroo"));
|
||||
}
|
||||
|
||||
public void testAuthenticationFailsForIncorrectUserName()
|
||||
|
@ -162,14 +162,14 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
|
|||
adapter.setKey(ADAPTER_KEY);
|
||||
adapter.init();
|
||||
|
||||
Principal result = adapter.loginImpl("marissa", "koala");
|
||||
Principal result = adapter.loginImpl("rod", "koala");
|
||||
|
||||
if (!(result instanceof PrincipalSpringSecurityUserToken)) {
|
||||
fail("Should have returned PrincipalSpringSecurityUserToken");
|
||||
}
|
||||
|
||||
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[1].getAuthority());
|
||||
|
@ -183,14 +183,14 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
|
|||
adapter.setKey(ADAPTER_KEY);
|
||||
adapter.init();
|
||||
|
||||
Principal result = adapter.loginImpl(null, null, null, "marissa", "koala");
|
||||
Principal result = adapter.loginImpl(null, null, null, "rod", "koala");
|
||||
|
||||
if (!(result instanceof PrincipalSpringSecurityUserToken)) {
|
||||
fail("Should have returned PrincipalSpringSecurityUserToken");
|
||||
}
|
||||
|
||||
PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
assertEquals("koala", castResult.getCredentials());
|
||||
assertEquals("ROLE_TELLER", castResult.getAuthorities()[0].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.setKey(ADAPTER_KEY);
|
||||
adapter.init();
|
||||
assertEquals(null, adapter.loginImpl("marissa", null));
|
||||
assertEquals(null, adapter.loginImpl("rod", null));
|
||||
}
|
||||
|
||||
public void testAuthenticationWithNullUserNameHandledGracefully()
|
||||
|
|
|
@ -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
|
||||
* <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
|
||||
* "ben" and "marissa" as members:
|
||||
* "ben" and "luke" as members:
|
||||
* <pre>
|
||||
* dn: ou=groups,dc=springframework,dc=org
|
||||
* objectClass: top
|
||||
|
@ -53,7 +53,7 @@ import java.util.Set;
|
|||
* cn: developers
|
||||
* description: Spring Security Developers
|
||||
* 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
|
||||
* </pre>
|
||||
* </p>
|
||||
|
|
|
@ -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 (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 (6, 'scott', 1);
|
||||
|
|
|
@ -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 (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 (6, 'scott', 1);
|
||||
|
|
|
@ -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 (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 (6, 'scott', 1);
|
||||
|
|
|
@ -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 (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 (6, 'scott', 1);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -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))");
|
||||
template.execute("SET IGNORECASE 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('scott','wombat',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('marissa','ROLE_SUPERVISOR')");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_TELLER')");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR')");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_TELLER')");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('scott','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 -----
|
||||
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, '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, 6, 'scott', 1);");
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class AclProviderManagerTests extends TestCase {
|
|||
|
||||
public void testAclLookupForGivenAuthenticationSuccess() {
|
||||
AclProviderManager mgr = makeProviderManager();
|
||||
assertNotNull(mgr.getAcls("STRING", new UsernamePasswordAuthenticationToken("marissa", "not used")));
|
||||
assertNotNull(mgr.getAcls("STRING", new UsernamePasswordAuthenticationToken("rod", "not used")));
|
||||
}
|
||||
|
||||
public void testAclLookupSuccess() {
|
||||
|
@ -94,7 +94,7 @@ public class AclProviderManagerTests extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
mgr.getAcls(null, new UsernamePasswordAuthenticationToken("marissa", "not used"));
|
||||
mgr.getAcls(null, new UsernamePasswordAuthenticationToken("rod", "not used"));
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
assertTrue(true);
|
||||
|
@ -110,7 +110,7 @@ public class AclProviderManagerTests extends TestCase {
|
|||
|
||||
public void testReturnsNullIfNoSupportingProvider() {
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -162,10 +162,10 @@ public class AclProviderManagerTests extends TestCase {
|
|||
//~ Inner Classes ==================================================================================================
|
||||
|
||||
private class MockProvider implements AclProvider {
|
||||
private UsernamePasswordAuthenticationToken marissa = new UsernamePasswordAuthenticationToken("marissa",
|
||||
private UsernamePasswordAuthenticationToken rod = new UsernamePasswordAuthenticationToken("rod",
|
||||
"not used",
|
||||
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);
|
||||
private UsernamePasswordAuthenticationToken scott = new UsernamePasswordAuthenticationToken("scott",
|
||||
"not used",
|
||||
|
@ -181,15 +181,15 @@ public class AclProviderManagerTests extends TestCase {
|
|||
return new AclEntry[] {entry100Scott};
|
||||
}
|
||||
|
||||
if (authentication.getPrincipal().equals(marissa.getPrincipal())) {
|
||||
return new AclEntry[] {entry100Marissa};
|
||||
if (authentication.getPrincipal().equals(rod.getPrincipal())) {
|
||||
return new AclEntry[] {entry100rod};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public AclEntry[] getAcls(Object domainInstance) {
|
||||
return new AclEntry[] {entry100Marissa, entry100Scott};
|
||||
return new AclEntry[] {entry100rod, entry100Scott};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,10 +47,10 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
|
|||
private SimpleAclEntry entry100Scott = new SimpleAclEntry(scott.getPrincipal(),
|
||||
new NamedEntityObjectIdentity("OBJECT", "100"), null, 4);
|
||||
private UsernamePasswordAuthenticationToken dianne = new UsernamePasswordAuthenticationToken("dianne", "not used");
|
||||
private UsernamePasswordAuthenticationToken marissa = new UsernamePasswordAuthenticationToken("marissa",
|
||||
private UsernamePasswordAuthenticationToken rod = new UsernamePasswordAuthenticationToken("rod",
|
||||
"not used",
|
||||
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);
|
||||
private UsernamePasswordAuthenticationToken scottWithUserDetails = new UsernamePasswordAuthenticationToken(new User(
|
||||
"scott", "NOT_USED", true, true, true, true,
|
||||
|
@ -59,7 +59,7 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
|
|||
|
||||
// convenience group
|
||||
private SimpleAclEntry[] acls = {
|
||||
entry100Marissa, entry100Scott, entry100RoleEverybody, entry100RoleOne, entry100RoleTwo
|
||||
entry100rod, entry100Scott, entry100RoleEverybody, entry100RoleOne, entry100RoleTwo
|
||||
};
|
||||
|
||||
//~ Constructors ===================================================================================================
|
||||
|
@ -87,12 +87,12 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
|
|||
assertNull(resolver.resolveEffectiveAcls(acls, dianne));
|
||||
}
|
||||
|
||||
public void testResolveAclsForMarissa() {
|
||||
public void testResolveAclsForrod() {
|
||||
GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver();
|
||||
assertEquals(3, resolver.resolveEffectiveAcls(acls, marissa).length);
|
||||
assertEquals(entry100Marissa, resolver.resolveEffectiveAcls(acls, marissa)[0]);
|
||||
assertEquals(entry100RoleEverybody, resolver.resolveEffectiveAcls(acls, marissa)[1]);
|
||||
assertEquals(entry100RoleOne, resolver.resolveEffectiveAcls(acls, marissa)[2]);
|
||||
assertEquals(3, resolver.resolveEffectiveAcls(acls, rod).length);
|
||||
assertEquals(entry100rod, resolver.resolveEffectiveAcls(acls, rod)[0]);
|
||||
assertEquals(entry100RoleEverybody, resolver.resolveEffectiveAcls(acls, rod)[1]);
|
||||
assertEquals(entry100RoleOne, resolver.resolveEffectiveAcls(acls, rod)[2]);
|
||||
}
|
||||
|
||||
public void testResolveAclsForScottWithStringObjectAsPrincipal() {
|
||||
|
@ -119,9 +119,9 @@ public class GrantedAuthorityEffectiveAclsResolverTests extends TestCase {
|
|||
public void testSkipsNonBasicAclEntryObjects() {
|
||||
GrantedAuthorityEffectiveAclsResolver resolver = new GrantedAuthorityEffectiveAclsResolver();
|
||||
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 ==================================================================================================
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testCorrectOperation() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testDetectsNullOnMainConstructor() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
|
||||
try {
|
||||
|
@ -123,7 +123,7 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testRejectsInvalidMasksInAddMethod() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 4);
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testRejectsInvalidMasksInDeleteMethod() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
|
||||
acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE});
|
||||
|
@ -150,7 +150,7 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testRejectsInvalidMasksInTogglePermissionMethod() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
|
||||
acl.addPermissions(new int[] {SimpleAclEntry.READ, SimpleAclEntry.WRITE, SimpleAclEntry.CREATE});
|
||||
|
@ -164,11 +164,11 @@ public class SimpleAclEntryTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testToString() {
|
||||
String recipient = "marissa";
|
||||
String recipient = "rod";
|
||||
AclObjectIdentity objectIdentity = new NamedEntityObjectIdentity("domain", "12");
|
||||
SimpleAclEntry acl = new SimpleAclEntry(recipient, objectIdentity, null, 0);
|
||||
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() {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
|
|||
|
||||
private static final AclObjectIdentity OBJECT_100 = new NamedEntityObjectIdentity("OBJECT", "100");
|
||||
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_200_PETER = new SimpleAclEntry("peter", OBJECT_200, null, 4);
|
||||
|
||||
|
@ -71,12 +71,12 @@ public class EhCacheBasedAclEntryCacheTests extends TestCase {
|
|||
cache.setCache(getCache());
|
||||
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});
|
||||
|
||||
// Check we can get them from cache again
|
||||
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]);
|
||||
assertNull(cache.getEntriesFromCache(new NamedEntityObjectIdentity("OBJECT", "NOT_IN_CACHE")));
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
|
||||
|
||||
// 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);
|
||||
|
||||
// Create another BasicAclEntry for this AclObjectIdentity
|
||||
|
@ -93,11 +93,11 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
assertEquals(SimpleAclEntry.READ, acls[1].getMask());
|
||||
|
||||
// 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));
|
||||
acls = dao.getAcls(identity);
|
||||
assertEquals(2, acls.length);
|
||||
assertEquals("marissa", acls[0].getRecipient());
|
||||
assertEquals("rod", acls[0].getRecipient());
|
||||
assertEquals(SimpleAclEntry.ADMINISTRATION, acls[0].getMask());
|
||||
assertEquals("scott", acls[1].getRecipient());
|
||||
assertEquals(SimpleAclEntry.NOTHING, acls[1].getMask());
|
||||
|
@ -110,7 +110,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
|
||||
|
||||
// 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);
|
||||
|
||||
// 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");
|
||||
|
||||
// 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);
|
||||
|
||||
// Create another BasicAclEntry for this AclObjectIdentity
|
||||
|
@ -178,7 +178,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
|
||||
|
||||
// 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);
|
||||
|
||||
// Create another BasicAclEntry for this AclObjectIdentity
|
||||
|
@ -263,7 +263,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
AclObjectIdentity parentIdentity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "1");
|
||||
|
||||
// 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);
|
||||
|
||||
// Create another BasicAclEntry for this AclObjectIdentity
|
||||
|
@ -291,7 +291,7 @@ public class JdbcExtendedDaoImplTests extends TestCase {
|
|||
JdbcExtendedDaoImpl dao = makePopulatedJdbcDao();
|
||||
AclObjectIdentity identity = new NamedEntityObjectIdentity(OBJECT_IDENTITY, "201");
|
||||
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 {
|
||||
dao.create(simpleAcl);
|
||||
|
|
|
@ -95,12 +95,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
|
||||
|
@ -129,12 +129,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testCorrectOperationWhenPrincipalIsAuthorised()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
|
||||
|
@ -151,7 +151,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
list.add("brisbane");
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -165,12 +165,12 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testCorrectOperationWhenReturnedObjectIsArray()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
|
||||
|
@ -187,7 +187,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
list[3] = "brisbane";
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -201,11 +201,11 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testDetectsIfReturnedObjectIsNotACollection()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -230,11 +230,11 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testGrantsAccessIfReturnedObjectIsNull()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -256,9 +256,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testRespectsModificationsToProcessConfigAttribute()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -278,7 +278,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
list.add("brisbane");
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -297,9 +297,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testRespectsModificationsToRequirePermissions()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -319,7 +319,7 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
list.add("brisbane");
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_COLLECTION_READ"));
|
||||
|
||||
|
@ -344,9 +344,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testStartupDetectsMissingProcessConfigAttribute()
|
||||
throws Exception {
|
||||
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
provider.setAclManager(aclManager);
|
||||
|
@ -364,9 +364,9 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProviderTests extend
|
|||
public void testStartupDetectsMissingRequirePermission()
|
||||
throws Exception {
|
||||
BasicAclEntryAfterInvocationCollectionFilteringProvider provider = new BasicAclEntryAfterInvocationCollectionFilteringProvider();
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
provider.setAclManager(aclManager);
|
||||
|
|
|
@ -87,12 +87,12 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testCorrectOperationWhenPrincipalHasNoPermissionToDomainObject()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
|
||||
|
@ -115,12 +115,12 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testCorrectOperationWhenPrincipalIsAuthorised()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
|
||||
|
@ -129,7 +129,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
|
||||
|
||||
|
@ -140,11 +140,11 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testGrantsAccessIfReturnedObjectIsNull()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("belmont", "marissa",
|
||||
AclManager aclManager = new MockAclManager("belmont", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
|
||||
|
||||
|
@ -164,9 +164,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testRespectsModificationsToProcessConfigAttribute()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
|
||||
|
||||
|
@ -193,9 +193,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testRespectsModificationsToRequirePermissions()
|
||||
throws Exception {
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
provider.afterPropertiesSet();
|
||||
|
||||
// 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();
|
||||
attr.addConfigAttribute(new SecurityConfig("AFTER_ACL_READ"));
|
||||
|
||||
|
@ -229,9 +229,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testStartupDetectsMissingProcessConfigAttribute()
|
||||
throws Exception {
|
||||
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
provider.setAclManager(aclManager);
|
||||
|
@ -249,9 +249,9 @@ public class BasicAclEntryAfterInvocationProviderTests extends TestCase {
|
|||
public void testStartupDetectsMissingRequirePermission()
|
||||
throws Exception {
|
||||
BasicAclEntryAfterInvocationProvider provider = new BasicAclEntryAfterInvocationProvider();
|
||||
AclManager aclManager = new MockAclManager("sydney", "marissa",
|
||||
AclManager aclManager = new MockAclManager("sydney", "rod",
|
||||
new AclEntry[] {
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new MockAclEntry()
|
||||
});
|
||||
provider.setAclManager(aclManager);
|
||||
|
|
|
@ -57,9 +57,9 @@ public class SecurityContextImplTests extends TestCase {
|
|||
|
||||
public void testSecurityContextCorrectOperation() {
|
||||
SecurityContext context = new SecurityContextImpl();
|
||||
Authentication auth = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
Authentication auth = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
context.setAuthentication(auth);
|
||||
assertEquals(auth, context.getAuthentication());
|
||||
assertTrue(context.toString().lastIndexOf("marissa") != -1);
|
||||
assertTrue(context.toString().lastIndexOf("rod") != -1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ContextPropagatingRemoteInvocationTests extends TestCase {
|
|||
public void testContextIsResetEvenIfExceptionOccurs()
|
||||
throws Exception {
|
||||
// Setup client-side context
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
|
||||
|
@ -88,7 +88,7 @@ public class ContextPropagatingRemoteInvocationTests extends TestCase {
|
|||
|
||||
public void testNormalOperation() throws Exception {
|
||||
// Setup client-side context
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
|
||||
|
|
|
@ -67,12 +67,12 @@ public class InterceptorStatusTokenTests extends TestCase {
|
|||
|
||||
MethodInvocation mi = new SimpleMethodInvocation();
|
||||
|
||||
InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken("marissa",
|
||||
InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken("rod",
|
||||
"koala"), true, attr, mi);
|
||||
|
||||
assertTrue(token.isContextHolderRefreshRequired());
|
||||
assertEquals(attr, token.getAttr());
|
||||
assertEquals(mi, token.getSecureObject());
|
||||
assertEquals("marissa", token.getAuthentication().getPrincipal());
|
||||
assertEquals("rod", token.getAuthentication().getPrincipal());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class AspectJSecurityInterceptorTests extends TestCase {
|
|||
MockAspectJCallback aspectJCallback = new MockAspectJCallback();
|
||||
|
||||
SecurityContextHolder.getContext()
|
||||
.setAuthentication(new TestingAuthenticationToken("marissa", "koala",
|
||||
.setAuthentication(new TestingAuthenticationToken("rod", "koala",
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("MOCK_ONE")}));
|
||||
|
||||
Object result = si.invoke(joinPoint, aspectJCallback);
|
||||
|
@ -120,7 +120,7 @@ public class AspectJSecurityInterceptorTests extends TestCase {
|
|||
aspectJCallback.setThrowExceptionIfInvoked(true);
|
||||
|
||||
SecurityContextHolder.getContext()
|
||||
.setAuthentication(new TestingAuthenticationToken("marissa", "koala",
|
||||
.setAuthentication(new TestingAuthenticationToken("rod", "koala",
|
||||
new GrantedAuthority[] {}));
|
||||
|
||||
try {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class FilterBasedLdapUserSearchTests extends AbstractLdapIntegrationTests
|
|||
@Test
|
||||
public void testExtraFilterPartToExcludeBob() throws Exception {
|
||||
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=people",
|
||||
"(&(cn=*)(!(|(uid={0})(uid=marissa))))", dirCtxFactory);
|
||||
"(&(cn=*)(!(|(uid={0})(uid=rod))))", dirCtxFactory);
|
||||
|
||||
// Search for bob, get back ben...
|
||||
DirContextOperations ben = locator.searchForUser("bob");
|
||||
|
|
|
@ -390,7 +390,7 @@ public class CasAuthenticationProviderTests extends TestCase {
|
|||
List list = new Vector();
|
||||
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");
|
||||
|
|
|
@ -49,12 +49,12 @@ public class TicketResponseTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testConstructorAcceptsNullProxyGrantingTicketIOU() {
|
||||
TicketResponse ticket = new TicketResponse("marissa", new Vector(), null);
|
||||
TicketResponse ticket = new TicketResponse("rod", new Vector(), null);
|
||||
assertEquals("", ticket.getProxyGrantingTicketIou());
|
||||
}
|
||||
|
||||
public void testConstructorAcceptsNullProxyList() {
|
||||
TicketResponse ticket = new TicketResponse("marissa", null,
|
||||
TicketResponse ticket = new TicketResponse("rod", null,
|
||||
"PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
|
||||
assertEquals(new Vector(), ticket.getProxyList());
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ public class TicketResponseTests extends TestCase {
|
|||
List proxyList = new Vector();
|
||||
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");
|
||||
assertEquals("marissa", ticket.getUser());
|
||||
assertEquals("rod", ticket.getUser());
|
||||
assertEquals(proxyList, ticket.getProxyList());
|
||||
assertEquals("PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt", ticket.getProxyGrantingTicketIou());
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class TicketResponseTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testToString() {
|
||||
TicketResponse ticket = new TicketResponse("marissa", null,
|
||||
TicketResponse ticket = new TicketResponse("rod", null,
|
||||
"PGTIOU-0-R0zlgrl4pdAQwBvJWO3vnNpevwqStbSGcq3vKB2SqSFFRnjPHt");
|
||||
String result = ticket.toString();
|
||||
assertTrue(result.lastIndexOf("Proxy List:") != -1);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class EhCacheBasedTicketCacheTests extends TestCase {
|
|||
List proxyList = new Vector();
|
||||
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")});
|
||||
|
||||
return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",
|
||||
|
|
|
@ -51,7 +51,7 @@ public class NullStatelessTicketCacheTests extends TestCase {
|
|||
List<String> proxyList = new ArrayList<String>();
|
||||
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")});
|
||||
|
||||
return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",
|
||||
|
|
|
@ -70,7 +70,7 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
|
|||
public void testGetGrantedAuthoritiesForInvalidUsername()
|
||||
throws Exception {
|
||||
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
|
||||
populator.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
populator.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
populator.afterPropertiesSet();
|
||||
|
||||
try {
|
||||
|
@ -84,10 +84,10 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
|
|||
public void testGetGrantedAuthoritiesForValidUsername()
|
||||
throws Exception {
|
||||
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
|
||||
populator.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
populator.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
populator.afterPropertiesSet();
|
||||
|
||||
UserDetails results = populator.getUserDetails("marissa");
|
||||
UserDetails results = populator.getUserDetails("rod");
|
||||
assertEquals(2, results.getAuthorities().length);
|
||||
assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), results.getAuthorities()[0]);
|
||||
assertEquals(new GrantedAuthorityImpl("ROLE_TWO"), results.getAuthorities()[1]);
|
||||
|
@ -109,7 +109,7 @@ public class DaoCasAuthoritiesPopulatorTests extends TestCase {
|
|||
|
||||
public void testGettersSetters() {
|
||||
DaoCasAuthoritiesPopulator populator = new DaoCasAuthoritiesPopulator();
|
||||
UserDetailsService dao = new MockAuthenticationDaoUserMarissa();
|
||||
UserDetailsService dao = new MockAuthenticationDaoUserrod();
|
||||
populator.setUserDetailsService(dao);
|
||||
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() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException, DataAccessException {
|
||||
if ("marissa".equals(username)) {
|
||||
return new User("marissa", "koala", true, true, true, true,
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", "koala", true, true, true, true,
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
|
||||
} else {
|
||||
throw new UsernameNotFoundException("Could not find: " + username);
|
||||
|
|
|
@ -56,10 +56,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
//~ Methods ========================================================================================================
|
||||
|
||||
public void testAuthenticateFailsForIncorrectPasswordCase() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "KOala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "KOala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -73,10 +73,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
public void testReceivedBadCredentialsWhenCredentialsNotProvided() {
|
||||
// Test related to SEC-434
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("marissa", null);
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("rod", null);
|
||||
try {
|
||||
provider.authenticate(authenticationToken);
|
||||
fail("Expected BadCredenialsException");
|
||||
|
@ -156,7 +156,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateFailsWhenAuthenticationDaoHasBackendFailure() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoSimulateBackendError());
|
||||
|
@ -174,7 +174,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -186,11 +186,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateFailsWithInvalidPassword() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa",
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod",
|
||||
"INVALID_PASSWORD");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -206,7 +206,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -222,7 +222,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
assertTrue(provider.isHideUserNotFoundExceptions());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -234,10 +234,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("MaRiSSA", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("RoD", "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -249,11 +249,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticates() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
token.setDetails("192.168.0.1");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
Authentication result = provider.authenticate(token);
|
||||
|
@ -271,10 +271,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticatesASecondTime() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
Authentication result = provider.authenticate(token);
|
||||
|
@ -294,13 +294,13 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticatesWhenASaltIsUsed() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
SystemWideSaltSource salt = new SystemWideSaltSource();
|
||||
salt.setSystemWideSalt("SYSTEM_SALT_VALUE");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissaWithSalt());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrodWithSalt());
|
||||
provider.setSaltSource(salt);
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
|
@ -320,10 +320,10 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticatesWithForcePrincipalAsString() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
provider.setForcePrincipalAsString(true);
|
||||
|
||||
|
@ -335,11 +335,11 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
|
||||
UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result;
|
||||
assertEquals(String.class, castResult.getPrincipal().getClass());
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
}
|
||||
|
||||
public void testDetectsNullBeingReturnedFromAuthenticationDao() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoReturnsNull());
|
||||
|
@ -370,9 +370,9 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
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();
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(authenticationDao);
|
||||
|
@ -381,19 +381,19 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
// This will work, as password still "koala"
|
||||
provider.authenticate(token);
|
||||
|
||||
// Check "marissa = koala" ended up in the cache
|
||||
assertEquals("koala", cache.getUserFromCache("marissa").getPassword());
|
||||
// Check "rod = koala" ended up in the cache
|
||||
assertEquals("koala", cache.getUserFromCache("rod").getPassword());
|
||||
|
||||
// Now change the password the AuthenticationDao will return
|
||||
authenticationDao.setPassword("easternLongNeckTurtle");
|
||||
|
||||
// Now try authentication again, with the new password
|
||||
token = new UsernamePasswordAuthenticationToken("marissa", "easternLongNeckTurtle");
|
||||
token = new UsernamePasswordAuthenticationToken("rod", "easternLongNeckTurtle");
|
||||
provider.authenticate(token);
|
||||
|
||||
// To get this far, the new password was accepted
|
||||
// Check the cache was updated
|
||||
assertEquals("easternLongNeckTurtle", cache.getUserFromCache("marissa").getPassword());
|
||||
assertEquals("easternLongNeckTurtle", cache.getUserFromCache("rod").getPassword());
|
||||
}
|
||||
|
||||
public void testStartupFailsIfNoAuthenticationDao()
|
||||
|
@ -410,7 +410,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
|
||||
public void testStartupFailsIfNoUserCacheSet() throws Exception {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserMarissa());
|
||||
provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
|
||||
assertEquals(NullUserCache.class, provider.getUserCache().getClass());
|
||||
provider.setUserCache(null);
|
||||
|
||||
|
@ -424,7 +424,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||
|
||||
public void testStartupSuccess() throws Exception {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
UserDetailsService userDetailsService = new MockAuthenticationDaoUserMarissa();
|
||||
UserDetailsService userDetailsService = new MockAuthenticationDaoUserrod();
|
||||
provider.setUserDetailsService(userDetailsService);
|
||||
provider.setUserCache(new MockUserCache());
|
||||
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";
|
||||
|
||||
public UserDetails loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException, DataAccessException {
|
||||
if ("marissa".equals(username)) {
|
||||
return new User("marissa", password, true, true, true, true,
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", password, true, true, true, true,
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
|
||||
} else {
|
||||
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)
|
||||
throws UsernameNotFoundException, DataAccessException {
|
||||
if ("marissa".equals(username)) {
|
||||
return new User("marissa", "koala{SYSTEM_SALT_VALUE}", true, true, true, true,
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true,
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
|
||||
} else {
|
||||
throw new UsernameNotFoundException("Could not find: " + username);
|
||||
|
|
|
@ -43,7 +43,7 @@ public class RemoteAuthenticationManagerImplTests extends TestCase {
|
|||
manager.setAuthenticationManager(new MockAuthenticationManager(false));
|
||||
|
||||
try {
|
||||
manager.attemptAuthentication("marissa", "password");
|
||||
manager.attemptAuthentication("rod", "password");
|
||||
fail("Should have thrown RemoteAuthenticationException");
|
||||
} catch (RemoteAuthenticationException expected) {
|
||||
assertTrue(true);
|
||||
|
@ -76,7 +76,7 @@ public class RemoteAuthenticationManagerImplTests extends TestCase {
|
|||
RemoteAuthenticationManagerImpl manager = new RemoteAuthenticationManagerImpl();
|
||||
manager.setAuthenticationManager(new MockAuthenticationManager(true));
|
||||
|
||||
GrantedAuthority[] result = manager.attemptAuthentication("marissa", "password");
|
||||
GrantedAuthority[] result = manager.attemptAuthentication("rod", "password");
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RemoteAuthenticationProviderTests extends TestCase {
|
|||
provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(false));
|
||||
|
||||
try {
|
||||
provider.authenticate(new UsernamePasswordAuthenticationToken("marissa", "password"));
|
||||
provider.authenticate(new UsernamePasswordAuthenticationToken("rod", "password"));
|
||||
fail("Should have thrown RemoteAuthenticationException");
|
||||
} catch (RemoteAuthenticationException expected) {
|
||||
assertTrue(true);
|
||||
|
@ -79,8 +79,8 @@ public class RemoteAuthenticationProviderTests extends TestCase {
|
|||
RemoteAuthenticationProvider provider = new RemoteAuthenticationProvider();
|
||||
provider.setRemoteAuthenticationManager(new MockRemoteAuthenticationManager(true));
|
||||
|
||||
Authentication result = provider.authenticate(new UsernamePasswordAuthenticationToken("marissa", "password"));
|
||||
assertEquals("marissa", result.getPrincipal());
|
||||
Authentication result = provider.authenticate(new UsernamePasswordAuthenticationToken("rod", "password"));
|
||||
assertEquals("rod", result.getPrincipal());
|
||||
assertEquals("password", result.getCredentials());
|
||||
assertEquals("foo", result.getAuthorities()[0].getAuthority());
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateFailsWhenUserDetailsServiceHasBackendFailure() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceSimulateBackendError());
|
||||
|
@ -138,7 +138,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -154,7 +154,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setHideUserNotFoundExceptions(false); // we want UsernameNotFoundExceptions
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -170,7 +170,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
assertTrue(provider.isHideUserNotFoundExceptions());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -182,10 +182,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateFailsWithMixedCaseUsernameIfDefaultChanged() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("MaRiSSA", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("RDd", "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
try {
|
||||
|
@ -197,11 +197,11 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticates() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
token.setDetails("192.168.0.1");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
Authentication result = provider.authenticate(token);
|
||||
|
@ -219,10 +219,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticatesASecondTime() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
|
||||
Authentication result = provider.authenticate(token);
|
||||
|
@ -242,10 +242,10 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticatesWithForcePrincipalAsString() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
provider.setUserCache(new MockUserCache());
|
||||
provider.setForcePrincipalAsString(true);
|
||||
|
||||
|
@ -257,11 +257,11 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
|
||||
UsernamePasswordAuthenticationToken castResult = (UsernamePasswordAuthenticationToken) result;
|
||||
assertEquals(String.class, castResult.getPrincipal().getClass());
|
||||
assertEquals("marissa", castResult.getPrincipal());
|
||||
assertEquals("rod", castResult.getPrincipal());
|
||||
}
|
||||
|
||||
public void testDetectsNullBeingReturnedFromUserDetailsService() {
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "koala");
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceReturnsNull());
|
||||
|
@ -299,7 +299,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
|
||||
public void testStartupFailsIfNoUserCacheSet() throws Exception {
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserMarissa());
|
||||
provider.setUserDetailsService(new MockUserDetailsServiceUserrod());
|
||||
assertEquals(NullUserCache.class, provider.getUserCache().getClass());
|
||||
provider.setUserCache(null);
|
||||
|
||||
|
@ -313,7 +313,7 @@ public class SiteminderAuthenticationProviderTests extends TestCase {
|
|||
|
||||
public void testStartupSuccess() throws Exception {
|
||||
SiteminderAuthenticationProvider provider = new SiteminderAuthenticationProvider();
|
||||
UserDetailsService userDetailsService = new MockUserDetailsServiceUserMarissa();
|
||||
UserDetailsService userDetailsService = new MockUserDetailsServiceUserrod();
|
||||
provider.setUserDetailsService(userDetailsService);
|
||||
provider.setUserCache(new MockUserCache());
|
||||
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";
|
||||
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
|
||||
if ("marissa".equals(username)) {
|
||||
return new User("marissa", password, true, true, true, true, new GrantedAuthority[] {
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", password, true, true, true, true, new GrantedAuthority[] {
|
||||
new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") });
|
||||
} else {
|
||||
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 {
|
||||
if ("marissa".equals(username)) {
|
||||
return new User("marissa", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, new GrantedAuthority[] {
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, new GrantedAuthority[] {
|
||||
new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO") });
|
||||
} else {
|
||||
throw new UsernameNotFoundException("Could not find: " + username);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EhCacheBasedX509UserCacheTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class AclTagTests extends TestCase {
|
|||
|
||||
public void testInclusionDeniedWhenAclManagerUnawareOfObject()
|
||||
throws JspException {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
aclTag.setHasPermission(new Long(SimpleAclEntry.ADMINISTRATION).toString());
|
||||
|
@ -69,7 +69,7 @@ public class AclTagTests extends TestCase {
|
|||
|
||||
public void testInclusionDeniedWhenNoListOfPermissionsGiven()
|
||||
throws JspException {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
aclTag.setHasPermission(null);
|
||||
|
@ -92,7 +92,7 @@ public class AclTagTests extends TestCase {
|
|||
|
||||
public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions()
|
||||
throws JspException {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
aclTag.setHasPermission(new Integer(SimpleAclEntry.DELETE).toString());
|
||||
|
@ -133,7 +133,7 @@ public class AclTagTests extends TestCase {
|
|||
|
||||
public void testOperationWhenPrincipalHoldsPermissionOfMultipleList()
|
||||
throws JspException {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
aclTag.setHasPermission(new Integer(SimpleAclEntry.ADMINISTRATION) + "," + new Integer(SimpleAclEntry.READ));
|
||||
|
@ -143,7 +143,7 @@ public class AclTagTests extends TestCase {
|
|||
|
||||
public void testOperationWhenPrincipalHoldsPermissionOfSingleList()
|
||||
throws JspException {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
aclTag.setHasPermission(new Integer(SimpleAclEntry.READ).toString());
|
||||
|
@ -162,11 +162,11 @@ public class AclTagTests extends TestCase {
|
|||
ConfigurableApplicationContext context = MockApplicationContext.getContext();
|
||||
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("object1", "marissa",
|
||||
AclManager aclManager = new MockAclManager("object1", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
|
||||
});
|
||||
|
||||
// Register the AclManager into our ApplicationContext
|
||||
|
|
|
@ -49,34 +49,34 @@ public class AuthenticationTagTests extends TestCase {
|
|||
|
||||
public void testOperationAndMethodPrefixWhenPrincipalIsAUserDetailsInstance()
|
||||
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[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
authenticationTag.setOperation("username");
|
||||
authenticationTag.setMethodPrefix("get");
|
||||
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
|
||||
assertEquals("marissaUserDetails", authenticationTag.getLastMessage());
|
||||
assertEquals("rodUserDetails", authenticationTag.getLastMessage());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
authenticationTag.setOperation("principal");
|
||||
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
|
||||
assertEquals("marissaAsString", authenticationTag.getLastMessage());
|
||||
assertEquals("rodAsString", authenticationTag.getLastMessage());
|
||||
}
|
||||
|
||||
public void testOperationWhenPrincipalIsAUserDetailsInstance()
|
||||
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[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
authenticationTag.setOperation("username");
|
||||
assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
|
||||
assertEquals("marissaUserDetails", authenticationTag.getLastMessage());
|
||||
assertEquals("rodUserDetails", authenticationTag.getLastMessage());
|
||||
}
|
||||
|
||||
public void testOperationWhenPrincipalIsNull() throws JspException {
|
||||
|
@ -102,7 +102,7 @@ public class AuthenticationTagTests extends TestCase {
|
|||
}
|
||||
|
||||
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[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
authenticationTag.setOperation("username");
|
||||
|
@ -117,7 +117,7 @@ public class AuthenticationTagTests extends TestCase {
|
|||
}
|
||||
|
||||
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[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
authenticationTag.setOperation("qsq");
|
||||
|
|
|
@ -55,11 +55,11 @@ public class AuthzImplTest extends TestCase {
|
|||
ctx = new StaticApplicationContext();
|
||||
|
||||
// Create an AclManager
|
||||
AclManager aclManager = new MockAclManager("object1", "marissa",
|
||||
AclManager aclManager = new MockAclManager("object1", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ)
|
||||
});
|
||||
|
||||
// Register the AclManager into our ApplicationContext
|
||||
|
@ -84,7 +84,7 @@ public class AuthzImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testInclusionDeniedWhenAclManagerUnawareOfObject() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
authz.setAppCtx(ctx);
|
||||
|
@ -97,7 +97,7 @@ public class AuthzImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testInclusionDeniedWhenNoListOfPermissionsGiven() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
authz.setAppCtx(ctx);
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class AuthzImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testInclusionDeniedWhenPrincipalDoesNotHoldRequiredPermissions() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
authz.setAppCtx(ctx);
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class AuthzImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testOperationWhenPrincipalHoldsPermissionOfMultipleList() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
authz.setAppCtx(ctx);
|
||||
|
@ -177,7 +177,7 @@ public class AuthzImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testOperationWhenPrincipalHoldsPermissionOfSingleList() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
authz.setAppCtx(ctx);
|
||||
|
@ -194,18 +194,18 @@ public class AuthzImplTest extends TestCase {
|
|||
* Test method for 'com.alibaba.exodus2.web.common.security.pulltool.AuthzImpl.getPrincipal()'
|
||||
*/
|
||||
public void testOperationWhenPrincipalIsAString() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissaAsString", "koala", new GrantedAuthority[] {});
|
||||
Authentication auth = new TestingAuthenticationToken("rodAsString", "koala", new GrantedAuthority[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
assertEquals("marissaAsString", authz.getPrincipal());
|
||||
assertEquals("rodAsString", authz.getPrincipal());
|
||||
}
|
||||
|
||||
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[] {});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
assertEquals("marissaUserDetails", authz.getPrincipal());
|
||||
assertEquals("rodUserDetails", authz.getPrincipal());
|
||||
}
|
||||
|
||||
public void testOperationWhenPrincipalIsNull() {
|
||||
|
|
|
@ -102,7 +102,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
// Create User Details Service, provider and authentication manager
|
||||
InMemoryDaoImpl dao = new InMemoryDaoImpl();
|
||||
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());
|
||||
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
|
@ -185,7 +185,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
|
||||
public void testNormalOperation() throws Exception {
|
||||
// Setup our HTTP request
|
||||
String token = "marissa:koala";
|
||||
String token = "rod:koala";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
|
||||
request.setServletPath("/some_file.html");
|
||||
|
@ -196,7 +196,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
executeFilterInContainerSimulator(filter, request, true);
|
||||
|
||||
assertNotNull(SecurityContextHolder.getContext().getAuthentication());
|
||||
assertEquals("marissa",
|
||||
assertEquals("rod",
|
||||
((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername());
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
public void testSuccessLoginThenFailureLoginResultsInSessionLoosingToken()
|
||||
throws Exception {
|
||||
// Setup our HTTP request
|
||||
String token = "marissa:koala";
|
||||
String token = "rod:koala";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
|
||||
request.setServletPath("/some_file.html");
|
||||
|
@ -250,7 +250,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
executeFilterInContainerSimulator(filter, request, true);
|
||||
|
||||
assertNotNull(SecurityContextHolder.getContext().getAuthentication());
|
||||
assertEquals("marissa",
|
||||
assertEquals("rod",
|
||||
((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername());
|
||||
|
||||
// NOW PERFORM FAILED AUTHENTICATION
|
||||
|
@ -271,7 +271,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
public void testWrongPasswordContinuesFilterChainIfIgnoreFailureIsTrue()
|
||||
throws Exception {
|
||||
// Setup our HTTP request
|
||||
String token = "marissa:WRONG_PASSWORD";
|
||||
String token = "rod:WRONG_PASSWORD";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
|
||||
request.setServletPath("/some_file.html");
|
||||
|
@ -289,7 +289,7 @@ public class BasicProcessingFilterTests extends MockObjectTestCase {
|
|||
public void testWrongPasswordReturnsForbiddenIfIgnoreFailureIsFalse()
|
||||
throws Exception {
|
||||
// Setup our HTTP request
|
||||
String token = "marissa:WRONG_PASSWORD";
|
||||
String token = "rod:WRONG_PASSWORD";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
|
||||
request.setServletPath("/some_file.html");
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DigestProcessingFilterTests extends MockObjectTestCase {
|
|||
private static final String REALM = "The Actual, Correct Realm Name";
|
||||
private static final String KEY = "springsecurity";
|
||||
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 REQUEST_URI = "/some_file.html";
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class DigestProcessingFilterTests extends MockObjectTestCase {
|
|||
// Create User Details Service
|
||||
InMemoryDaoImpl dao = new InMemoryDaoImpl();
|
||||
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());
|
||||
|
||||
DigestProcessingFilterEntryPoint ep = new DigestProcessingFilterEntryPoint();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
|
|||
|
||||
public void testNormalOperation() throws Exception {
|
||||
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");
|
||||
|
||||
AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter();
|
||||
|
@ -66,7 +66,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
|
|||
|
||||
public void testNullPasswordHandledGracefully() throws Exception {
|
||||
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();
|
||||
filter.setAuthenticationManager(new MockAuthenticationManager(true));
|
||||
|
@ -96,7 +96,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
|
|||
filter.init(null);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addParameter("x", "marissa");
|
||||
request.addParameter("x", "rod");
|
||||
request.addParameter("y", "koala");
|
||||
|
||||
Authentication result = filter.attemptAuthentication(request);
|
||||
|
@ -106,7 +106,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
|
|||
|
||||
public void testSpacesAreTrimmedCorrectlyFromUsername() throws Exception {
|
||||
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");
|
||||
|
||||
AuthenticationProcessingFilter filter = new AuthenticationProcessingFilter();
|
||||
|
@ -114,6 +114,6 @@ public class AuthenticationProcessingFilterTests extends TestCase {
|
|||
filter.init(null);
|
||||
|
||||
Authentication result = filter.attemptAuthentication(request);
|
||||
assertEquals("marissa", result.getName());
|
||||
assertEquals("rod", result.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class SiteminderAuthenticationProcessingFilterTests extends TestCase {
|
|||
*/
|
||||
public void testFormNormalOperation() throws Exception {
|
||||
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");
|
||||
|
||||
MockAuthenticationManager authMgr = new MockAuthenticationManager(true);
|
||||
|
@ -124,7 +124,7 @@ public class SiteminderAuthenticationProcessingFilterTests extends TestCase {
|
|||
*/
|
||||
public void testFormNullPasswordHandledGracefully() throws Exception {
|
||||
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);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class UserTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
|
||||
assertFalse(user1.equals(null));
|
||||
|
@ -61,7 +61,7 @@ public class UserTests extends TestCase {
|
|||
assertTrue(user1.equals(user1));
|
||||
|
||||
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")})));
|
||||
|
||||
assertFalse(user1.equals(
|
||||
|
@ -69,27 +69,27 @@ public class UserTests extends TestCase {
|
|||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")})));
|
||||
|
||||
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")})));
|
||||
|
||||
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")})));
|
||||
|
||||
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")})));
|
||||
|
||||
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")})));
|
||||
|
||||
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")})));
|
||||
|
||||
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")})));
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class UserTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
@ -122,14 +122,14 @@ public class UserTests extends TestCase {
|
|||
}
|
||||
|
||||
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");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
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});
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
@ -152,18 +152,18 @@ public class UserTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
assertEquals("marissa", user.getUsername());
|
||||
assertEquals("rod", user.getUsername());
|
||||
assertEquals("koala", user.getPassword());
|
||||
assertTrue(user.isEnabled());
|
||||
assertEquals(new GrantedAuthorityImpl("ROLE_ONE"), user.getAuthorities()[0]);
|
||||
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 {
|
||||
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")});
|
||||
assertTrue(!user.isEnabled());
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ public class JdbcDaoImplTests extends TestCase {
|
|||
|
||||
public void testCheckDaoAccessUserSuccess() throws Exception {
|
||||
JdbcDaoImpl dao = makePopulatedJdbcDao();
|
||||
UserDetails user = dao.loadUserByUsername("marissa");
|
||||
assertEquals("marissa", user.getUsername());
|
||||
UserDetails user = dao.loadUserByUsername("rod");
|
||||
assertEquals("rod", user.getUsername());
|
||||
assertEquals("koala", user.getPassword());
|
||||
assertTrue(user.isEnabled());
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class JdbcDaoImplTests extends TestCase {
|
|||
|
||||
public void testLookupSuccessWithMixedCase() throws Exception {
|
||||
JdbcDaoImpl dao = makePopulatedJdbcDao();
|
||||
assertEquals("koala", dao.loadUserByUsername("MaRiSSA").getPassword());
|
||||
assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
|
||||
assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword());
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,8 @@ public class JdbcDaoImplTests extends TestCase {
|
|||
JdbcDaoImpl dao = makePopulatedJdbcDaoWithRolePrefix();
|
||||
assertEquals("ARBITRARY_PREFIX_", dao.getRolePrefix());
|
||||
|
||||
UserDetails user = dao.loadUserByUsername("marissa");
|
||||
assertEquals("marissa", user.getUsername());
|
||||
UserDetails user = dao.loadUserByUsername("rod");
|
||||
assertEquals("rod", user.getUsername());
|
||||
assertEquals(2, user.getAuthorities().length);
|
||||
|
||||
HashSet authorities = new HashSet(2);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class InMemoryDaoTests extends TestCase {
|
|||
|
||||
private UserMap makeUserMap() {
|
||||
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();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class InMemoryDaoTests extends TestCase {
|
|||
InMemoryDaoImpl dao = new InMemoryDaoImpl();
|
||||
dao.setUserMap(makeUserMap());
|
||||
dao.afterPropertiesSet();
|
||||
assertEquals("koala", dao.loadUserByUsername("marissa").getPassword());
|
||||
assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
|
||||
assertEquals("wombat", dao.loadUserByUsername("scott").getPassword());
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class InMemoryDaoTests extends TestCase {
|
|||
InMemoryDaoImpl dao = new InMemoryDaoImpl();
|
||||
dao.setUserMap(makeUserMap());
|
||||
dao.afterPropertiesSet();
|
||||
assertEquals("koala", dao.loadUserByUsername("MaRiSSA").getPassword());
|
||||
assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
|
||||
assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword());
|
||||
}
|
||||
|
||||
|
@ -121,10 +121,10 @@ public class InMemoryDaoTests extends TestCase {
|
|||
public void testUseOfExternalPropertiesObject() throws Exception {
|
||||
InMemoryDaoImpl dao = new InMemoryDaoImpl();
|
||||
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");
|
||||
dao.setUserProperties(props);
|
||||
assertEquals("koala", dao.loadUserByUsername("marissa").getPassword());
|
||||
assertEquals("koala", dao.loadUserByUsername("rod").getPassword());
|
||||
assertEquals("wombat", dao.loadUserByUsername("scott").getPassword());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,22 +50,22 @@ public class UserMapEditorTests extends TestCase {
|
|||
|
||||
public void testConvertedIntoUserSuccessfullyWhenDisabled() {
|
||||
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();
|
||||
assertTrue(!map.getUser("marissa").isEnabled());
|
||||
assertTrue(!map.getUser("rod").isEnabled());
|
||||
}
|
||||
|
||||
public void testConvertedIntoUserSuccessfullyWhenEnabled() {
|
||||
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();
|
||||
assertEquals("marissa", map.getUser("marissa").getUsername());
|
||||
assertEquals("koala", map.getUser("marissa").getPassword());
|
||||
assertEquals("ROLE_ONE", map.getUser("marissa").getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_TWO", map.getUser("marissa").getAuthorities()[1].getAuthority());
|
||||
assertTrue(map.getUser("marissa").isEnabled());
|
||||
assertEquals("rod", map.getUser("rod").getUsername());
|
||||
assertEquals("koala", map.getUser("rod").getPassword());
|
||||
assertEquals("ROLE_ONE", map.getUser("rod").getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_TWO", map.getUser("rod").getAuthorities()[1].getAuthority());
|
||||
assertTrue(map.getUser("rod").isEnabled());
|
||||
}
|
||||
|
||||
public void testEmptyStringReturnsEmptyMap() {
|
||||
|
@ -86,10 +86,10 @@ public class UserMapEditorTests extends TestCase {
|
|||
|
||||
public void testMultiUserParsing() {
|
||||
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();
|
||||
assertEquals("marissa", map.getUser("marissa").getUsername());
|
||||
assertEquals("rod", map.getUser("rod").getUsername());
|
||||
assertEquals("scott", map.getUser("scott").getUsername());
|
||||
}
|
||||
|
||||
|
|
|
@ -54,19 +54,19 @@ public class UserMapTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
UserDetails scott = new User("scott", "wombat", true, true, true, true,
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_THREE")});
|
||||
UserDetails peter = new User("peter", "opal", true, true, true, true,
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_FOUR")});
|
||||
UserMap map = new UserMap();
|
||||
map.addUser(marissa);
|
||||
map.addUser(rod);
|
||||
map.addUser(scott);
|
||||
map.addUser(peter);
|
||||
assertEquals(3, map.getUserCount());
|
||||
|
||||
assertEquals(marissa, map.getUser("marissa"));
|
||||
assertEquals(rod, map.getUser("rod"));
|
||||
assertEquals(scott, map.getUser("scott"));
|
||||
assertEquals(peter, map.getUser("peter"));
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class UserMapTests extends TestCase {
|
|||
}
|
||||
|
||||
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")});
|
||||
UserMap map = new UserMap();
|
||||
assertEquals(0, map.getUserCount());
|
||||
map.addUser(marissa);
|
||||
map.addUser(rod);
|
||||
assertEquals(1, map.getUserCount());
|
||||
|
||||
try {
|
||||
|
|
|
@ -51,11 +51,11 @@ public class StringSplitUtilsTests extends TestCase {
|
|||
|
||||
public void testSplitEachArrayElementAndCreateMapNormalOperation() {
|
||||
// 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);
|
||||
Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", "\"");
|
||||
|
||||
assertEquals("marissa", headerMap.get("username"));
|
||||
assertEquals("rod", headerMap.get("username"));
|
||||
assertEquals("Contacts Realm", headerMap.get("realm"));
|
||||
assertEquals("MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==", headerMap.get("nonce"));
|
||||
assertEquals("/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4",
|
||||
|
@ -68,11 +68,11 @@ public class StringSplitUtilsTests extends TestCase {
|
|||
}
|
||||
|
||||
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);
|
||||
Map headerMap = StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", null);
|
||||
|
||||
assertEquals("\"marissa\"", headerMap.get("username"));
|
||||
assertEquals("\"rod\"", headerMap.get("username"));
|
||||
assertEquals("\"Contacts Realm\"", headerMap.get("realm"));
|
||||
assertEquals("\"MTEwOTAyMzU1MTQ4NDo1YzY3OWViYWM5NDNmZWUwM2UwY2NmMDBiNDQzMTQ0OQ==\"", headerMap.get("nonce"));
|
||||
assertEquals("\"/spring-security-sample-contacts-filter/secure/adminPermission.htm?contactId=4\"",
|
||||
|
@ -90,9 +90,9 @@ public class StringSplitUtilsTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testSplitNormalOperation() {
|
||||
String unsplit = "username=\"marissa==\"";
|
||||
String unsplit = "username=\"rod==\"";
|
||||
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() {
|
||||
|
@ -133,11 +133,11 @@ public class StringSplitUtilsTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testSplitWorksWithDifferentDelimiters() {
|
||||
assertEquals(2, StringSplitUtils.split("18/marissa", "/").length);
|
||||
assertNull(StringSplitUtils.split("18/marissa", "!"));
|
||||
assertEquals(2, StringSplitUtils.split("18/rod", "/").length);
|
||||
assertNull(StringSplitUtils.split("18/rod", "!"));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,12 +72,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject, "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject, "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -100,7 +100,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
assertEquals(AccessDecisionVoter.ACCESS_GRANTED,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr));
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
|
||||
}
|
||||
|
||||
public void testOnlySupportsMethodInvocationAndJoinPoint() {
|
||||
|
@ -111,12 +111,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testStartupRejectsMissingAclManager() throws Exception {
|
||||
AclManager aclManager = new MockAclManager("domain1", "marissa",
|
||||
AclManager aclManager = new MockAclManager("domain1", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -135,12 +135,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
|
||||
public void testStartupRejectsMissingProcessConfigAttribute()
|
||||
throws Exception {
|
||||
AclManager aclManager = new MockAclManager("domain1", "marissa",
|
||||
AclManager aclManager = new MockAclManager("domain1", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -171,12 +171,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
|
||||
public void testStartupRejectsMissingRequirePermission()
|
||||
throws Exception {
|
||||
AclManager aclManager = new MockAclManager("domain1", "marissa",
|
||||
AclManager aclManager = new MockAclManager("domain1", "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -205,12 +205,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject, "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject, "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -229,7 +229,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr));
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
|
||||
}
|
||||
|
||||
public void testVoterAbstainsIfNotMatchingConfigAttribute()
|
||||
|
@ -238,12 +238,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = null;
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject, "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject, "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -262,7 +262,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
assertEquals(AccessDecisionVoter.ACCESS_ABSTAIN,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr));
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
|
||||
}
|
||||
|
||||
public void testVoterCanDenyAccessBasedOnInternalMethodOfDomainObject()
|
||||
|
@ -271,10 +271,10 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -294,7 +294,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
assertEquals(AccessDecisionVoter.ACCESS_DENIED,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr));
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
|
||||
}
|
||||
|
||||
public void testVoterCanDenyAccessIfPrincipalHasNoPermissionsAtAllToDomainObject()
|
||||
|
@ -303,10 +303,10 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject, "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject, "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -325,7 +325,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
// Setup a MockMethodInvocation, so voter can retrieve domainObject
|
||||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
// NB: scott is the principal, not marissa
|
||||
// NB: scott is the principal, not rod
|
||||
assertEquals(AccessDecisionVoter.ACCESS_DENIED,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("scott", null), mi, attr));
|
||||
}
|
||||
|
@ -336,12 +336,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -363,7 +363,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
assertEquals(AccessDecisionVoter.ACCESS_GRANTED,
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr));
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr));
|
||||
}
|
||||
|
||||
public void testVoterThrowsExceptionIfInvalidInternalMethodOfDomainObject()
|
||||
|
@ -372,12 +372,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -398,7 +398,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = getMethodInvocation(domainObject);
|
||||
|
||||
try {
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr);
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr);
|
||||
fail("Should have thrown AuthorizationServiceException");
|
||||
} catch (AuthorizationServiceException expected) {
|
||||
assertTrue(true);
|
||||
|
@ -411,12 +411,12 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
SomeDomainObject domainObject = new SomeDomainObject("foo");
|
||||
|
||||
// Setup an AclManager
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "marissa",
|
||||
AclManager aclManager = new MockAclManager(domainObject.getParent(), "rod",
|
||||
new AclEntry[] {
|
||||
new MockAclEntry(),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("marissa", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.ADMINISTRATION),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.READ),
|
||||
new SimpleAclEntry("rod", new MockAclObjectIdentity(), null, SimpleAclEntry.DELETE)
|
||||
});
|
||||
|
||||
// Wire up a voter
|
||||
|
@ -438,7 +438,7 @@ public class BasicAclEntryVoterTests extends TestCase {
|
|||
MethodInvocation mi = new SimpleMethodInvocation(method, new Object[] {domainObject});
|
||||
|
||||
try {
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("marissa", null), mi, attr);
|
||||
voter.vote(new UsernamePasswordAuthenticationToken("rod", null), mi, attr);
|
||||
fail("Should have thrown AuthorizationServiceException");
|
||||
} catch (AuthorizationServiceException expected) {
|
||||
assertTrue(true);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testCorrectOperationWithStringBasedPrincipal() throws Exception {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala",
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala",
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
|
@ -60,14 +60,14 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
|
|||
|
||||
SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), "");
|
||||
|
||||
assertEquals("marissa", wrapper.getRemoteUser());
|
||||
assertEquals("rod", wrapper.getRemoteUser());
|
||||
assertTrue(wrapper.isUserInRole("ROLE_FOO"));
|
||||
assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED"));
|
||||
assertEquals(auth, wrapper.getUserPrincipal());
|
||||
}
|
||||
|
||||
public void testUseOfRolePrefixMeansItIsntNeededWhenCallngIsUserInRole() {
|
||||
Authentication auth = new TestingAuthenticationToken("marissa", "koala",
|
||||
Authentication auth = new TestingAuthenticationToken("rod", "koala",
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_FOO")});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
|
|||
}
|
||||
|
||||
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",
|
||||
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_HELLO"), new GrantedAuthorityImpl("ROLE_FOOBAR")});
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
|
@ -90,7 +90,7 @@ public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
|
|||
|
||||
SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request, new PortResolverImpl(), "");
|
||||
|
||||
assertEquals("marissaAsUserDetails", wrapper.getRemoteUser());
|
||||
assertEquals("rodAsUserDetails", wrapper.getRemoteUser());
|
||||
assertFalse(wrapper.isUserInRole("ROLE_FOO"));
|
||||
assertFalse(wrapper.isUserInRole("ROLE_NOT_GRANTED"));
|
||||
assertTrue(wrapper.isUserInRole("ROLE_FOOBAR"));
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
|
||||
<property name="userMap">
|
||||
<value>
|
||||
marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_TELLER
|
||||
scott=wombat,ROLE_TELLER
|
||||
peter=opal,disabled,ROLE_TELLER
|
||||
|
|
|
@ -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.
|
||||
The password for all the files is "password"
|
||||
|
||||
- marissa.p12 is a pkcs12 file containing the client certificate and private key for
|
||||
the user marissa, and should be imported into your browser.
|
||||
- user.p12 is a pkcs12 file containing the client certificate and private key for
|
||||
a user, and should be imported into your browser.
|
||||
|
||||
- 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
|
||||
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.
|
||||
|
|
|
@ -129,9 +129,9 @@ public class ClientApplication {
|
|||
if ("".equals(username) || "".equals(password)) {
|
||||
System.out.println(
|
||||
"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, "
|
||||
+ "use: -Dusername=marissa -Dpassword=koala' for a single call per service and "
|
||||
+ "use: -Dusername=marissa -Dpassword=koala -DnrOfCalls=10 for ten calls per service.");
|
||||
+ "using the username, password, and nrOfCalls system properties respectively. eg for user rod, "
|
||||
+ "use: -Dusername=rod -Dpassword=koala' for a single call per service and "
|
||||
+ "use: -Dusername=rod -Dpassword=koala -DnrOfCalls=10 for ten calls per service.");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
int nrOfCalls = 1;
|
||||
|
|
|
@ -80,7 +80,7 @@ public class DataSourcePopulator implements InitializingBean {
|
|||
Assert.notNull(tt, "platformTransactionManager required");
|
||||
|
||||
// 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")});
|
||||
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
|
||||
Encoded password for marissa is "koala"
|
||||
Encoded password for rod is "koala"
|
||||
Encoded password for dianne is "emu"
|
||||
Encoded password for scott is "wombat"
|
||||
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"
|
||||
|
||||
*/
|
||||
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('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
|
||||
template.execute("INSERT INTO USERS VALUES('bill','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('bob','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('marissa','ROLE_SUPERVISOR');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
|
||||
|
@ -158,12 +158,12 @@ public class DataSourcePopulator implements InitializingBean {
|
|||
}
|
||||
|
||||
// Now grant some permissions
|
||||
grantPermissions(1, "marissa", BasePermission.ADMINISTRATION);
|
||||
grantPermissions(2, "marissa", BasePermission.READ);
|
||||
grantPermissions(3, "marissa", BasePermission.READ);
|
||||
grantPermissions(3, "marissa", BasePermission.WRITE);
|
||||
grantPermissions(3, "marissa", BasePermission.DELETE);
|
||||
grantPermissions(4, "marissa", BasePermission.ADMINISTRATION);
|
||||
grantPermissions(1, "rod", BasePermission.ADMINISTRATION);
|
||||
grantPermissions(2, "rod", BasePermission.READ);
|
||||
grantPermissions(3, "rod", BasePermission.READ);
|
||||
grantPermissions(3, "rod", BasePermission.WRITE);
|
||||
grantPermissions(3, "rod", BasePermission.DELETE);
|
||||
grantPermissions(4, "rod", BasePermission.ADMINISTRATION);
|
||||
grantPermissions(4, "dianne", BasePermission.ADMINISTRATION);
|
||||
grantPermissions(4, "scott", BasePermission.READ);
|
||||
grantPermissions(5, "dianne", BasePermission.ADMINISTRATION);
|
||||
|
@ -182,7 +182,7 @@ public class DataSourcePopulator implements InitializingBean {
|
|||
grantPermissions(9, "scott", BasePermission.DELETE);
|
||||
|
||||
// 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)
|
||||
changeOwner(5, "dianne");
|
||||
changeOwner(6, "dianne");
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
|
||||
<!-- 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 -->
|
||||
<!-- 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">
|
||||
<property name="userDetailsService" ref="jdbcDaoImpl" />
|
||||
<property name="switchUserUrl"><value>/j_spring_security_switch_user</value></property>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<P>Valid users:
|
||||
<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>scott</b>, password <b>wombat</b>
|
||||
<p>username <b>peter</b>, password <b>opal</b> (user disabled)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<P>Valid users:
|
||||
<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>scott</b>, password <b>wombat</b>
|
||||
<p>username <b>bill</b>, password <b>wombat</b>
|
||||
|
|
|
@ -110,7 +110,7 @@ public class GetAllContactsTests extends AbstractTransactionalSpringContextTests
|
|||
protected void makeActiveUser(String username) {
|
||||
String password = "";
|
||||
|
||||
if ("marissa".equals(username)) {
|
||||
if ("rod".equals(username)) {
|
||||
password = "koala";
|
||||
} else if ("dianne".equals(username)) {
|
||||
password = "emu";
|
||||
|
@ -148,8 +148,8 @@ public class GetAllContactsTests extends AbstractTransactionalSpringContextTests
|
|||
assertNotContainsContact(Long.toString(3), contacts);
|
||||
}
|
||||
|
||||
public void testMarissa() {
|
||||
makeActiveUser("marissa"); // has ROLE_SUPERVISOR
|
||||
public void testrod() {
|
||||
makeActiveUser("rod"); // has ROLE_SUPERVISOR
|
||||
|
||||
List contacts = contactManager.getAll();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
marissa=koala,ROLE_SUPERVISOR
|
||||
rod=koala,ROLE_SUPERVISOR
|
||||
dianne=emu,ROLE_USER
|
||||
scott=wombat,ROLE_USER
|
||||
peter=opal,disabled,ROLE_USER
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<P>Valid users:
|
||||
<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>scott</b>, password <b>wombat</b> (normal user)
|
||||
<p>username <b>peter</b>, password <b>opal</b> (user disabled)
|
||||
|
|
Loading…
Reference in New Issue