Class FinalizeAuthentication

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ProfileAction, Aware, MessageSource, MessageSourceAware, Action

public class FinalizeAuthentication
extends AbstractAuthenticationAction
An authentication action that runs after a completed authentication flow (or the reuse of an active result) and transfers information from other contexts into a SubjectContext child of the ProfileRequestContext.

The action enforces any constraints on proxying that may be present in the result against the intended use based on the RelyingPartyContext.

The action also cross-checks RequestedPrincipalContext.getMatchingPrincipal(), if set, against the AuthenticationResult to ensure that the result produced actually satisfies the request. This is redundant when reusing active results, but is necessary to prevent a flow from running that can return different results and having it produce a result that doesn't actually satisfy the request. Such a flow would be buggy, but this guards against a mistake from leaving the subsystem.

If no matching Principal is established, or if the match is no longer valid, the request is evaluated in conjunction with the AuthenticationResult to establish a Principal that does satisfy the request and it is recorded via RequestedPrincipalContext.setMatchingPrincipal(Principal).

The context is populated based on the presence of a canonical principal name in either a SubjectCanonicalizationContext or SessionContext, and also includes the completed AuthenticationResult and any other active results found in the AuthenticationContext.

Any SubjectCanonicalizationContext found will be removed.

If AuthenticationContext.getRequiredName() is set, then this action will validate that the same principal name is represented by it, and signal a mismatch otherwise. This is used in protocols that indicate normatively what the authenticated identity is required to be.

ProfileRequestContext.getSubcontext(AuthenticationContext.class) != null
If SubjectCanonicalizationContext.getCanonicalPrincipalName() != null || SessionContext.getIdPSession() != null then ProfileRequestContext.getSubcontext(SubjectContext.class) != null, AuthenticationContext.setCompletionInstant() was called,
ProfileRequestContext.getSubcontext(SubjectCanonicalizationContext.class) == null
  • Field Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • canonicalPrincipalName

      @Nullable private String canonicalPrincipalName
      The principal name extracted from the context tree.
  • Constructor Details

    • FinalizeAuthentication

      public FinalizeAuthentication()
  • Method Details

    • doPreExecute

      protected boolean doPreExecute​(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
      Performs this authentication action's pre-execute step. Default implementation just returns true.
      doPreExecute in class AbstractAuthenticationAction
      profileRequestContext - the current IdP profile request context
      authenticationContext - the current authentication context
      true iff execution should continue
    • doExecute

      protected void doExecute​(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
      Performs this authentication action. Default implementation throws an exception.
      doExecute in class AbstractAuthenticationAction
      profileRequestContext - the current IdP profile request context
      authenticationContext - the current authentication context
    • findMatchingPrincipal

      @Nullable protected Principal findMatchingPrincipal​(@Nonnull AuthenticationContext authenticationContext, @Nonnull RequestedPrincipalContext requestedPrincipalCtx)
      Evaluate request criteria and the AuthenticationResult to locate a Principal in the result that satisfies the request criteria.

      If a weighting map is supplied, the Principal returned is the one that both satisfies the request and is highest weighted according to the underlying flow descriptor.

      authenticationContext - authentication context
      requestedPrincipalCtx - request criteria
      matching Principal, or null
    • checkProxyRestrictions

      private boolean checkProxyRestrictions​(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull Subject subject)
      Check for proxy restrictions and evaluate them against the request.
      profileRequestContext - current profile request context
      subject - the authentication result's subject
      true iff processing should continue