public final class AuthenticationContext extends BaseContext
ProfileRequestContextRequestedPrincipalContext, attribute.context.AttributeContext,
UsernameContext, UsernamePasswordContext, UserAgentContext, CertificateContext,
ExternalAuthenticationContext, KerberosTicketContext, LDAPResponseContext,
AuthenticationErrorContext, AuthenticationWarningContextBaseContext.ContextSetNoRemoveIteratorDecorator| Modifier and Type | Field and Description |
|---|---|
private Map<String,AuthenticationResult> |
activeResults
Authentication results associated with an active session and available for (re)use.
|
private AuthenticationFlowDescriptor |
attemptedFlow
Authentication flow being attempted to authenticate the user.
|
private AuthenticationResult |
authenticationResult
A successful authentication result (the output of the attempted flow, if any).
|
private Map<String,AuthenticationFlowDescriptor> |
availableFlows
Flows that are known to the system.
|
private long |
completionInstant
Time, in milliseconds since the epoch, when authentication process completed.
|
private PrincipalEvalPredicateFactoryRegistry |
evalRegistry
Instance of registry used for auto-creation of
RequestedPrincipalContext. |
private com.google.common.base.Function<ProfileRequestContext,String> |
fixedEventLookupStrategy
Lookup strategy for a fixed event to return from validators for testing.
|
private boolean |
forceAuthn
Whether to require fresh subject interaction to succeed.
|
private String |
hintedName
A non-normative hint some protocols support to indicate who the subject might be.
|
private AuthenticationResult |
initialAuthenticationResult
A successful "initial" authentication result from the current request's initial-authn phase.
|
private long |
initiationInstant
Time, in milliseconds since the epoch, when the authentication process started.
|
private Map<String,AuthenticationFlowDescriptor> |
intermediateFlows
Previously attempted flows (could be failures or intermediate results).
|
private boolean |
isPassive
Whether authentication must not involve subject interaction.
|
private long |
maxAge
Allowed time in ms since an
AuthenticationResult was created that it can be reused for this request. |
private Map<String,AuthenticationFlowDescriptor> |
potentialFlows
Flows that could potentially be used to authenticate the user.
|
private boolean |
resultCacheable
Result may be cached for reuse in the normal way.
|
private String |
signaledFlowId
Signals authentication flow to run next, to influence selection logic.
|
private Map<String,Object> |
stateMap
Storage map for interflow communication.
|
| Constructor and Description |
|---|
AuthenticationContext()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addRequestedPrincipalContext(String operator,
List<Principal> principals,
boolean replace)
Add (or replace) a
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling. |
boolean |
addRequestedPrincipalContext(String operator,
Principal principal,
boolean replace)
Add (or replace) a
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling. |
boolean |
addRequestedPrincipalContext(String operator,
String className,
Collection<String> principals,
boolean replace)
Add (or replace) a
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling. |
boolean |
addRequestedPrincipalContext(String operator,
String className,
String principal,
boolean replace)
Add (or replace) a
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling. |
Map<String,AuthenticationResult> |
getActiveResults()
Get previous authentication results currently active for the subject.
|
AuthenticationFlowDescriptor |
getAttemptedFlow()
Get the authentication flow that was attempted in order to authenticate the user.
|
AuthenticationResult |
getAuthenticationResult()
Get the authentication result produced by the attempted flow, or reused for SSO.
|
Map<String,Object> |
getAuthenticationStateMap()
Get the map of intermediate state that flows can use to pass information amongst themselves.
|
Map<String,AuthenticationFlowDescriptor> |
getAvailableFlows()
Get the set of flows known to the system overall.
|
long |
getCompletionInstant()
Get the time, in milliseconds since the epoch, when the authentication process ended.
|
com.google.common.base.Function<ProfileRequestContext,String> |
getFixedEventLookupStrategy()
Get optional lookup strategy to return a fixed event to return from credential validation
to exercise error and warning logic.
|
String |
getHintedName()
Get a non-normative hint provided by the request about the user's identity.
|
AuthenticationResult |
getInitialAuthenticationResult()
Get the "initial" authentication result produced during this request's initial-authn phase.
|
long |
getInitiationInstant()
Get the time, in milliseconds since the epoch, when the authentication process started.
|
Map<String,AuthenticationFlowDescriptor> |
getIntermediateFlows()
Get the set of flows that have been executed, successfully or otherwise, without producing a completed result.
|
long |
getMaxAge()
Get duration in milliseconds since an
AuthenticationResult was created that
allows it to be reused for this request. |
Map<String,AuthenticationFlowDescriptor> |
getPotentialFlows()
Get the set of flows that could potentially be used for authentication.
|
PrincipalEvalPredicateFactoryRegistry |
getPrincipalEvalPredicateFactoryRegistry()
Get the registry of predicate factories for custom principal evaluation.
|
String |
getSignaledFlowId()
Get the flow ID signaled as the next selection.
|
boolean |
isAcceptable(Collection<Principal> principals)
Helper method that evaluates
Principal objects against a RequestedPrincipalContext child
of this context, if present, to determine if the input is compatible with them. |
boolean |
isAcceptable(PrincipalSupportingComponent component)
Helper method that evaluates a
PrincipalSupportingComponent against a
RequestedPrincipalContext child of this context, if present, to determine
if the input is compatible with it. |
<T extends Principal> |
isAcceptable(T principal)
Helper method that evaluates a
Principal object against a RequestedPrincipalContext child
of this context, if present, to determine if the input is compatible with it. |
boolean |
isForceAuthn()
Get whether to require fresh subject interaction to succeed.
|
boolean |
isPassive()
Get whether subject interaction is allowed.
|
boolean |
isResultCacheable()
Get whether the result is suitable for caching (such as in a session) for reuse.
|
AuthenticationContext |
setActiveResults(Iterable<AuthenticationResult> results)
Set the authentication results currently active for the subject.
|
AuthenticationContext |
setAttemptedFlow(AuthenticationFlowDescriptor flow)
Set the authentication flow that was attempted in order to authenticate the user.
|
AuthenticationContext |
setAuthenticationResult(AuthenticationResult result)
Set the authentication result produced by the attempted flow, or reused for SSO.
|
AuthenticationContext |
setCompletionInstant()
Set the completion time of the authentication attempt to the current time.
|
AuthenticationContext |
setFixedEventLookupStrategy(com.google.common.base.Function<ProfileRequestContext,String> strategy)
Set optional lookup strategy to return a fixed event to return from credential validation
to exercise error and warning logic.
|
AuthenticationContext |
setForceAuthn(boolean force)
Set whether to require fresh subject interaction to succeed.
|
AuthenticationContext |
setHintedName(String hint)
Set a non-normative hint provided by the request about the user's identity.
|
AuthenticationContext |
setInitialAuthenticationResult(AuthenticationResult result)
Set the "initial" authentication result produced during this request's initial-authn phase.
|
AuthenticationContext |
setIsPassive(boolean passive)
Set whether subject interaction is allowed.
|
AuthenticationContext |
setMaxAge(long age)
Set duration in milliseconds since an
AuthenticationResult was created that
allows it to be reused for this request. |
AuthenticationContext |
setPrincipalEvalPredicateFactoryRegistry(PrincipalEvalPredicateFactoryRegistry registry)
Set the registry of predicate factories for custom principal evaluation to inject into instances of
RequestedPrincipalContext created via the addRequestedPrincipalContext(String, List, boolean)
helper method. |
void |
setResultCacheable(boolean flag)
Set whether the result is suitable for caching (such as in a session) for reuse.
|
AuthenticationContext |
setSignaledFlowId(String id)
Set the flow ID signaled as the next selection.
|
String |
toString() |
addSubcontext, addSubcontext, clearSubcontexts, containsSubcontext, createSubcontext, getParent, getSubcontext, getSubcontext, getSubcontext, getSubcontext, isAutoCreateSubcontexts, iterator, removeSubcontext, removeSubcontext, setAutoCreateSubcontexts, setParent@Positive private final long initiationInstant
private boolean forceAuthn
private boolean isPassive
@Nullable private String hintedName
@NonNegative @Duration private long maxAge
AuthenticationResult was created that it can be reused for this request.@Nullable private com.google.common.base.Function<ProfileRequestContext,String> fixedEventLookupStrategy
@Nonnull @NonnullElements private final Map<String,AuthenticationFlowDescriptor> availableFlows
@Nonnull @NonnullElements private final Map<String,AuthenticationFlowDescriptor> potentialFlows
@Nonnull @NonnullElements private final Map<String,AuthenticationResult> activeResults
@Nonnull @NonnullElements private final Map<String,AuthenticationFlowDescriptor> intermediateFlows
@Nullable private PrincipalEvalPredicateFactoryRegistry evalRegistry
RequestedPrincipalContext.@Nullable private AuthenticationFlowDescriptor attemptedFlow
@Nullable private String signaledFlowId
@Nonnull private final Map<String,Object> stateMap
@Nullable private AuthenticationResult initialAuthenticationResult
@Nullable private AuthenticationResult authenticationResult
private boolean resultCacheable
@NonNegative private long completionInstant
@Positive public long getInitiationInstant()
@Nonnull @NonnullElements @Live public Map<String,AuthenticationResult> getActiveResults()
These should be used to identify SSO opportunities. Results produced during a particular authentication run should not be included in this collection.
@Nonnull public AuthenticationContext setActiveResults(@Nonnull@NonnullElements Iterable<AuthenticationResult> results)
results - authentication results currently active for the subject@Nonnull @NonnullElements @Live public Map<String,AuthenticationFlowDescriptor> getAvailableFlows()
Authentication flows supplied by the configuration and gradually filtered down to a collection that can be used to authenticate the subject.
@Nonnull @NonnullElements @Live public Map<String,AuthenticationFlowDescriptor> getPotentialFlows()
Initially the same as getAvailableFlows(), it may be filtered down to a smaller set.
@Nonnull @NonnullElements @Live public Map<String,AuthenticationFlowDescriptor> getIntermediateFlows()
This tracks flows that have already been run to avoid unintentional repeated attempts to run the same flow.
@Nonnull public PrincipalEvalPredicateFactoryRegistry getPrincipalEvalPredicateFactoryRegistry()
This object is only needed when evaluating a RequestedPrincipalContext, so the presence of it at
this level of the tree is solely for use by the addRequestedPrincipalContext(String, List, boolean)
helper method.
@Nonnull public AuthenticationContext setPrincipalEvalPredicateFactoryRegistry(@Nullable PrincipalEvalPredicateFactoryRegistry registry)
RequestedPrincipalContext created via the addRequestedPrincipalContext(String, List, boolean)
helper method.
It also propagates this object into any existing RequestedPrincipalContext subcontext.
registry - predicate factory registrypublic boolean isPassive()
Flows that support this feature MUST be implemented with awareness of this value. If a flow doesn't examine this property, it should be marked as non-supporting or would have to be universally lacking in subject interaction.
@Nonnull public AuthenticationContext setIsPassive(boolean passive)
passive - whether subject interaction may occurpublic boolean isForceAuthn()
Flows may not explicitly be aware of this property, but if they include any internal orchestration of other flows, then they MUST be aware of it to avoid reuse of previous results.
@Nonnull public AuthenticationContext setForceAuthn(boolean force)
force - whether subject interaction must occur@Nullable @NotEmpty public String getHintedName()
This is NOT a trustworthy value, but may be used to optimize the user experience.
@Nonnull public AuthenticationContext setHintedName(@Nullable String hint)
hint - the username hint@NonNegative @Duration public long getMaxAge()
AuthenticationResult was created that
allows it to be reused for this request.
If zero, no constraint is applied.
@Nonnull public AuthenticationContext setMaxAge(@NonNegative@Duration long age)
AuthenticationResult was created that
allows it to be reused for this request.
Set to zero to apply no constraint.
age - duration in milliseconds, or zero@Nullable public com.google.common.base.Function<ProfileRequestContext,String> getFixedEventLookupStrategy()
@Nonnull public AuthenticationContext setFixedEventLookupStrategy(@Nullable com.google.common.base.Function<ProfileRequestContext,String> strategy)
strategy - lookup strategy@Nullable public AuthenticationFlowDescriptor getAttemptedFlow()
This field will hold the flow being run while it is executing, and will continue to contain that value until/unless another flow is run. It is not set if an existing result was reused by the IdP's own machinery for SSO, and subsequent to authentication will inform as to the fact that SSO was or was not done, and which flow was used.
@Nonnull public AuthenticationContext setAttemptedFlow(@Nullable AuthenticationFlowDescriptor flow)
Do not set if an existing result was reused for SSO.
flow - authentication flow that was attempted in order to authenticate the user@Nullable @NotEmpty public String getSignaledFlowId()
A login flow may set this value to signal the authentication flow to transfer control immediately to another login flow instead of proceeding in ordered fashion picking flows to attempt. Generally it is more effective to actually call a login flow from within another flow and subsume it than to rely on this signaling mechanism.
@Nonnull public AuthenticationContext setSignaledFlowId(@Nullable String id)
id - ID of flow to run next@Nonnull @Live public Map<String,Object> getAuthenticationStateMap()
This is a simple string-based map of attributes that can be used to carry information between login flows or for subsequent use, without relying on native Spring WebFlow mechanisms.
@Nullable public AuthenticationResult getInitialAuthenticationResult()
This is used to make a previous result available for SSO even if the "forced authentication" feature is being used, since the result was produced as part of the same request.
@Nonnull public AuthenticationContext setInitialAuthenticationResult(@Nullable AuthenticationResult result)
result - "initial" authentication result, if any@Nullable public AuthenticationResult getAuthenticationResult()
The last flow to complete successfully should have its results stored here. Composite flows should be aware that they may need to preserve intermediate results, and the only get to produce one single result at the end.
@Nonnull public AuthenticationContext setAuthenticationResult(@Nullable AuthenticationResult result)
result - authentication result, if anypublic boolean isResultCacheable()
Allows flows to indicate at runtime if their results should be cached for future use, or thrown away after a single use.
public void setResultCacheable(boolean flag)
flag - flag to set@NonNegative public long getCompletionInstant()
@Nonnull public AuthenticationContext setCompletionInstant()
public boolean isAcceptable(@Nonnull PrincipalSupportingComponent component)
PrincipalSupportingComponent against a
RequestedPrincipalContext child of this context, if present, to determine
if the input is compatible with it.component - component to evaluatepublic boolean isAcceptable(@Nonnull@NonnullElements Collection<Principal> principals)
Principal objects against a RequestedPrincipalContext child
of this context, if present, to determine if the input is compatible with them.principals - principal(s) to evaluatepublic <T extends Principal> boolean isAcceptable(@Nonnull T principal)
Principal object against a RequestedPrincipalContext child
of this context, if present, to determine if the input is compatible with it.T - type of principalprincipal - principal to evaluatepublic boolean addRequestedPrincipalContext(@Nonnull@NotEmpty String operator, @Nonnull@NotEmpty String className, @Nonnull@NotEmpty String principal, boolean replace) throws Exception
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling.operator - matching operatorclassName - name of class to wrap principal namesprincipal - name of principal to requestreplace - whether to replace an existing context or simply return falseException - if the principal class can't be loaded or instantiated as requiredpublic boolean addRequestedPrincipalContext(@Nonnull@NotEmpty String operator, @Nonnull@NotEmpty String className, @Nonnull Collection<String> principals, boolean replace) throws Exception
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling.operator - matching operatorclassName - name of class to wrap principal namesprincipals - names of principals to requestreplace - whether to replace an existing context or simply return falseException - if the principal class can't be loaded or instantiated as requiredpublic boolean addRequestedPrincipalContext(@Nonnull@NotEmpty String operator, @Nonnull Principal principal, boolean replace)
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling.operator - matching operatorprincipal - principal to requestreplace - whether to replace an existing context or simply return falsepublic boolean addRequestedPrincipalContext(@Nonnull@NotEmpty String operator, @Nonnull@NonnullElements List<Principal> principals, boolean replace)
RequestedPrincipalContext as a child of this context using the
supplied parameters and the previously established PrincipalEvalPredicateFactoryRegistry
for comparison handling.operator - matching operatorprincipals - principals to requestreplace - whether to replace an existing context or simply return falseCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.