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.
    • formattingMap

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

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

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

      @Nullable private RequestContext requestContext
      The Spring RequestContext to operate on.
    • auditCtx

      @Nullable private AuditContext auditCtx
      The AuditContext to operate on.
    • httpRequest

      @Nullable private javax.servlet.http.HttpServletRequest httpRequest
      HttpServletRequest object.
  • 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
    • getFormattingMap

      @Nonnull @NonnullElements @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​(@Nonnull @NonnullElements 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
    • 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
    • doInitialize

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

      @Nonnull protected Event doExecute​(@Nonnull RequestContext springRequestContext, @Nonnull ProfileRequestContext profileRequestContext)
      Spring-aware actions can override this method to fully control the execution of an Action by the Web Flow engine.

      Alternatively they may override AbstractProfileAction.doExecute(ProfileRequestContext) and access Spring information via a SpringRequestContext attached to the profile request context.

      The default implementation attaches the Spring Web Flow request context to the profile request context tree to "narrow" the execution signature to the basic OpenSAML ProfileAction interface. After execution, an EventContext is sought, and used to return a result back to the Web Flow engine. If no context exists, a "proceed" event is signaled.

      Overrides:
      doExecute in class AbstractProfileAction
      Parameters:
      springRequestContext - the Spring request context
      profileRequestContext - a profile request context
      Returns:
      a Web Flow event produced by the action
    • 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