mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-04 01:32:14 +00:00
SEC-1641: Correct code and test for null groupSearchBase.
This commit is contained in:
parent
952af853ac
commit
d0bada2bad
@ -143,7 +143,9 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
|
|||||||
ldapTemplate.setSearchControls(searchControls);
|
ldapTemplate.setSearchControls(searchControls);
|
||||||
this.groupSearchBase = groupSearchBase;
|
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");
|
logger.info("groupSearchBase is empty. Searches will be performed from the context source base");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +199,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
|
|||||||
|
|
||||||
public Set<GrantedAuthority> getGroupMembershipRoles(String userDn, String username) {
|
public Set<GrantedAuthority> getGroupMembershipRoles(String userDn, String username) {
|
||||||
if (getGroupSearchBase() == null) {
|
if (getGroupSearchBase() == null) {
|
||||||
return Collections.emptySet();
|
return new HashSet<GrantedAuthority>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
||||||
|
@ -58,7 +58,7 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapIntegratio
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nullSearchBaseIsAccepted() throws Exception {
|
public void nullSearchBaseIsAccepted() throws Exception {
|
||||||
populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), "ou=groups");
|
populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), null);
|
||||||
populator.setDefaultRole("ROLE_USER");
|
populator.setDefaultRole("ROLE_USER");
|
||||||
|
|
||||||
Collection<GrantedAuthority> authorities = populator.getGrantedAuthorities(
|
Collection<GrantedAuthority> authorities = populator.getGrantedAuthorities(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user