Class SecurityEventStore
java.lang.Object
com.iizix.server.user.SecurityEventStore
The security events kept for ServerAdmin (CC-SIGNIN-RECORDS-AND-SECURITY-LOG, order 556): one row per event
SecurityEventLog was given - a sign-in, a sign-in refused, a second factor that failed, a recovery code used, a policy changed, a break-glass reset - with the session's user, application, device, client address and place. The server log holds the same events as lines; the table is what ServerAdmin lists and filters.The table IZS.SECURITY_EVENTS is created here when it is absent, as DeviceTokenStore creates its own. Where it cannot be created the store is unavailable: the events still reach the server log, nothing is kept, and nothing that logged an event is affected. A deleted user's rows stay, their uid set to NULL and the user's name kept, until the purge: an audit line does not vanish with its account. Rows are deleted by the daily purge (purge(int)) after $signIn.signInRecordDays days.
SQL-92, Derby, PostgreSQL and MySQL. Thread-safe: every method takes its own connection.
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne event, as written and as read.Constructor Summary
ConstructorsConstructorDescriptionSecurityEventStore(ConnectionSource connections) Constructs the store on the system clock.SecurityEventStore(ConnectionSource connections, LongSupplier clock) Constructs the store on a clock.Method Summary
Modifier and TypeMethodDescriptionbooleanCreates the table when it is absent.list(Long uid, SecuritySeverity atLeast, int limit) Lists events, the newest first; those of one time value - two servers' events, seeSecurityEventLog.stamp()- by identifier.intpurge(int days) Deletes the events older than a number of days: the daily purge.Writes an event.
Constructor Details
SecurityEventStore
Constructs the store on the system clock.- Parameters:
connections- The connection source, in the serverDBUtilities::getPooledConnection.
SecurityEventStore
Constructs the store on a clock.- Parameters:
connections- The connection source.clock- The clock: epoch milliseconds.
Method Details
ensureSchema
Creates the table when it is absent.- Returns:
- true if the table was created here, false if it existed or another server made it.
- Throws:
SQLException- For SQL errors: the table is absent and cannot be created.
write
Writes an event. The texts are cut to their columns; the identifier is made here when the event's is zero.- Parameters:
ev- The event.- Returns:
- The event as written (its identifier set), null when the store is unavailable.
- Throws:
NullPointerException- If the event, its severity, kind or text is null.SQLException- For SQL errors.
purge
Deletes the events older than a number of days: the daily purge.- Parameters:
days- The days kept, positive.- Returns:
- The number of rows deleted.
- Throws:
IllegalArgumentException- Ifdaysis not positive.SQLException- For SQL errors.
list
public List<SecurityEventStore.Event> list(Long uid, SecuritySeverity atLeast, int limit) throws SQLException Lists events, the newest first; those of one time value - two servers' events, seeSecurityEventLog.stamp()- by identifier.- Parameters:
uid- The user whose events, null for every user's.atLeast- The least severity listed, null for every severity.limit- The most rows, positive.- Returns:
- The events, possibly none; none when the store is unavailable.
- Throws:
SQLException- For SQL errors.