Package com.tnsai.security.audit
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 Summary
Modifier and TypeMethodDescriptionlongcount(AuditQuery query) Counts events matching the given criteria.longdeleteOlderThan(Instant cutoff) Deletes events older than the given cutoff.static AuditStorediscover()Discovers an AuditStore via ServiceLoader.query(AuditQuery query) Queries audit events matching the given criteria.voidrecord(AuditEvent event) Records an audit event.
-
Method Details
-
record
Records an audit event.- Parameters:
event- the event to record (must not be null)
-
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
Counts events matching the given criteria.- Parameters:
query- the query criteria (limit is ignored for counting)- Returns:
- number of matching events
-
deleteOlderThan
Deletes events older than the given cutoff.- Parameters:
cutoff- events with timestamp before this are deleted- Returns:
- number of events deleted
-
discover
Discovers an AuditStore via ServiceLoader.- Returns:
- discovered store, or null if none on classpath
-