Skip to content

Commit

Permalink
Polish ActiveDirectoryLdapAuthenticationProvider#setAuthoritiesPopulator
Browse files Browse the repository at this point in the history
Issue gh-4490
  • Loading branch information
jzheaux committed Feb 9, 2024
1 parent 98f0a21 commit 4aed679
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public ActiveDirectoryLdapAuthenticationProvider(String domain, String url, Stri
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
this.url = url;
this.rootDn = StringUtils.hasText(rootDn) ? rootDn.toLowerCase() : null;
this.setAuthoritiesPopulator(this.authoritiesPopulator);
}

/**
Expand All @@ -155,7 +154,6 @@ public ActiveDirectoryLdapAuthenticationProvider(String domain, String url) {
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
this.url = url;
this.rootDn = (this.domain != null) ? rootDnFromDomain(this.domain) : null;
this.setAuthoritiesPopulator(this.authoritiesPopulator);
}

@Override
Expand All @@ -179,6 +177,10 @@ protected DirContextOperations doAuthentication(UsernamePasswordAuthenticationTo
}
}

/**
* Creates the user authority list from the values of the {@code memberOf} attribute
* obtained from the user's Active Directory entry.
*/
@Override
protected Collection<? extends GrantedAuthority> loadUserAuthorities(DirContextOperations userData, String username,
String password) {
Expand Down Expand Up @@ -389,7 +391,7 @@ public void setContextEnvironmentProperties(Map<String, Object> environment) {
* @since 6.3
*/
public void setAuthoritiesPopulator(LdapAuthoritiesPopulator authoritiesPopulator) {
Assert.notNull(authoritiesPopulator, "An LdapAuthoritiesPopulator must be supplied");
Assert.notNull(authoritiesPopulator, "authoritiesPopulator must not be null");
this.authoritiesPopulator = authoritiesPopulator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*
* @author Luke Taylor
* @author Roman Zabaluev
* @since 6.3
*/
public final class DefaultActiveDirectoryAuthoritiesPopulator implements LdapAuthoritiesPopulator {

Expand Down

0 comments on commit 4aed679

Please sign in to comment.