Class AbstractLdapAuthenticationManagerFactory<T extends AbstractLdapAuthenticator>
- java.lang.Object
-
- org.springframework.security.config.ldap.AbstractLdapAuthenticationManagerFactory<T>
-
- Direct Known Subclasses:
LdapBindAuthenticationManagerFactory,LdapPasswordComparisonAuthenticationManagerFactory
public abstract class AbstractLdapAuthenticationManagerFactory<T extends AbstractLdapAuthenticator> extends java.lang.ObjectCreates anAuthenticationManagerthat can perform LDAP authentication.- Since:
- 5.7
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AuthenticationManagercreateAuthenticationManager()Returns the configuredAuthenticationManagerthat can be used to perform LDAP authentication.protected abstract TcreateDefaultLdapAuthenticator()Allows subclasses to supply the defaultAbstractLdapAuthenticator.protected org.springframework.ldap.core.support.BaseLdapPathContextSourcegetContextSource()Gets theBaseLdapPathContextSourceused to perform LDAP authentication.voidsetAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper)Sets theGrantedAuthoritiesMapperused for converting the authorities loaded from storage to a new set of authorities which will be associated to theUsernamePasswordAuthenticationToken.voidsetContextSource(org.springframework.ldap.core.support.BaseLdapPathContextSource contextSource)Sets theBaseLdapPathContextSourceused to perform LDAP authentication.voidsetLdapAuthoritiesPopulator(LdapAuthoritiesPopulator ldapAuthoritiesPopulator)Sets theLdapAuthoritiesPopulatorused to obtain a list of granted authorities for an LDAP user.voidsetUserDetailsContextMapper(UserDetailsContextMapper userDetailsContextMapper)Sets a custom strategy to be used for creating theUserDetailswhich will be stored as the principal in theAuthentication.voidsetUserDnPatterns(java.lang.String... userDnPatterns)If your users are at a fixed location in the directory (i.e.voidsetUserSearchBase(java.lang.String userSearchBase)Search base for user searches.voidsetUserSearchFilter(java.lang.String userSearchFilter)The LDAP filter used to search for users (optional).
-
-
-
Method Detail
-
setContextSource
public void setContextSource(org.springframework.ldap.core.support.BaseLdapPathContextSource contextSource)
Sets theBaseLdapPathContextSourceused to perform LDAP authentication.- Parameters:
contextSource- theBaseLdapPathContextSourceused to perform LDAP authentication
-
getContextSource
protected final org.springframework.ldap.core.support.BaseLdapPathContextSource getContextSource()
Gets theBaseLdapPathContextSourceused to perform LDAP authentication.- Returns:
- the
BaseLdapPathContextSourceused to perform LDAP authentication
-
setLdapAuthoritiesPopulator
public void setLdapAuthoritiesPopulator(LdapAuthoritiesPopulator ldapAuthoritiesPopulator)
Sets theLdapAuthoritiesPopulatorused to obtain a list of granted authorities for an LDAP user.- Parameters:
ldapAuthoritiesPopulator- theLdapAuthoritiesPopulatorto use
-
setAuthoritiesMapper
public void setAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper)
Sets theGrantedAuthoritiesMapperused for converting the authorities loaded from storage to a new set of authorities which will be associated to theUsernamePasswordAuthenticationToken.- Parameters:
authoritiesMapper- theGrantedAuthoritiesMapperused for mapping the user's authorities
-
setUserDetailsContextMapper
public void setUserDetailsContextMapper(UserDetailsContextMapper userDetailsContextMapper)
Sets a custom strategy to be used for creating theUserDetailswhich will be stored as the principal in theAuthentication.- Parameters:
userDetailsContextMapper- the strategy instance
-
setUserDnPatterns
public void setUserDnPatterns(java.lang.String... userDnPatterns)
If your users are at a fixed location in the directory (i.e. you can work out the DN directly from the username without doing a directory search), you can use this attribute to map directly to the DN. It maps directly to the userDnPatterns property of AbstractLdapAuthenticator. The value is a specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username.- Parameters:
userDnPatterns- the LDAP patterns for finding the usernames
-
setUserSearchFilter
public void setUserSearchFilter(java.lang.String userSearchFilter)
The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name.- Parameters:
userSearchFilter- the LDAP filter used to search for users
-
setUserSearchBase
public void setUserSearchBase(java.lang.String userSearchBase)
Search base for user searches. Defaults to "". Only used withsetUserSearchFilter(String).- Parameters:
userSearchBase- search base for user searches
-
createAuthenticationManager
public final AuthenticationManager createAuthenticationManager()
Returns the configuredAuthenticationManagerthat can be used to perform LDAP authentication.- Returns:
- the configured
AuthenticationManager
-
createDefaultLdapAuthenticator
protected abstract T createDefaultLdapAuthenticator()
Allows subclasses to supply the defaultAbstractLdapAuthenticator.- Returns:
- the
AbstractLdapAuthenticatorthat will be configured for LDAP authentication
-
-