Package net.shibboleth.idp.authn.impl
Class ValidateCredentials
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.AbstractConditionalProfileAction
net.shibboleth.idp.profile.AbstractProfileAction
net.shibboleth.idp.authn.AbstractAuthenticationAction
net.shibboleth.idp.authn.AbstractValidationAction
net.shibboleth.idp.authn.impl.AbstractAuditingValidationAction
net.shibboleth.idp.authn.impl.ValidateCredentials
- All Implemented Interfaces:
CredentialValidator.ErrorHandler
,CredentialValidator.WarningHandler
,PrincipalSupportingComponent
,Component
,DestructableComponent
,InitializableComponent
,ProfileAction
,Aware
,MessageSource
,MessageSourceAware
,Action
public class ValidateCredentials
extends AbstractAuditingValidationAction
implements CredentialValidator.WarningHandler, CredentialValidator.ErrorHandler
An action that processes a list of
CredentialValidator
objects to produce an AuthenticationResult
.- Since:
- 4.0.0
- Event:
EventIds.PROCEED_EVENT_ID
, others on error- Precondition:
ProfileRequestContext.getSubcontext(AuthenticationContext.class).getAttemptedFlow() != null
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A default cleanup hook that removes theUsernamePasswordContext
from the tree. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<CredentialValidator>
Ordered list of validators.private CredentialValidator
Currently executing validator.private static final String
Default prefix for metrics.private boolean
Tracks whether an error event was signaled.private AccountLockoutManager
Optional lockout management interface.private final org.slf4j.Logger
Class logger.private boolean
Whether all validators must succeed.private Collection<Subject>
Results from successful validators.private boolean
Tracks whether a warning event was signaled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doExecute
(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Performs this authentication action.getAuditFields
(ProfileRequestContext profileRequestContext) Subclasses can override this method to supply additional audit fields to store.Get the base name to use for metrics reported.void
handleError
(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, Exception e, String eventId) Adds an exception encountered during the action to anAuthenticationErrorContext
, creating one if necessary, beneath theAuthenticationContext
.void
handleError
(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, String message, String eventId) Evaluates a message as a potential match as a "classified" error and if matched, the classification label is attached to anAuthenticationErrorContext
and used as the resulting event for the action.void
handleWarning
(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, String message, String eventId) Evaluates a message as a potential match as a "classified" warning and if matched, the classification label is attached to anAuthenticationWarningContext
and used as the resulting event for the action.protected Subject
populateSubject
(Subject subject) protected void
recordSuccess
(ProfileRequestContext profileRequestContext) Record a successful authentication attempt against the configured counter.void
setLockoutManager
(AccountLockoutManager manager) Set an account lockout management component.void
setRequireAll
(boolean flag) Set whether to execute and require success from all configured validators, or stop at the first successful result.void
setValidators
(List<CredentialValidator> validators) Set the list of validators to use.Methods inherited from class net.shibboleth.idp.authn.impl.AbstractAuditingValidationAction
doAudit, doExecute, getAuditContext, recordFailure, setAuditContextCreationStrategy, setPopulateAuditContextAction, setWriteAuditLogAction
Methods inherited from class net.shibboleth.idp.authn.AbstractValidationAction
addDefaultPrincipals, buildAuthenticationResult, doPreExecute, getClassifiedErrors, getCleanupHook, getRequesterLookupStrategy, getResponderLookupStrategy, getResultCachingPredicate, getSubject, getSupportedPrincipals, recordFailure, recordSuccess, setAddDefaultPrincipals, setClassifiedMessages, setCleanupHook, setMetricName, setRequesterLookupStrategy, setResponderLookupStrategy, setResultCachingPredicate, setSupportedPrincipals
Methods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doPreExecute, setAuthenticationContextLookupStrategy
Methods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategy
Methods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationCondition
Methods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, setHttpServletRequest, setHttpServletRequestSupplier, setHttpServletResponse, setHttpServletResponseSupplier
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
DEFAULT_METRIC_NAME
Default prefix for metrics.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
credentialValidators
Ordered list of validators. -
requireAll
private boolean requireAllWhether all validators must succeed. -
lockoutManager
Optional lockout management interface. -
results
Results from successful validators. -
currentValidator
Currently executing validator. -
warningSignaled
private boolean warningSignaledTracks whether a warning event was signaled. -
errorSignaled
private boolean errorSignaledTracks whether an error event was signaled.
-
-
Constructor Details
-
ValidateCredentials
public ValidateCredentials()Constructor.
-
-
Method Details
-
setLockoutManager
Set an account lockout management component.- Parameters:
manager
- lockout manager
-
setValidators
Set the list of validators to use.- Parameters:
validators
- validators to use
-
setRequireAll
public void setRequireAll(boolean flag) Set whether to execute and require success from all configured validators, or stop at the first successful result.- Parameters:
flag
- flag to set
-
getMetricName
Get the base name to use for metrics reported.- Overrides:
getMetricName
in classAbstractValidationAction
- Returns:
- root for name of metrics
-
handleWarning
public void handleWarning(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable String message, @Nonnull @NotEmpty String eventId) Evaluates a message as a potential match as a "classified" warning and if matched, the classification label is attached to anAuthenticationWarningContext
and used as the resulting event for the action.If no match, the supplied eventId is used as the result.
If multiple matches, the first matching label is used as the result, but each match is added to the context.
- Specified by:
handleWarning
in interfaceCredentialValidator.WarningHandler
- Overrides:
handleWarning
in classAbstractValidationAction
- Parameters:
profileRequestContext
- the current profile request contextauthenticationContext
- the current authentication contextmessage
- to processeventId
- the event to "return" via anEventContext
if the message is not classified
-
handleError
public void handleError(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable String message, @Nonnull @NotEmpty String eventId) Evaluates a message as a potential match as a "classified" error and if matched, the classification label is attached to anAuthenticationErrorContext
and used as the resulting event for the action.If no match, the supplied eventId is used as the result.
If multiple matches, the first matching label is used as the result, but each match is added to the context.
- Specified by:
handleError
in interfaceCredentialValidator.ErrorHandler
- Overrides:
handleError
in classAbstractValidationAction
- Parameters:
profileRequestContext
- the current profile request contextauthenticationContext
- the current authentication contextmessage
- to processeventId
- the event to "return" via anEventContext
if the message is not classified
-
handleError
public void handleError(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nonnull Exception e, @Nonnull @NotEmpty String eventId) Adds an exception encountered during the action to anAuthenticationErrorContext
, creating one if necessary, beneath theAuthenticationContext
.The exception message is evaluated as a potential match as a "classified" error and if matched, the classification label is attached to the
AuthenticationErrorContext
and used as the resulting event for the action.- Specified by:
handleError
in interfaceCredentialValidator.ErrorHandler
- Overrides:
handleError
in classAbstractValidationAction
- Parameters:
profileRequestContext
- the current profile request contextauthenticationContext
- the current authentication contexte
- the exception to processeventId
- the event to "return" via anEventContext
if the exception message is not classified
-
doExecute
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Performs this authentication action. Default implementation throws an exception.- Overrides:
doExecute
in classAbstractAuthenticationAction
- Parameters:
profileRequestContext
- the current IdP profile request contextauthenticationContext
- the current authentication context
-
populateSubject
Subclasses must override this method to complete the population of theSubject
withPrincipal
and credential information based on the validation they perform.Typically this will include attaching a
UsernamePrincipal
, but this is not a requirement if other components are suitably overridden.- Specified by:
populateSubject
in classAbstractValidationAction
- Parameters:
subject
- subject to populate- Returns:
- the input subject
-
recordSuccess
Record a successful authentication attempt against the configured counter. Records nothing if the metrics registry is not installed into the runtime.Also optionally clears account lockout state.
- Overrides:
recordSuccess
in classAbstractAuditingValidationAction
- Parameters:
profileRequestContext
- profile request context
-
getAuditFields
@Nullable @NonnullElements protected Map<String,String> getAuditFields(@Nonnull ProfileRequestContext profileRequestContext) Subclasses can override this method to supply additional audit fields to store.- Overrides:
getAuditFields
in classAbstractAuditingValidationAction
- Parameters:
profileRequestContext
- profile request context- Returns:
- audit fields
-