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'sApplicationEventPublisher
(usually obtained by implementingApplicationEventPublisherAware
) to publish AuditApplicationEvents (wrappers for AuditEvent).- See Also:
AuditEventRepository
, Serialized Form
Constructor Summary
Constructors Constructor Description AuditEvent(String principal, String type, String... data)
Create a new audit event for the current time from data provided as name-value pairs.AuditEvent(String principal, String type, Map<String,Object> data)
Create a new audit event for the current time.AuditEvent(Instant timestamp, String principal, String type, Map<String,Object> data)
Create a new audit event.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
getData()
Returns the event data.String
getPrincipal()
Returns the user principal responsible for the event or an empty String if the principal is not available.Instant
getTimestamp()
Returns the date/time that the event was logged.String
getType()
Returns the type of event.String
toString()
Constructor Detail
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 responsibletype
- the event typedata
- 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 responsibletype
- the event typedata
- the event data in the form 'key=value' or simply 'key'
Method Detail
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