Class SecurityEventLog

java.lang.Object
com.iizix.server.user.SecurityEventLog

public final class SecurityEventLog extends Object
The security event log of the server (CC-SIGNIN-RECORDS-AND-SECURITY-LOG, order 556): where every "serious" event of a client session or an application session goes - the one implementation behind IClientSessionGyro.logSecurityEvent and IAppSessionGyro.logSecurityEvent, and what the server's own sign-in code calls.

What happens to an event. One line goes to the server log through ILog at once, at the level of its severity (CRITICAL is SEVERE with "CRITICAL" in front, as SecuritySeverity says), under the originator SecurityEventLog, with the session's user, application, device, client address and the place of the address when it is known already (cached). Then, on a virtual thread so that the caller never waits, the place is looked up when it was not, and the event is written into IZS.SECURITY_EVENTS (SecurityEventStore) for ServerAdmin. A failure there is logged WARNING at most once a minute and never reaches the caller: an event that cannot be kept is still in the log, and a sign-in that logs an event is never failed by the logging.

Why ILog and not the server shell: every audit line the server writes today is an ILog line (the "Sign-in setting ... changed" lines of the settings page, the device token lines, the session geolocation lines), ILog is reachable from every class including the SignIn module's, carries the levels, and is what ServerAdmin's Log page shows and filters; the shell has no audit facility to extend.

Author:
Christopher Mindus
  • Constructor Details

    • SecurityEventLog

      public SecurityEventLog(SecurityEventStore store, Executor executor)
      Constructs an event log on a store and an executor: the tests' constructor.
      Parameters:
      store - The store.
      executor - Where the writes run; Runnable::run for the tests that want them done when the call returns.
  • Method Details

    • getInstance

      public static SecurityEventLog getInstance()
      Gets the server's event log.
      Returns:
      The instance.
    • getStore

      public SecurityEventStore getStore()
      Gets the store.
      Returns:
      The store, for ServerAdmin's lists and the purge.
    • contextOf

      public static SecurityEventLog.Context contextOf(IClientSessionGyro clientGyro)
      Gets the context of a client session: its user, application, device and client address, and the place when the provider has it cached.
      Parameters:
      clientGyro - The client session, null for none.
      Returns:
      The context, never null.
    • contextOf

      public static SecurityEventLog.Context contextOf(IAppSessionGyro appGyro)
      Gets the context of an application session: that of its first client session, else its user and application alone.
      Parameters:
      appGyro - The application session, null for none.
      Returns:
      The context, never null.
    • contextOf

      public static SecurityEventLog.Context contextOf(UserInfoBase user, String appID)
      Gets the context of a user outside a session: an administrator's action on another account, the daily purge.
      Parameters:
      user - The user the event is about, null for none.
      appID - The application, null for none.
      Returns:
      The context.
    • log

      public void log(SecuritySeverity severity, SecurityEventKind kind, String text, IClientSessionGyro clientGyro)
      Logs an event of a client session.
      Parameters:
      severity - The severity.
      kind - The kind.
      text - What happened, null for the kind's name.
      clientGyro - The client session, null for none.
    • log

      public void log(SecuritySeverity severity, SecurityEventKind kind, String text, AppSessionGyro appGyro)
      Logs an event of an application session.
      Parameters:
      severity - The severity.
      kind - The kind.
      text - What happened, null for the kind's name.
      appGyro - The application session, null for none.
    • log

      public void log(SecuritySeverity severity, SecurityEventKind kind, String text, SecurityEventLog.Context context)
      Logs an event in a context: the log line now, the row on a virtual thread. Never throws.
      Parameters:
      severity - The severity.
      kind - The kind.
      text - What happened, null for the kind's name; cut to ISecurityEventLogger.MAX_TEXT_LENGTH.
      context - The context, null for none.
      Throws:
      NullPointerException - If severity or kind is null.
    • purge

      public int purge(int days)
      Deletes the events older than the days kept: the daily purge, with the sign-in records.
      Parameters:
      days - The days kept.
      Returns:
      The rows deleted, 0 when the store is unavailable or the purge failed (logged).