Class InternalUserDirectoryAuthenticationProvider
java.lang.Object
com.foreach.across.modules.user.security.AbstractUserInDirectoryAuthenticationProvider
com.foreach.across.modules.user.security.InternalUserDirectoryAuthenticationProvider
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.MessageSourceAware,org.springframework.security.authentication.AuthenticationProvider
public class InternalUserDirectoryAuthenticationProvider
extends AbstractUserInDirectoryAuthenticationProvider
Authenticates a user against a
InternalUserDirectory.- Since:
- 2.0.0
- Author:
- Arne Vandamme
-
Field Summary
Fields inherited from class com.foreach.across.modules.user.security.AbstractUserInDirectoryAuthenticationProvider
LOG, messages, userDirectory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadditionalAuthenticationChecks(org.springframework.security.core.userdetails.UserDetails userDetails, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) Allows subclasses to perform any additional checks of a returned (or cached)UserDetailsfor a given authentication request.protected org.springframework.security.core.userdetails.UserDetailsbuildUserDetails(User user, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) Allows subclasses to build theUserDetailsfor a givenUser.protected voidprotected org.springframework.security.crypto.password.PasswordEncodervoidsetPasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Sets the PasswordEncoder instance to be used to encode and validate passwords.Methods inherited from class com.foreach.across.modules.user.security.AbstractUserInDirectoryAuthenticationProvider
afterPropertiesSet, authenticate, createSuccessAuthentication, retrieveUser, setAuthoritiesMapper, setForcePrincipalAsString, setMessageSource, setPostAuthenticationChecks, setPreAuthenticationChecks, setThrowExceptionIfUserNotFound, setUserCache, setUserDirectory, setUserService, supports
-
Constructor Details
-
InternalUserDirectoryAuthenticationProvider
public InternalUserDirectoryAuthenticationProvider()
-
-
Method Details
-
doAfterPropertiesSet
- Overrides:
doAfterPropertiesSetin classAbstractUserInDirectoryAuthenticationProvider- Throws:
Exception
-
buildUserDetails
protected org.springframework.security.core.userdetails.UserDetails buildUserDetails(User user, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) throws org.springframework.security.core.AuthenticationException Description copied from class:AbstractUserInDirectoryAuthenticationProviderAllows subclasses to build theUserDetailsfor a givenUser. Actual credential validation can be performed and anAuthenticationExceptionthrown if validation fails. In case the method returnsnullthis will end in anullAuthenticationbeing returned by this provider. Note thatUseralready implementsUserDetails. If validation is successful, that same user instance can be returned by the method implementation.- Specified by:
buildUserDetailsin classAbstractUserInDirectoryAuthenticationProvider- Parameters:
user- The user found with the username from the authenticationauthentication- The authentication request, which subclasses may need to perform a binding-based retrieval of theUserDetails- Returns:
- the user information, can be
nullto fall back to being "unable to authenticate" - Throws:
org.springframework.security.core.AuthenticationException- if the credentials could not be validated
-
additionalAuthenticationChecks
protected void additionalAuthenticationChecks(org.springframework.security.core.userdetails.UserDetails userDetails, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) throws org.springframework.security.core.AuthenticationException Description copied from class:AbstractUserInDirectoryAuthenticationProviderAllows subclasses to perform any additional checks of a returned (or cached)UserDetailsfor a given authentication request. Generally a subclass will at least compare theAuthentication.getCredentials()with aUserDetails.getPassword(). If custom logic is needed to compare additional properties ofUserDetailsand/orUsernamePasswordAuthenticationToken, these should also appear in this method.- Specified by:
additionalAuthenticationChecksin classAbstractUserInDirectoryAuthenticationProvider- Parameters:
userDetails- as retrieved from theAbstractUserInDirectoryAuthenticationProvider.buildUserDetails(User, UsernamePasswordAuthenticationToken)orUserCacheauthentication- the current request that needs to be authenticated- Throws:
org.springframework.security.core.AuthenticationException- AuthenticationException if the credentials could not be validated (generally aBadCredentialsException, anAuthenticationServiceException)
-
getPasswordEncoder
protected org.springframework.security.crypto.password.PasswordEncoder getPasswordEncoder() -
setPasswordEncoder
public void setPasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Sets the PasswordEncoder instance to be used to encode and validate passwords. If not set, the password will be compared usingPasswordEncoderFactories.createDelegatingPasswordEncoder()- Parameters:
passwordEncoder- must be an instance of one of thePasswordEncodertypes.
-