Class StoreBackedJSentinelAuditService

java.lang.Object
com.svenruppert.jsentinel.audit.StoreBackedJSentinelAuditService
All Implemented Interfaces:
JSentinelAuditService

@ExperimentalJSentinelApi public final class StoreBackedJSentinelAuditService extends Object implements JSentinelAuditService
JSentinelAuditService that persists events through an AuditEventStore (Phase 2). Complementary to CompositeAuditService, which writes to a RingBufferAuditSink and any extra AuditSinks but never persists.

The service is bound to one TenantId at construction time — single-tenant applications use the no-argument constructor and the resolved tenant defaults to TenantId.DEFAULT. Multi-tenant applications instantiate one service per tenant or wrap this class with a tenant-resolving facade.

Failures propagating from the underlying store are swallowed in publish(AuditEvent) so audit failure cannot break the security flow that emitted the event. query(AuditQuery) does propagate them — read-side failures are an explicit caller concern.

  • Constructor Details

    • StoreBackedJSentinelAuditService

      public StoreBackedJSentinelAuditService(AuditEventStore store)
      Builds a service that operates against TenantId.DEFAULT.
      Parameters:
      store - backing store; must not be null
    • StoreBackedJSentinelAuditService

      public StoreBackedJSentinelAuditService(AuditEventStore store, TenantId tenant)
      Builds a service that operates against the supplied tenant.
      Parameters:
      store - backing store; must not be null
      tenant - tenant scope for every published / queried event; null becomes TenantId.DEFAULT
  • Method Details

    • publish

      public void publish(AuditEvent event)
      Description copied from interface: JSentinelAuditService
      Records the given event. Never throws.
      Specified by:
      publish in interface JSentinelAuditService
      Parameters:
      event - non-null typed audit event
    • query

      public List<AuditEvent> query(AuditQuery query)
      Description copied from interface: JSentinelAuditService
      Returns retained events matching query, oldest first. Implementations that do not retain events return an empty list.
      Specified by:
      query in interface JSentinelAuditService
      Parameters:
      query - filter, never null
      Returns:
      retained matching events, never null
    • tenant

      public TenantId tenant()
      Returns the tenant this service is bound to. Test seam / debug accessor.
      Returns:
      tenant scope