Class WriteAuditLog

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

public class WriteAuditLog extends AbstractProfileAction
Action that produces audit log entries based on an AuditContext and one or more formatting strings.
Event:
EventIds.PROCEED_EVENT_ID
  • Field Details

    • log

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

      @Nonnull private Function<ProfileRequestContext,AuditContext> auditContextLookupStrategy
      Strategy used to locate the AuditContext associated with a given ProfileRequestContext.
    • eventContextLookupStrategy

      @Nonnull private Function<ProfileRequestContext,EventContext> eventContextLookupStrategy
      Strategy function for access to EventContext to check.
    • formattingMap

      @Nonnull @NotEmpty private Map<String,List<String>> formattingMap
      Map of log category to formatting tokens and literals to output.
    • categoriesToLog

      @Nonnull @NotEmpty private Collection<String> categoriesToLog
      Explicit categories to log from formattingMap.
    • dateTimeFormatter

      @Nonnull private DateTimeFormatter dateTimeFormatter
      Formatter for date/time fields.
    • useDefaultTimeZone

      private boolean useDefaultTimeZone
      Convert date/time fields to default time zone.
    • includeProfileLoggingId

      private boolean includeProfileLoggingId
      Include profile's logging ID in category.
    • auditCtx

      @Nullable private AuditContext auditCtx
      The AuditContext to operate on.
  • Constructor Details

    • WriteAuditLog

      public WriteAuditLog()
      Constructor.
  • Method Details

    • setAuditContextLookupStrategy

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

      public void setEventContextLookupStrategy(@Nonnull Function<ProfileRequestContext,EventContext> strategy)
      Set lookup strategy for EventContext to check.
      Parameters:
      strategy - lookup strategy
      Since:
      5.3.0
    • getFormattingMap

      @Nonnull @NotLive @Unmodifiable public Map<String,List<String>> getFormattingMap()
      Get the map of logging category to formatting tokens for log entries.
      Returns:
      map of formatting tokens
    • setFormattingMap

      public void setFormattingMap(@Nullable Map<String,String> map)
      Set the map of logging category to formatting strings for log entries.

      A formatting string consists of tokens prefixed by '%' separated by any non-alphanumeric or whitespace. Tokens can contain any letter or number or a hyphen. Anything other than a token, including whitespace, is a literal.

      Parameters:
      map - map of categories to formatting strings
    • setCategoriesToLog

      public void setCategoriesToLog(@Nullable Collection<String> categories)
      Set categories to log explicitly.

      In the absence of any, the original behavior that iterates over the whole formatting map and logs each key is retained.

      Parameters:
      categories - categories to log
      Since:
      4.3.0
    • setDateTimeFormat

      public void setDateTimeFormat(@Nullable @NotEmpty String format)
      Set the formatting string to apply when extracting date/time fields.
      Parameters:
      format - formatting string
    • setUseDefaultTimeZone

      public void setUseDefaultTimeZone(boolean flag)
      Convert date/time fields to default time zone.
      Parameters:
      flag - flag to set
    • setIncludeProfileLoggingId

      public void setIncludeProfileLoggingId(boolean flag)
      Sets whether to suffix the profile's logging ID to the category to log against.

      Defaults to true.

      Parameters:
      flag - flag to set
      Since:
      4.3.0
    • doInitialize

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

      protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext)
      Overrides:
      doPreExecute in class AbstractConditionalProfileAction
    • doExecute

      protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext)
      Overrides:
      doExecute in class AbstractProfileAction
    • filter

      protected void filter(@Nonnull StringBuilder entry)
      Optional override to filter the outgoing log message, does nothing by default.
      Parameters:
      entry - log entry
    • getEvent

      @Nullable protected String getEvent(@Nonnull ProfileRequestContext profileRequestContext)
      Gets the Web Flow event value to log, if any.
      Parameters:
      profileRequestContext - profile request context
      Returns:
      event to log
      Since:
      5.3.0