Class AbstractLdapAuthenticationProvider
- java.lang.Object
- 
- org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider
 
- 
- All Implemented Interfaces:
- org.springframework.beans.factory.Aware,- org.springframework.context.MessageSourceAware,- AuthenticationProvider
 - Direct Known Subclasses:
- ActiveDirectoryLdapAuthenticationProvider,- LdapAuthenticationProvider
 
 public abstract class AbstractLdapAuthenticationProvider extends java.lang.Object implements AuthenticationProvider, org.springframework.context.MessageSourceAware Base class for the standardLdapAuthenticationProviderand theActiveDirectoryLdapAuthenticationProvider.- Since:
- 3.1
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected org.apache.commons.logging.Logloggerprotected org.springframework.context.support.MessageSourceAccessormessagesprotected UserDetailsContextMapperuserDetailsContextMapper
 - 
Constructor SummaryConstructors Constructor Description AbstractLdapAuthenticationProvider()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Authenticationauthenticate(Authentication authentication)Performs authentication with the same contract asAuthenticationManager.authenticate(Authentication).protected AuthenticationcreateSuccessfulAuthentication(UsernamePasswordAuthenticationToken authentication, UserDetails user)Creates the finalAuthenticationobject which will be returned from theauthenticatemethod.protected abstract org.springframework.ldap.core.DirContextOperationsdoAuthentication(UsernamePasswordAuthenticationToken auth)protected UserDetailsContextMappergetUserDetailsContextMapper()Provides access to the injectedUserDetailsContextMapperstrategy for use by subclasses.protected abstract java.util.Collection<? extends GrantedAuthority>loadUserAuthorities(org.springframework.ldap.core.DirContextOperations userData, java.lang.String username, java.lang.String password)voidsetAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper)voidsetMessageSource(org.springframework.context.MessageSource messageSource)voidsetUseAuthenticationRequestCredentials(boolean useAuthenticationRequestCredentials)Determines whether the supplied password will be used as the credentials in the successful authentication token.voidsetUserDetailsContextMapper(UserDetailsContextMapper userDetailsContextMapper)Allows a custom strategy to be used for creating the UserDetails which will be stored as the principal in the Authentication returned by thecreateSuccessfulAuthentication(org.springframework.security.authentication.UsernamePasswordAuthenticationToken, org.springframework.security.core.userdetails.UserDetails)method.booleansupports(java.lang.Class<?> authentication)Returnstrueif thisAuthenticationProvidersupports the indicatedAuthenticationobject.
 
- 
- 
- 
Field Detail- 
loggerprotected final org.apache.commons.logging.Log logger 
 - 
messagesprotected org.springframework.context.support.MessageSourceAccessor messages 
 - 
userDetailsContextMapperprotected UserDetailsContextMapper userDetailsContextMapper 
 
- 
 - 
Method Detail- 
authenticatepublic Authentication authenticate(Authentication authentication) throws AuthenticationException Description copied from interface:AuthenticationProviderPerforms authentication with the same contract asAuthenticationManager.authenticate(Authentication).- Specified by:
- authenticatein interface- AuthenticationProvider
- Parameters:
- authentication- the authentication request object.
- Returns:
- a fully authenticated object including credentials. May return
 nullif theAuthenticationProvideris unable to support authentication of the passedAuthenticationobject. In such a case, the nextAuthenticationProviderthat supports the presentedAuthenticationclass will be tried.
- Throws:
- AuthenticationException- if authentication fails.
 
 - 
doAuthenticationprotected abstract org.springframework.ldap.core.DirContextOperations doAuthentication(UsernamePasswordAuthenticationToken auth) 
 - 
loadUserAuthoritiesprotected abstract java.util.Collection<? extends GrantedAuthority> loadUserAuthorities(org.springframework.ldap.core.DirContextOperations userData, java.lang.String username, java.lang.String password) 
 - 
createSuccessfulAuthenticationprotected Authentication createSuccessfulAuthentication(UsernamePasswordAuthenticationToken authentication, UserDetails user) Creates the finalAuthenticationobject which will be returned from theauthenticatemethod.- Parameters:
- authentication- the original authentication request token
- user- the UserDetails instance returned by the configured UserDetailsContextMapper.
- Returns:
- the Authentication object for the fully authenticated user.
 
 - 
supportspublic boolean supports(java.lang.Class<?> authentication) Description copied from interface:AuthenticationProviderReturnstrueif thisAuthenticationProvidersupports the indicatedAuthenticationobject.Returning truedoes not guarantee anAuthenticationProviderwill be able to authenticate the presented instance of theAuthenticationclass. It simply indicates it can support closer evaluation of it. AnAuthenticationProvidercan still returnnullfrom theAuthenticationProvider.authenticate(Authentication)method to indicate anotherAuthenticationProvidershould be tried.Selection of an AuthenticationProvidercapable of performing authentication is conducted at runtime theProviderManager.- Specified by:
- supportsin interface- AuthenticationProvider
- Returns:
- trueif the implementation can more closely evaluate the- Authenticationclass presented
 
 - 
setUseAuthenticationRequestCredentialspublic void setUseAuthenticationRequestCredentials(boolean useAuthenticationRequestCredentials) Determines whether the supplied password will be used as the credentials in the successful authentication token. If set to false, then the password will be obtained from the UserDetails object created by the configuredUserDetailsContextMapper. Often it will not be possible to read the password from the directory, so defaults to true.- Parameters:
- useAuthenticationRequestCredentials-
 
 - 
setMessageSourcepublic void setMessageSource(org.springframework.context.MessageSource messageSource) - Specified by:
- setMessageSourcein interface- org.springframework.context.MessageSourceAware
 
 - 
setAuthoritiesMapperpublic void setAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper) 
 - 
setUserDetailsContextMapperpublic void setUserDetailsContextMapper(UserDetailsContextMapper userDetailsContextMapper) Allows a custom strategy to be used for creating the UserDetails which will be stored as the principal in the Authentication returned by thecreateSuccessfulAuthentication(org.springframework.security.authentication.UsernamePasswordAuthenticationToken, org.springframework.security.core.userdetails.UserDetails)method.- Parameters:
- userDetailsContextMapper- the strategy instance. If not set, defaults to a simple LdapUserDetailsMapper.
 
 - 
getUserDetailsContextMapperprotected UserDetailsContextMapper getUserDetailsContextMapper() Provides access to the injectedUserDetailsContextMapperstrategy for use by subclasses.
 
- 
 
-