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
Fields inherited from class ch.tocco.nice2.security.spi.auth.AbstractUsernamePasswordAuthHandler
ATTR_PRINCIPAL_DETAILS, authenticators
Fields inherited from interface ch.tocco.nice2.security.spi.auth.AuthenticationHandler
ANONYMOUS_HANDLER_ORDER, API_KEY_PK_ATTRIBUTE, PRINCIPAL_PK_ATTRIBUTE, SESSION_HASH_HANDLER_ORDER, SESSION_ID_ATTRIBUTE
-
Constructor Summary
ConstructorDescriptionDbAuthenticationHandler
(org.slf4j.Logger log, PrincipalService principalService, PasswordEncoder passwordEncoder) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
void
doAuthenticate
(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 boolean
doSetCredentials
(PrincipalDetails principalDetails, UsernamePasswordCredentials oldCredentials, Credentials newCredentials) Set new credentials for the passed principal.void
postAuthenticate
(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.void
setPrivilegedRoles
(List<String> privilegedRoles) Methods inherited from class ch.tocco.nice2.security.spi.auth.AbstractUsernamePasswordAuthHandler
authenticate, getPrincipalDetailService, initializeService, setAuthenticators, setPrincipalService, updateCredentials
Methods inherited from class ch.tocco.nice2.security.spi.auth.AuthenticationHandlerAdapter
getName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.security.spi.auth.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:AbstractUsernamePasswordAuthHandler
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.As subclasses configure its instance with their concrete
PrincipalDetailService
you are safe to cast thePrincipalDetails
argument to your specific type.- Specified by:
doAuthenticate
in 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:AbstractUsernamePasswordAuthHandler
Set new credentials for the passed principal. This is only invoked for any instance ofUsernamePasswordCredentials
that were used to get the principal. The old credentials are also passed in together with new credentials.The type of argument
newCredentials
should be used to check if this handler supports setting new credentials. Returnfalse
if the type ofnewCredentials
is not supported.- Specified by:
doSetCredentials
in classAbstractUsernamePasswordAuthHandler
- Parameters:
principalDetails
- details about the principal that wants to set new credentialsoldCredentials
- the old credentials of the principalnewCredentials
- new credentials to set.- Returns:
true
if setting was successful,false
if action was skipped
-
currentUserIsPrivileged
protected boolean currentUserIsPrivileged() -
postAuthenticate
Description copied from interface:AuthenticationHandler
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.
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:
postAuthenticate
in interfaceAuthenticationHandler
- Overrides:
postAuthenticate
in classAuthenticationHandlerAdapter
- Parameters:
challenge
- the challenge to authenticate
-