Interface AuditStore


public interface AuditStore
Persistent storage for audit events.

Implementations must be thread-safe. Events are append-only; the only mutation is deleteOlderThan(Instant) for retention.

Implementations

  • InMemoryAuditStore - In-memory (testing)
  • FileAuditStore - JSON file persistence

SPI Discovery

Register implementations in META-INF/services/com.tnsai.security.audit.AuditStore

See Also:
  • Method Details

    • record

      void record(AuditEvent event)
      Records an audit event.
      Parameters:
      event - the event to record (must not be null)
    • query

      List<AuditEvent> query(AuditQuery query)
      Queries audit events matching the given criteria.

      Results are returned in chronological order (oldest first).

      Parameters:
      query - the query criteria
      Returns:
      matching events, possibly empty
    • count

      long count(AuditQuery query)
      Counts events matching the given criteria.
      Parameters:
      query - the query criteria (limit is ignored for counting)
      Returns:
      number of matching events
    • deleteOlderThan

      long deleteOlderThan(Instant cutoff)
      Deletes events older than the given cutoff.
      Parameters:
      cutoff - events with timestamp before this are deleted
      Returns:
      number of events deleted
    • discover

      static AuditStore discover()
      Discovers an AuditStore via ServiceLoader.
      Returns:
      discovered store, or null if none on classpath