public abstract class AbstractAuthenticationManager extends java.lang.Object implements AuthenticationManager
AbstractAuthenticationManager
, which provides common operations
around an authentication manager implementation.Modifier and Type | Field and Description |
---|---|
protected AuthenticationEventExecutionPlan |
authenticationEventExecutionPlan
Plan to execute the authentication transaction.
|
protected AuthenticationHandlerResolver |
authenticationHandlerResolver
The Authentication handler resolver.
|
protected boolean |
principalResolutionFailureFatal
Indicate if principal resolution should totally fail
and no fall back onto principal that is produced by the
authentication handler.
|
AUTHENTICATION_METHOD_ATTRIBUTE
Modifier | Constructor and Description |
---|---|
protected |
AbstractAuthenticationManager(AuthenticationEventExecutionPlan authenticationEventExecutionPlan,
AuthenticationHandlerResolver authenticationHandlerResolver,
boolean principalResolutionFatal)
Creates a new authentication manager with a map of authentication handlers to the principal resolvers that
should be used upon successful authentication if no principal is resolved by the authentication handler.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAuthenticationMethodAttribute(AuthenticationBuilder builder,
Authentication authentication)
Add authentication method attribute.
|
Authentication |
authenticate(AuthenticationTransaction transaction)
Authenticates the provided credentials.
|
protected void |
authenticateAndResolvePrincipal(AuthenticationBuilder builder,
Credential credential,
PrincipalResolver resolver,
AuthenticationHandler handler)
Authenticate and resolve principal.
|
protected abstract AuthenticationBuilder |
authenticateInternal(AuthenticationTransaction transaction)
Follows the same contract as
AuthenticationManager.authenticate(AuthenticationTransaction) . |
protected java.util.Set<AuthenticationHandler> |
getAuthenticationHandlersForThisTransaction(AuthenticationTransaction transaction)
Gets authentication handlers for this transaction.
|
protected java.util.Collection<AuthenticationMetaDataPopulator> |
getAuthenticationMetadataPopulatorsForTransaction(AuthenticationTransaction transaction)
Gets authentication metadata populators for transaction.
|
protected PrincipalResolver |
getPrincipalResolverLinkedToHandlerIfAny(AuthenticationHandler handler,
AuthenticationTransaction transaction)
Gets principal resolver linked to the handler if any.
|
protected void |
populateAuthenticationMetadataAttributes(AuthenticationBuilder builder,
AuthenticationTransaction transaction)
Populate authentication metadata attributes.
|
protected void |
publishEvent(org.springframework.context.ApplicationEvent event)
Publish event.
|
protected Principal |
resolvePrincipal(AuthenticationHandler handler,
PrincipalResolver resolver,
Credential credential,
Principal principal)
Resolve principal.
|
protected final AuthenticationEventExecutionPlan authenticationEventExecutionPlan
protected final AuthenticationHandlerResolver authenticationHandlerResolver
protected boolean principalResolutionFailureFatal
protected AbstractAuthenticationManager(AuthenticationEventExecutionPlan authenticationEventExecutionPlan, AuthenticationHandlerResolver authenticationHandlerResolver, boolean principalResolutionFatal)
LinkedHashMap
) should be used.authenticationEventExecutionPlan
- Describe the execution plan for this managerauthenticationHandlerResolver
- the authentication handler resolverprincipalResolutionFatal
- the principal resolution fatalprotected void populateAuthenticationMetadataAttributes(AuthenticationBuilder builder, AuthenticationTransaction transaction)
builder
- the buildertransaction
- the transactionprotected void addAuthenticationMethodAttribute(AuthenticationBuilder builder, Authentication authentication)
builder
- the builderauthentication
- the authenticationprotected Principal resolvePrincipal(AuthenticationHandler handler, PrincipalResolver resolver, Credential credential, Principal principal)
handler
- the handler nameresolver
- the resolvercredential
- the credentialprincipal
- the current authenticated principal from a handler, if any.@Timed(name="AUTHENTICATE_TIMER") @Metered(name="AUTHENTICATE_METER") @Counted(name="AUTHENTICATE_COUNT", monotonic=true) public Authentication authenticate(AuthenticationTransaction transaction) throws AuthenticationException
AuthenticationManager
Authentication
object
is returned containing metadata about the result of each authenticated credential.
Note that a particular implementation may require some or all credentials to be
successfully authenticated. Failure to authenticate is considered an exceptional case, and
an AuthenticationException is thrown.authenticate
in interface AuthenticationManager
transaction
- Process a single authentication transactionAuthenticationException
- On authentication failure. The exception contains details
on each of the credentials that failed to authenticate.protected void authenticateAndResolvePrincipal(AuthenticationBuilder builder, Credential credential, PrincipalResolver resolver, AuthenticationHandler handler) throws java.security.GeneralSecurityException, PreventedException
builder
- the buildercredential
- the credentialresolver
- the resolverhandler
- the handlerjava.security.GeneralSecurityException
- the general security exceptionPreventedException
- the prevented exceptionprotected abstract AuthenticationBuilder authenticateInternal(AuthenticationTransaction transaction) throws AuthenticationException
AuthenticationManager.authenticate(AuthenticationTransaction)
.transaction
- the authentication transactionAuthenticationException
- When one or more credentials failed authentication such that security policy was not satisfied.protected java.util.Set<AuthenticationHandler> getAuthenticationHandlersForThisTransaction(AuthenticationTransaction transaction)
transaction
- the transactionprotected PrincipalResolver getPrincipalResolverLinkedToHandlerIfAny(AuthenticationHandler handler, AuthenticationTransaction transaction)
handler
- the handlertransaction
- the transactionprotected java.util.Collection<AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulatorsForTransaction(AuthenticationTransaction transaction)
transaction
- the transactionprotected void publishEvent(org.springframework.context.ApplicationEvent event)
event
- the event