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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
additionalAuthenticationChecks
(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)UserDetails
for a given authentication request.protected org.springframework.security.core.userdetails.UserDetails
buildUserDetails
(User user, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) Allows subclasses to build theUserDetails
for a givenUser
.protected void
protected org.springframework.security.crypto.password.PasswordEncoder
void
setPasswordEncoder
(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:
doAfterPropertiesSet
in 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:AbstractUserInDirectoryAuthenticationProvider
Allows subclasses to build theUserDetails
for a givenUser
. Actual credential validation can be performed and anAuthenticationException
thrown if validation fails. In case the method returnsnull
this will end in anull
Authentication
being returned by this provider. Note thatUser
already implementsUserDetails
. If validation is successful, that same user instance can be returned by the method implementation.- Specified by:
buildUserDetails
in 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
null
to 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:AbstractUserInDirectoryAuthenticationProvider
Allows subclasses to perform any additional checks of a returned (or cached)UserDetails
for 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 ofUserDetails
and/orUsernamePasswordAuthenticationToken
, these should also appear in this method.- Specified by:
additionalAuthenticationChecks
in classAbstractUserInDirectoryAuthenticationProvider
- Parameters:
userDetails
- as retrieved from theAbstractUserInDirectoryAuthenticationProvider.buildUserDetails(User, UsernamePasswordAuthenticationToken)
orUserCache
authentication
- 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 thePasswordEncoder
types.
-