InboundMessageType - type of in-bound messageOutboundMessageType - type of out-bound messagepublic abstract class AbstractValidationAction<InboundMessageType,OutboundMessageType> extends AbstractAuthenticationAction<InboundMessageType,OutboundMessageType> implements PrincipalSupportingComponent
AuthenticationResult.EventIds.INVALID_PROFILE_CTX, AuthnEventIds.REQUEST_UNSUPPORTEDProfileRequestContext.getSubcontext(AuthenticationContext.class).getAttemptedFlow() != null
| Modifier and Type | Class and Description |
|---|---|
private class |
AbstractValidationAction.MessageChecker
A predicate that examines a message to see if it contains a particular String.
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
addDefaultPrincipals
Whether to inject the authentication flow's default custom principals into the subject.
|
private Subject |
authenticatedSubject
Basis for
AuthenticationResult. |
private Map<String,Collection<String>> |
classifiedMessages
Error messages associated with a specific error condition token.
|
private boolean |
clearErrorContext
Indicates whether to clear any existing
AuthenticationErrorContext before execution. |
private static String |
DEFAULT_METRIC_NAME
Default prefix for metrics.
|
private org.slf4j.Logger |
log
Class logger.
|
private String |
metricName
Base name of metrics.
|
private com.google.common.base.Function<ProfileRequestContext,String> |
requesterLookupStrategy
Function used to obtain the requester ID.
|
private com.google.common.base.Function<ProfileRequestContext,String> |
responderLookupStrategy
Function used to obtain the responder ID.
|
private com.google.common.base.Predicate<ProfileRequestContext> |
resultCachingPredicate
Predicate to apply when setting AuthenticationResult cacheability.
|
| Constructor and Description |
|---|
AbstractValidationAction()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addDefaultPrincipals()
Get whether to inject the authentication flow's default custom principals into the subject.
|
protected void |
buildAuthenticationResult(ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext,
AuthenticationContext authenticationContext)
Normally called upon successful completion of credential validation, calls the
populateSubject(Subject)
abstract method, stores an AuthenticationResult in the AuthenticationContext, and attaches a
SubjectCanonicalizationContext to the ProfileRequestContext in preparation for c14n to occur. |
protected boolean |
doPreExecute(ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext,
AuthenticationContext authenticationContext)
Performs this authentication action's pre-execute step.
|
Map<String,Collection<String>> |
getClassifiedErrors()
Get the error messages classified by specific error conditions.
|
String |
getMetricName()
Get the base name to use for metrics reported.
|
com.google.common.base.Predicate<ProfileRequestContext> |
getResultCachingPredicate()
Get predicate to apply to determine cacheability of
AuthenticationResult. |
protected Subject |
getSubject()
Get the subject to be produced by successful execution of this action.
|
<T extends Principal> |
getSupportedPrincipals(Class<T> c)
Get an immutable set of supported custom principals that the component produces, supports, contains, etc.
|
protected void |
handleError(ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext,
AuthenticationContext authenticationContext,
Exception e,
String eventId)
Adds an exception encountered during the action to an
AuthenticationErrorContext, creating one if
necessary, beneath the AuthenticationContext. |
protected void |
handleError(ProfileRequestContext<InboundMessageType,OutboundMessageType> 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 an
AuthenticationErrorContext and used as the resulting event for the action. |
protected void |
handleWarning(ProfileRequestContext<InboundMessageType,OutboundMessageType> 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 an
AuthenticationWarningContext and used as the resulting event for the action. |
protected abstract Subject |
populateSubject(Subject subject)
|
protected void |
recordFailure()
Record a failed authentication attempt against the configured counter.
|
protected void |
recordSuccess()
Record a successful authentication attempt against the configured counter.
|
void |
setAddDefaultPrincipals(boolean flag)
Set whether to inject the authentication flow's default custom principals into the subject.
|
void |
setClassifiedMessages(Map<String,Collection<String>> messages)
Set the error messages indicating an unknown username.
|
void |
setMetricName(String name)
Set the base name to use for metrics reported.
|
void |
setRequesterLookupStrategy(com.google.common.base.Function<ProfileRequestContext,String> strategy)
Set the strategy used to locate the requester ID for canonicalization.
|
void |
setResponderLookupStrategy(com.google.common.base.Function<ProfileRequestContext,String> strategy)
Set the strategy used to locate the responder ID for canonicalization.
|
void |
setResultCachingPredicate(com.google.common.base.Predicate<ProfileRequestContext> predicate)
Set predicate to apply to determine cacheability of
AuthenticationResult. |
<T extends Principal> |
setSupportedPrincipals(Collection<T> 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.
|
doExecute, doExecute, doPreExecute, setLookupStrategydoExecute, execute, getMessage, getMessage, getMessage, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategygetActivationCondition, setActivationConditiondoPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletResponse, getLogPrefix, setHttpServletRequest, setHttpServletResponsedestroy, doDestroy, doInitialize, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitialize, isInitialized@Nonnull @NotEmpty private static final String DEFAULT_METRIC_NAME
@Nonnull private final org.slf4j.Logger log
@Nonnull private final Subject authenticatedSubject
AuthenticationResult.private boolean addDefaultPrincipals
private boolean clearErrorContext
AuthenticationErrorContext before execution.@Nonnull @NonnullElements private Map<String,Collection<String>> classifiedMessages
@Nullable private com.google.common.base.Predicate<ProfileRequestContext> resultCachingPredicate
@Nullable private com.google.common.base.Function<ProfileRequestContext,String> requesterLookupStrategy
@Nullable private com.google.common.base.Function<ProfileRequestContext,String> responderLookupStrategy
@Nonnull @NotEmpty public String getMetricName()
public void setMetricName(@Nonnull@NotEmpty String name)
name - root for name of metricspublic boolean addDefaultPrincipals()
This is the default behavior, and works for static flows in which the principal set can be statically determined from the flow.
public void setAddDefaultPrincipals(boolean flag)
flag - flag to set@Nonnull @NonnullElements @Unmodifiable @NotLive public Map<String,Collection<String>> getClassifiedErrors()
public void setClassifiedMessages(@Nonnull@NonnullElements Map<String,Collection<String>> messages)
messages - the "unknown username" error messages to set@Nullable public com.google.common.base.Predicate<ProfileRequestContext> getResultCachingPredicate()
AuthenticationResult.public void setResultCachingPredicate(@Nullable com.google.common.base.Predicate<ProfileRequestContext> predicate)
AuthenticationResult.predicate - predicate to apply, or nullpublic void setRequesterLookupStrategy(@Nullable com.google.common.base.Function<ProfileRequestContext,String> strategy)
strategy - lookup strategypublic void setResponderLookupStrategy(@Nullable com.google.common.base.Function<ProfileRequestContext,String> strategy)
strategy - lookup strategy@Nonnull @NonnullElements @Unmodifiable @NotLive public <T extends Principal> Set<T> getSupportedPrincipals(@Nonnull Class<T> c)
getSupportedPrincipals in interface PrincipalSupportingComponentT - type of Principal to inquire onc - type of Principal to inquire onpublic <T extends Principal> void setSupportedPrincipals(@Nullable@NonnullElements Collection<T> principals)
Setting to a null or empty collection will maintain the default behavior of relying on the flow.
T - a type of principal to add, if not genericprincipals - supported principals to include@Nonnull protected Subject getSubject()
protected boolean doPreExecute(@Nonnull ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
doPreExecute in class AbstractAuthenticationAction<InboundMessageType,OutboundMessageType>profileRequestContext - the current IdP profile request contextauthenticationContext - the current authentication contextprotected void buildAuthenticationResult(@Nonnull ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
populateSubject(Subject)
abstract method, stores an AuthenticationResult in the AuthenticationContext, and attaches a
SubjectCanonicalizationContext to the ProfileRequestContext in preparation for c14n to occur.profileRequestContext - the current profile request contextauthenticationContext - the current authentication context@Nonnull protected abstract Subject populateSubject(@Nonnull Subject subject)
Subject with
Principal 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.
subject - subject to populateprotected void recordSuccess()
protected void recordFailure()
protected void handleError(@Nonnull ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nonnull Exception e, @Nonnull@NotEmpty String eventId)
AuthenticationErrorContext, creating one if
necessary, beneath the AuthenticationContext.
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.
profileRequestContext - the current profile request contextauthenticationContext - the current authentication contexte - the exception to processeventId - the event to "return" via an EventContext if
the exception message is not classifiedprotected void handleError(@Nonnull ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable String message, @Nonnull@NotEmpty String eventId)
AuthenticationErrorContext 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.
profileRequestContext - the current profile request contextauthenticationContext - the current authentication contextmessage - to processeventId - the event to "return" via an EventContext if
the message is not classifiedprotected void handleWarning(@Nonnull ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable String message, @Nonnull@NotEmpty String eventId)
AuthenticationWarningContext 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.
profileRequestContext - the current profile request contextauthenticationContext - the current authentication contextmessage - to processeventId - the event to "return" via an EventContext if
the message is not classifiedCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.