Class AbstractWebAuthnAuditingAction<T>

Type Parameters:
T - the WebAuthn context type
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ProfileAction, Aware, MessageSource, MessageSourceAware, Action
Direct Known Subclasses:
AdminDeletePublicKeyCredential, DeletePublicKeyCredential, StorePublicKeyCredential, UpdateCredentialNickname

public abstract class AbstractWebAuthnAuditingAction<T> extends AbstractWebAuthnAction<T>
A base class for actions that include audit logging support.
  • Field Details

  • Constructor Details

    • AbstractWebAuthnAuditingAction

      protected AbstractWebAuthnAuditingAction(@Nonnull Function<ProfileRequestContext,T> defaultStrategy)
      Constructor.
      Parameters:
      defaultStrategy - the default audit context lookup strategy
  • Method Details

    • setAuditContextCreationStrategy

      public void setAuditContextCreationStrategy(@Nonnull Function<ProfileRequestContext,AuditContext> strategy)
      Set the strategy used to locate the AuditContext associated with a given ProfileRequestContext.
      Parameters:
      strategy - lookup strategy
    • setPopulateAuditContextAction

      public void setPopulateAuditContextAction(@Nullable PopulateAuditContext action)
      Sets an audit context population action to run.
      Parameters:
      action - optional action to use to populate audit context
    • setWriteAuditLogAction

      public void setWriteAuditLogAction(@Nullable WriteAuditLog action)
      Sets an audit output action to run.
      Parameters:
      action - optional action to use to write to audit log
    • getAuditContext

      @Nullable protected AuditContext getAuditContext(@Nonnull ProfileRequestContext profileRequestContext)
      Create or locate the AuditContext via the defined strategy.
      Parameters:
      profileRequestContext - profile request context
      Returns:
      the audit context
    • setOnFailureAuditHook

      public void setOnFailureAuditHook(@Nullable BiConsumer<ProfileRequestContext,String> hook)
      Set a hook to run on a failure audit event.
      Parameters:
      hook - the hook to set.
      Since:
      1.3.0
    • setOnSuccessAuditHook

      public void setOnSuccessAuditHook(@Nullable BiConsumer<ProfileRequestContext,String> hook)
      Set a hook to run on a success audit event.
      Parameters:
      hook - the hook to set.
      Since:
      1.3.0
    • doExecute

      protected Event doExecute(@Nonnull RequestContext springRequestContext, @Nonnull ProfileRequestContext profileRequestContext)
      Overrides:
      doExecute in class AbstractProfileAction
    • auditSuccess

      protected void auditSuccess(@Nonnull ProfileRequestContext profileRequestContext, @Nullable String action)
      Audit a successful operation. This will automatically add a 'success' field to the audit context. The onSuccessAuditHook is run before audit logging.
      Parameters:
      profileRequestContext - the profile request context
      action - a descriptive string of the action that was performed. Can be null if not used.
    • auditFailure

      protected void auditFailure(@Nonnull ProfileRequestContext profileRequestContext, @Nullable String action)
      Audit a failed operation. This will automatically add a 'failure' field to the audit context. The onFailureAuditHook is run before audit logging.
      Parameters:
      profileRequestContext - the profile request context
      action - a descriptive string of the action that was performed. Can be null if not used.
    • doAudit

      protected void doAudit(@Nonnull ProfileRequestContext profileRequestContext, boolean success, @Nullable String action)
      Do audit extraction and output.
      Parameters:
      profileRequestContext - profile request context
      success - true iff this is an audit of successful action, false otherwise
      action - the type of action that was performed
    • getAuditFields

      @Nullable @Unmodifiable @NotLive protected Map<String,String> getAuditFields(@Nonnull ProfileRequestContext profileRequestContext)
      Subclasses can override this method to supply additional audit fields to store.
      Parameters:
      profileRequestContext - profile request context
      Returns:
      audit fields