SEC-1641: Correct code and test for null groupSearchBase.

This commit is contained in:
Luke Taylor
2010-12-20 16:50:11 +00:00
parent 428a0b7dce
commit dbe270f132
2 changed files with 5 additions and 3 deletions

View File

@@ -146,7 +146,9 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
ldapTemplate.setSearchControls(searchControls);
this.groupSearchBase = groupSearchBase;
if (groupSearchBase.length() == 0) {
if (groupSearchBase == null) {
logger.info("groupSearchBase is null. No group search will be performed.");
} else if (groupSearchBase.length() == 0) {
logger.info("groupSearchBase is empty. Searches will be performed from the context source base");
}
}
@@ -200,7 +202,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
public Set<GrantedAuthority> getGroupMembershipRoles(String userDn, String username) {
if (getGroupSearchBase() == null) {
return Collections.emptySet();
return new HashSet<GrantedAuthority>();
}
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();