Class SecurityEventLog
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
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe context of an event: who and where, all optional.Constructor Summary
ConstructorsConstructorDescriptionSecurityEventLog(SecurityEventStore store, Executor executor) Constructs an event log on a store and an executor: the tests' constructor.Method Summary
Modifier and TypeMethodDescriptionstatic SecurityEventLog.ContextcontextOf(IAppSessionGyro appGyro) Gets the context of an application session: that of its first client session, else its user and application alone.static SecurityEventLog.ContextcontextOf(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.static SecurityEventLog.ContextcontextOf(UserInfoBase user, String appID) Gets the context of a user outside a session: an administrator's action on another account, the daily purge.static SecurityEventLogGets the server's event log.getStore()Gets the store.voidlog(SecuritySeverity severity, SecurityEventKind kind, String text, IClientSessionGyro clientGyro) Logs an event of a client session.voidlog(SecuritySeverity severity, SecurityEventKind kind, String text, AppSessionGyro appGyro) Logs an event of an application session.voidlog(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.intpurge(int days) Deletes the events older than the days kept: the daily purge, with the sign-in records.
Constructor Details
SecurityEventLog
Constructs an event log on a store and an executor: the tests' constructor.- Parameters:
store- The store.executor- Where the writes run;Runnable::runfor the tests that want them done when the call returns.
Method Details
getInstance
getStore
Gets the store.- Returns:
- The store, for ServerAdmin's lists and the purge.
contextOf
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
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
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 toISecurityEventLogger.MAX_TEXT_LENGTH.context- The context, null for none.- Throws:
NullPointerException- Ifseverityorkindis 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).