Updates to getGrantedAuthorityString as suggested by Matt DeHoust to make functionality match javadocs.

This commit is contained in:
Robert Sanders 2005-04-18 18:56:33 +00:00
parent 48ad6496e4
commit 74a5a505d5
1 changed files with 18 additions and 1 deletions

View File

@ -446,7 +446,7 @@ public class LdapPasswordAuthenticationDao implements PasswordAuthenticationDao
if (upperCaseRoleNames) {
roleName = roleName.toUpperCase();
}
GrantedAuthority ga = new GrantedAuthorityImpl(roleName);
GrantedAuthority ga = new GrantedAuthorityImpl( roleName.replaceAll("[,=\\s]", "_") );
if (log.isDebugEnabled()) {
log.debug("GrantedAuthority: " + ga);
@ -454,6 +454,23 @@ public class LdapPasswordAuthenticationDao implements PasswordAuthenticationDao
return ga;
}
/*
public void testGetGrantedAuthorityString() {
LdapPasswordAuthenticationDao uut = new LdapPasswordAuthenticationDao();
String[] test = {
"ROLE ABC DEF", "ROLE ABC,DEF", "ROLE ABC=DEF", "ROLE ABC_DEF",
"ROLE,ABC DEF", "ROLE,ABC,DEF", "ROLE,ABC=DEF", "ROLE,ABC_DEF",
"ROLE=ABC DEF", "ROLE=ABC,DEF", "ROLE=ABC=DEF", "ROLE=ABC_DEF",
"ROLE_ABC DEF", "ROLE_ABC,DEF", "ROLE_ABC=DEF", "ROLE_ABC_DEF",
};
final String expected = "ROLE_ABC_DEF";
for (int i = 0; i < test.length; i++) {
assertEquals("Unexpected granted authority name.", expected,
uut.getGrantedAuthority(test[i]).getAuthority());
}
}
*/
/**
* @return The InitialContextFactory for creating the root JNDI context; defaults to "com.sun.jndi.ldap.LdapCtxFactory"