Class AbstractValidationAction
- All Implemented Interfaces:
PrincipalSupportingComponent,Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
- Direct Known Subclasses:
AbstractAuditingValidationAction,ValidateSAMLAuthentication
AuthenticationResult.- Event:
AuthnEventIds.INVALID_AUTHN_CTX,AuthnEventIds.REQUEST_UNSUPPORTED- Precondition:
ProfileRequestContext.getSubcontext(AuthenticationContext.class).getAttemptedFlow() != null
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classA predicate that examines a message to see if it contains a particular String. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether to inject the authentication flow's default custom principals into the subject.private final SubjectBasis forAuthenticationResult.private Map<String,Collection<String>> Error messages associated with a specific error condition token.private Consumer<ProfileRequestContext>A cleanup hook to execute after successful validation.private booleanIndicates whether to clear any existingAuthenticationErrorContextbefore execution.private static final StringDefault prefix for metrics.private final org.slf4j.LoggerClass logger.private StringBase name of metrics.private Function<ProfileRequestContext,String> Function used to obtain the requester ID.private Function<ProfileRequestContext,String> Function used to obtain the responder ID.private Predicate<ProfileRequestContext>Predicate to apply when setting AuthenticationResult cacheability. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet whether to inject the authentication flow's default custom principals into the subject.protected voidbuildAuthenticationResult(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Normally called upon successful completion of credential validation, calls thepopulateSubject(Subject)abstract method, stores anAuthenticationResultin theAuthenticationContext, and attaches aSubjectCanonicalizationContextto theProfileRequestContextin preparation for c14n to occur.protected booleandoPreExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) Performs this authentication action's pre-execute step.Get the error messages mapped to specific events.Get the cleanup hook to execute after successful validation.Get the base name to use for metrics reported.Get the strategy used to locate the requester ID for canonicalization.Get the strategy used to locate the responder ID for canonicalization.Get predicate to apply to determine cacheability ofAuthenticationResult.protected SubjectGet the subject to be produced by successful execution of this action.getSupportedPrincipals(Class<T> c) Get an immutable set of supported custom principals that the component produces, supports, contains, etc.protected voidhandleError(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, Exception e, String eventId) Adds an exception encountered during the action to anAuthenticationErrorContext, creating one if necessary, beneath theAuthenticationContext.protected 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.protected 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 abstract SubjectpopulateSubject(Subject subject) protected voidrecordFailure(ProfileRequestContext profileRequestContext) Record a failed authentication attempt against the configured counter.protected voidrecordSuccess(ProfileRequestContext profileRequestContext) Record a successful authentication attempt against the configured counter.voidsetAddDefaultPrincipals(boolean flag) Set whether to inject the authentication flow's default custom principals into the subject.voidsetClassifiedMessages(Map<String, Collection<String>> messages) Set the error messages to map to specific events.voidSet the cleanup hook to execute after successful validation.voidsetMetricName(String name) Set the base name to use for metrics reported.voidSet the strategy used to locate the requester ID for canonicalization.voidSet the strategy used to locate the responder ID for canonicalization.voidsetResultCachingPredicate(Predicate<ProfileRequestContext> predicate) Set predicate to apply to determine cacheability ofAuthenticationResult.voidsetSupportedPrincipals(Collection<Principal> principals) Set supported non-user-specific principals that the action will include in the subjects it generates, in place of any default principals from the flow.Methods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doExecute, doPreExecute, setAuthenticationContextLookupStrategyMethods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
doExecute, 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. -
metricName
Base name of metrics. -
authenticatedSubject
Basis forAuthenticationResult. -
addDefaultPrincipals
private boolean addDefaultPrincipalsWhether to inject the authentication flow's default custom principals into the subject. -
clearErrorContext
private boolean clearErrorContextIndicates whether to clear any existingAuthenticationErrorContextbefore execution. -
cleanupHook
A cleanup hook to execute after successful validation. -
classifiedMessages
Error messages associated with a specific error condition token. -
resultCachingPredicate
Predicate to apply when setting AuthenticationResult cacheability. -
requesterLookupStrategy
Function used to obtain the requester ID. -
responderLookupStrategy
Function used to obtain the responder ID.
-
-
Constructor Details
-
AbstractValidationAction
public AbstractValidationAction()Constructor.
-
-
Method Details
-
getMetricName
Get the base name to use for metrics reported.- Returns:
- root for name of metrics
- Since:
- 3.3.0
-
setMetricName
Set the base name to use for metrics reported.- Parameters:
name- root for name of metrics- Since:
- 3.3.0
-
addDefaultPrincipals
public boolean addDefaultPrincipals()Get whether to inject the authentication flow's default custom principals into the subject.This is the default behavior, and works for static flows in which the principal set can be statically determined from the flow.
- Returns:
- whether to inject the authentication flow's default custom principals into the subject
-
setAddDefaultPrincipals
public void setAddDefaultPrincipals(boolean flag) Set whether to inject the authentication flow's default custom principals into the subject.- Parameters:
flag- flag to set
-
getClassifiedErrors
Get the error messages mapped to specific events.The map keys are the events and the values are the message collections.
- Returns:
- classified error message map
-
setClassifiedMessages
Set the error messages to map to specific events.The map keys are the events and the values are the message collections.
- Parameters:
messages- the error message / event mappings to set
-
getResultCachingPredicate
Get predicate to apply to determine cacheability ofAuthenticationResult.- Returns:
- predicate to apply, or null
-
setResultCachingPredicate
Set predicate to apply to determine cacheability ofAuthenticationResult.- Parameters:
predicate- predicate to apply, or null
-
getCleanupHook
Get the cleanup hook to execute after successful validation.- Returns:
- cleanup hook
- Since:
- 4.1.0
-
setCleanupHook
Set the cleanup hook to execute after successful validation.- Parameters:
hook- cleanup hook- Since:
- 4.1.0
-
getRequesterLookupStrategy
Get the strategy used to locate the requester ID for canonicalization.- Returns:
- lookup strategy
- Since:
- 4.0.0
-
setRequesterLookupStrategy
Set the strategy used to locate the requester ID for canonicalization.- Parameters:
strategy- lookup strategy
-
getResponderLookupStrategy
Get the strategy used to locate the responder ID for canonicalization.- Returns:
- lookup strategy
- Since:
- 4.0.0
-
setResponderLookupStrategy
Set the strategy used to locate the responder ID for canonicalization.- Parameters:
strategy- lookup strategy
-
getSupportedPrincipals
@Nonnull @Unmodifiable @NotLive public <T extends Principal> Set<T> getSupportedPrincipals(@Nonnull Class<T> c) Get an immutable set of supported custom principals that the component produces, supports, contains, etc.- Specified by:
getSupportedPrincipalsin interfacePrincipalSupportingComponent- Type Parameters:
T- type of Principal to inquire on- Parameters:
c- type of Principal to inquire on- Returns:
- a set of matching principals
-
setSupportedPrincipals
Set supported non-user-specific principals that the action will include in the subjects it generates, in place of any default principals from the flow.Setting to a null or empty collection will maintain the default behavior of relying on the flow.
- Parameters:
principals- supported principals to include
-
getSubject
Get the subject to be produced by successful execution of this action.- Returns:
- the subject meant as the result of this action
-
doPreExecute
protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Performs this authentication action's pre-execute step. Default implementation just returns true.- Overrides:
doPreExecutein classAbstractAuthenticationAction- Parameters:
profileRequestContext- the current IdP profile request contextauthenticationContext- the current authentication context- Returns:
- true iff execution should continue
-
buildAuthenticationResult
protected void buildAuthenticationResult(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) Normally called upon successful completion of credential validation, calls thepopulateSubject(Subject)abstract method, stores anAuthenticationResultin theAuthenticationContext, and attaches aSubjectCanonicalizationContextto theProfileRequestContextin preparation for c14n to occur.- Parameters:
profileRequestContext- the current 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.- 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.- Parameters:
profileRequestContext- profile request context- Since:
- 4.1.0
-
recordFailure
Record a failed authentication attempt against the configured counter. Records nothing if the metrics registry is not installed into the runtime.- Parameters:
profileRequestContext- profile request context- Since:
- 4.1.0
-
handleError
protected 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.- 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
-
handleError
protected 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.
- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication contextmessage- to processeventId- the event to "return" via anEventContextif the message is not classified
-
handleWarning
protected 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.
- Parameters:
profileRequestContext- the current profile request contextauthenticationContext- the current authentication contextmessage- to processeventId- the event to "return" via anEventContextif the message is not classified
-