Class AuditEventBuilder<T extends AuditEventBuilder<T>>

java.lang.Object
org.forgerock.audit.events.AuditEventBuilder<T>
Type Parameters:
T - the type of the builder
Direct Known Subclasses:
AccessAuditEventBuilder, ActivityAuditEventBuilder, AuthenticationAuditEventBuilder, ConfigAuditEventBuilder

public abstract class AuditEventBuilder<T extends AuditEventBuilder<T>> extends Object
Root builder for all audit events.
  • Field Details

    • EVENT_NAME

      public static final String EVENT_NAME
      Event name event payload field name.
      See Also:
    • TIMESTAMP

      public static final String TIMESTAMP
      Timestamp event payload field name.
      See Also:
    • TRANSACTION_ID

      public static final String TRANSACTION_ID
      Transaction ID event payload field name.
      See Also:
    • USER_ID

      public static final String USER_ID
      User ID event payload field name.
      See Also:
    • TRACKING_IDS

      public static final String TRACKING_IDS
      Tracking IDs event payload field name.
      See Also:
    • ISO_OFFSET_DATE_TIME_FORMAT

      public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_FORMAT
      ISO 8601 date-time formatter '2011-12-03T10:15:30.000Z' specifically for UTC/GMT time zone.
    • jsonValue

      protected JsonValue jsonValue
      Represents the event as a JSON value.
  • Constructor Details

    • AuditEventBuilder

      protected AuditEventBuilder()
      Creates the builder.
  • Method Details

    • self

      protected final T self()
      Returns this object, as its actual type.
      Returns:
      this object
    • toEvent

      public final AuditEvent toEvent()
      Generates the audit event. As a side-effect of calling this method, this builder is reset to its starting state.
      Returns:
      the audit event
    • setDefaults

      protected void setDefaults()
      Called by toEvent() to allow any unset fields to be given their default value. When overriding this method, the super class implementation must be called.
    • validate

      protected void validate()
      Called by toEvent() to ensure that the audit event will be created in a valid state. When overriding this method, the super class implementation must be called.
      Throws:
      IllegalStateException - if a required field has not been populated.
    • requireField

      protected void requireField(String rootFieldName)
      Helper method to be used when overriding validate().
      Parameters:
      rootFieldName - The name of the field that must be populated.
      Throws:
      IllegalStateException - if the required field has not been populated.
    • eventName

      public final T eventName(String name)
      Sets the provided name for the event. An event's name will usually be of the form {product}-{component}-{operation}. For example, AM-SESSION-CREATED, AM-CREST-SUCCESSFUL, etc.
      Parameters:
      name - the event's name.
      Returns:
      this builder
    • timestamp

      public final T timestamp(long timestamp)
      Sets the provided time stamp for the event.
      Parameters:
      timestamp - the time stamp.
      Returns:
      this builder
    • transactionId

      public final T transactionId(String id)
      Sets the provided transactionId for the event.
      Parameters:
      id - the transaction id.
      Returns:
      this builder
    • userId

      public final T userId(String id)
      Sets the provided userId for the event.
      Parameters:
      id - the user id.
      Returns:
      this builder
    • trackingId

      public final T trackingId(String trackingIdValue)
      Adds an entry to trackingIds for the event.
      Parameters:
      trackingIdValue - the unique value associated with the object being tracked.
      Returns:
      this builder
    • trackingIds

      public final T trackingIds(Set<String> trackingIdValues)
      Adds the specified entries to trackingIds for the event.
      Parameters:
      trackingIdValues - the set of trackingId entries to be recorded (see trackingId(java.lang.String).
      Returns:
      this builder
    • transactionIdFromContext

      public final T transactionIdFromContext(org.forgerock.services.context.Context context)
      Sets transactionId from ID of TransactionIdContext, if the provided Context contains a TransactionIdContext.
      Parameters:
      context - The CREST context.
      Returns:
      this builder