Class DbAuthenticationHandler
- All Implemented Interfaces:
AuthenticationHandler
UsernamePasswordCredentials.
It supports setting new credentials as well es requesting credentials for a user. When setting
new credentials, the new credentials must be of type UserCredentialsChange.
-
Field Summary
FieldsFields inherited from class AbstractUsernamePasswordAuthHandler
ATTR_PRINCIPAL_DETAILS, authenticatorsFields inherited from interface AuthenticationHandler
ANONYMOUS_HANDLER_ORDER, API_KEY_PK_ATTRIBUTE, PRINCIPAL_PK_ATTRIBUTE, SESSION_HASH_HANDLER_ORDER, SESSION_ID_ATTRIBUTE -
Constructor Summary
ConstructorsConstructorDescriptionDbAuthenticationHandler(org.slf4j.Logger log, PrincipalService principalService, PasswordEncoder passwordEncoder) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanvoiddoAuthenticate(Challenge challenge, @Nullable PrincipalDetails principalDetails, UsernamePasswordCredentials credentials) After the principal is retrieved using the configuredPrincipalDetailService, this method is invoked right afterwards to let subclasses do further authentication checks and finally call theChallenge.vote(Challenge.State)method.protected booleandoSetCredentials(PrincipalDetails principalDetails, UsernamePasswordCredentials oldCredentials, Credentials newCredentials) Set new credentials for the passed principal.voidpostAuthenticate(Challenge challenge) After authentication has been successful for all registered AuthenticationHandlers, the post-authentication step is invoked to add more authorization information to the principal which is sure to be not null and authenticated when this method is invoked.voidsetPrivilegedRoles(List<String> privilegedRoles) Methods inherited from class AbstractUsernamePasswordAuthHandler
authenticate, getPrincipalDetailService, initializeService, setAuthenticators, setPrincipalService, updateCredentialsMethods inherited from class AuthenticationHandlerAdapter
getNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AuthenticationHandler
postEventListeners
-
Field Details
-
ORDER
public static final int ORDER- See Also:
-
-
Constructor Details
-
DbAuthenticationHandler
public DbAuthenticationHandler(org.slf4j.Logger log, PrincipalService principalService, PasswordEncoder passwordEncoder)
-
-
Method Details
-
setPrivilegedRoles
-
doAuthenticate
public void doAuthenticate(Challenge challenge, @Nullable @Nullable PrincipalDetails principalDetails, UsernamePasswordCredentials credentials) Description copied from class:AbstractUsernamePasswordAuthHandlerAfter the principal is retrieved using the configuredPrincipalDetailService, this method is invoked right afterwards to let subclasses do further authentication checks and finally call theChallenge.vote(Challenge.State)method.As subclasses configure its instance with their concrete
PrincipalDetailServiceyou are safe to cast thePrincipalDetailsargument to your specific type.- Specified by:
doAuthenticatein classAbstractUsernamePasswordAuthHandler- Parameters:
challenge- the challenge to be authenticatedprincipalDetails- the principal details just loaded (may be null if principal could not be found)credentials- the concrete username and password credentials
-
doSetCredentials
protected boolean doSetCredentials(PrincipalDetails principalDetails, UsernamePasswordCredentials oldCredentials, Credentials newCredentials) Description copied from class:AbstractUsernamePasswordAuthHandlerSet new credentials for the passed principal. This is only invoked for any instance ofUsernamePasswordCredentialsthat were used to get the principal. The old credentials are also passed in together with new credentials.The type of argument
newCredentialsshould be used to check if this handler supports setting new credentials. Returnfalseif the type ofnewCredentialsis not supported.- Specified by:
doSetCredentialsin classAbstractUsernamePasswordAuthHandler- Parameters:
principalDetails- details about the principal that wants to set new credentialsoldCredentials- the old credentials of the principalnewCredentials- new credentials to set.- Returns:
trueif setting was successful,falseif action was skipped
-
currentUserIsPrivileged
protected boolean currentUserIsPrivileged() -
postAuthenticate
Description copied from interface:AuthenticationHandlerAfter authentication has been successful for all registered AuthenticationHandlers, the post-authentication step is invoked to add more authorization information to the principal which is sure to be not null and authenticated when this method is invoked.
This handler may also decide in this step to give a new vote for this challenge which overrides the previously given vote.
If this throws any exception, authentication process is immediately stopped to failed state.
- Specified by:
postAuthenticatein interfaceAuthenticationHandler- Overrides:
postAuthenticatein classAuthenticationHandlerAdapter- Parameters:
challenge- the challenge to authenticate
-