Class ValidateWebAuthnAssertion

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

public class ValidateWebAuthnAssertion extends AbstractAuditingValidationAction
An action that validates a WebAuthn authenticator assertion that results from a call to WebAuthn's 'get' credential API. If successful, populates the Subject with a UsernamePrincipal based on the username in the authentication context and a WebAuthnUserIdPrinicpal based on the user.id in the authentication context.
Event:
AuthnEventIds.INVALID_CREDENTIALS, AuthnEventIds.INVALID_AUTHN_CTX
  • Field Details

  • Constructor Details

    • ValidateWebAuthnAssertion

      public ValidateWebAuthnAssertion()
      Constructor.
  • Method Details

    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • setCredentialRepository

      public void setCredentialRepository(@Nonnull WebAuthnCredentialRepository repository)
      Set the credential repository used to store WebAuthn credentials.
      Parameters:
      repository - the repository to set.
    • setWebAuthnClient

      public void setWebAuthnClient(@Nonnull WebAuthnAuthenticationClient client)
      Set the WebAuthn client used to handle validation of the authentication ceremony.
      Parameters:
      client - the webauthnClient to set.
    • setUpdateSignatureCount

      public void setUpdateSignatureCount(boolean flag)
      Set the flag to determine if we should update the signature count on the credential in the repository after successful validation?
      Parameters:
      flag - the flag to set.
    • setUpdateSignatureCountPredicate

      public void setUpdateSignatureCountPredicate(@Nonnull Predicate<ProfileRequestContext> predicate)
      Set the predicate to determine if we should update the signature count on the credential in the repository after successful validation?
      Parameters:
      predicate - the predicate to set.
    • setUpdateLastUsedTimePredicate

      public void setUpdateLastUsedTimePredicate(@Nonnull Predicate<ProfileRequestContext> predicate)
      Set the predicate to determine if we should update the last used time on the credential in the repository after successful validation?
      Parameters:
      predicate - the predicate to set.
      Since:
      1.1.0
    • doPreExecute

      protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
      Overrides:
      doPreExecute in class AbstractValidationAction
    • doExecute

      protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
      Overrides:
      doExecute in class AbstractAuthenticationAction
    • updateLastUsedTime

      private void updateLastUsedTime(@Nonnull String username, @Nonnull com.yubico.webauthn.data.PublicKeyCredential<com.yubico.webauthn.data.AuthenticatorAssertionResponse,com.yubico.webauthn.data.ClientAssertionExtensionOutputs> assertion) throws AssertionFailureException
      Update the last used time of the credential to Instant.now(). Any failure just gets logged and normal processing continues.
      Parameters:
      username - the username of the user to update the last used time for
      assertion - the assertion with the credential Id to update
      Throws:
      AssertionFailureException - on error updating the counter
    • updateSignatureCount

      private void updateSignatureCount(@Nonnull String username, @Nonnull com.yubico.webauthn.data.PublicKeyCredential<com.yubico.webauthn.data.AuthenticatorAssertionResponse,com.yubico.webauthn.data.ClientAssertionExtensionOutputs> assertion) throws AssertionFailureException
      Take the new signature count from the authenticator assertion response and update the stored credential with that value. It is assumed the assertion and signature counter is valid by the time this method is called.
      Parameters:
      username - the username of the user to update signature count for
      assertion - the assertion with the credential Id to update, and the new signature count
      Throws:
      AssertionFailureException - on error updating the counter
    • buildAuthenticationResult

      protected void buildAuthenticationResult(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext)
      Overrides:
      buildAuthenticationResult in class AbstractValidationAction
    • populateSubject

      protected Subject populateSubject(@Nonnull Subject subject)
      Specified by:
      populateSubject in class AbstractValidationAction