Package net.shibboleth.idp.authn.impl
Class ValidateCredentials
java.lang.Object
net.shibboleth.shared.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 classA default cleanup hook that removes theUsernamePasswordContextfrom the tree. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<CredentialValidator>Ordered list of validators.private CredentialValidatorCurrently executing validator.private static final StringDefault prefix for metrics.private booleanTracks whether an error event was signaled.private AccountLockoutManagerOptional lockout management interface.private final org.slf4j.LoggerClass logger.private booleanWhether all validators must succeed.private Collection<Subject>Results from successful validators.private booleanTracks whether a warning event was signaled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoExecute(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.voidhandleError(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, Exception e, String eventId) Adds an exception encountered during the action to anAuthenticationErrorContext, creating one if necessary, beneath theAuthenticationContext.voidhandleError(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 anAuthenticationErrorContextand used as the resulting event for the action.voidhandleWarning(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 anAuthenticationWarningContextand used as the resulting event for the action.protected SubjectpopulateSubject(Subject subject) protected voidrecordSuccess(ProfileRequestContext profileRequestContext) Record a successful authentication attempt against the configured counter.voidsetLockoutManager(AccountLockoutManager manager) Set an account lockout management component.voidsetRequireAll(boolean flag) Set whether to execute and require success from all configured validators, or stop at the first successful result.voidsetValidators(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, setWriteAuditLogActionMethods inherited from class net.shibboleth.idp.authn.AbstractValidationAction
addDefaultPrincipals, buildAuthenticationResult, doPreExecute, getClassifiedErrors, getCleanupHook, getRequesterLookupStrategy, getResponderLookupStrategy, getResultCachingPredicate, getSubject, getSupportedPrincipals, setAddDefaultPrincipals, setClassifiedMessages, setCleanupHook, setMetricName, setRequesterLookupStrategy, setResponderLookupStrategy, setResultCachingPredicate, setSupportedPrincipalsMethods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doPreExecute, setAuthenticationContextLookupStrategyMethods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategyMethods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationConditionMethods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplierMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.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:
getMetricNamein 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 anAuthenticationWarningContextand 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:
handleWarningin interfaceCredentialValidator.WarningHandler- Overrides:
handleWarningin classAbstractValidationAction- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication contextmessage- to processeventId- the event to "return" via anEventContextif 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 anAuthenticationErrorContextand 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:
handleErrorin interfaceCredentialValidator.ErrorHandler- Overrides:
handleErrorin classAbstractValidationAction- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication contextmessage- to processeventId- the event to "return" via anEventContextif 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
AuthenticationErrorContextand used as the resulting event for the action.- Specified by:
handleErrorin interfaceCredentialValidator.ErrorHandler- Overrides:
handleErrorin classAbstractValidationAction- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication contexte- the exception to processeventId- the event to "return" via anEventContextif 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:
doExecutein classAbstractAuthenticationAction- Parameters:
profileRequestContext- the current IdP profile request contextauthenticationContext- the current authentication context
-
populateSubject
Subclasses must override this method to complete the population of theSubjectwithPrincipaland 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:
populateSubjectin 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:
recordSuccessin classAbstractAuditingValidationAction- Parameters:
profileRequestContext- profile request context
-
getAuditFields
@Nonnull @Unmodifiable @NotLive protected Map<String,String> getAuditFields(@Nonnull ProfileRequestContext profileRequestContext) Subclasses can override this method to supply additional audit fields to store.- Overrides:
getAuditFieldsin classAbstractAuditingValidationAction- Parameters:
profileRequestContext- profile request context- Returns:
- audit fields
-