Class AuditEvent

java.lang.Object
org.springframework.boot.actuate.audit.AuditEvent
All Implemented Interfaces:
Serializable

public class AuditEvent extends Object implements Serializable
A value object representing an audit event: at a particular time, a particular user or agent carried out an action of a particular type. This object records the details of such an event.

Users can inject a AuditEventRepository to publish their own events or alternatively use Spring's ApplicationEventPublisher (usually obtained by implementing ApplicationEventPublisherAware) to publish AuditApplicationEvents (wrappers for AuditEvent).

Since:
1.0.0
Author:
Dave Syer
See Also:
  • Constructor Details

    • AuditEvent

      public AuditEvent(String principal, String type, Map<String,Object> data)
      Create a new audit event for the current time.
      Parameters:
      principal - the user principal responsible
      type - the event type
      data - the event data
    • AuditEvent

      public AuditEvent(String principal, String type, String... data)
      Create a new audit event for the current time from data provided as name-value pairs.
      Parameters:
      principal - the user principal responsible
      type - the event type
      data - the event data in the form 'key=value' or simply 'key'
    • AuditEvent

      public AuditEvent(Instant timestamp, String principal, String type, Map<String,Object> data)
      Create a new audit event.
      Parameters:
      timestamp - the date/time of the event
      principal - the user principal responsible
      type - the event type
      data - the event data
  • Method Details

    • getTimestamp

      public Instant getTimestamp()
      Returns the date/time that the event was logged.
      Returns:
      the timestamp
    • getPrincipal

      public String getPrincipal()
      Returns the user principal responsible for the event or an empty String if the principal is not available.
      Returns:
      the principal
    • getType

      public String getType()
      Returns the type of event.
      Returns:
      the event type
    • getData

      public Map<String,Object> getData()
      Returns the event data.
      Returns:
      the event data
    • toString

      public String toString()
      Overrides:
      toString in class Object