Class JdbcClientAssertionReplayRegistry

java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.clientauth.JdbcClientAssertionReplayRegistry
All Implemented Interfaces:
ClientAssertionReplayRegistry

@Repository public class JdbcClientAssertionReplayRegistry extends Object implements ClientAssertionReplayRegistry
ClientAssertionReplayRegistry over the client_assertion_jtis table. Each method is a single statement run in the caller's transaction. The primary key (client_id, jti) makes the insert atomic: of concurrent registrations of the same pair exactly one inserts a row, the others do nothing and report a replay, without a constraint violation that would abort the caller's transaction.
  • Field Details

    • INSERT

      private static final String INSERT
      Statement recording a first use; a replay inserts nothing.
      See Also:
    • DELETE_EXPIRED

      private static final String DELETE_EXPIRED
      Statement deleting the expired identifiers.
      See Also:
    • jdbcClient

      private final org.springframework.jdbc.core.simple.JdbcClient jdbcClient
      JDBC client used to run the statements.
  • Constructor Details

    • JdbcClientAssertionReplayRegistry

      public JdbcClientAssertionReplayRegistry()
  • Method Details

    • register

      public boolean register(String clientId, String jti, Instant expiresAt)
      Description copied from interface: ClientAssertionReplayRegistry
      Records the first use of an assertion identifier of a client. Safe under concurrency: of several simultaneous registrations of the same pair exactly one returns true.
      Specified by:
      register in interface ClientAssertionReplayRegistry
      Parameters:
      clientId - identifier of the client.
      jti - the jti claim of the assertion.
      expiresAt - instant at which the assertion expires.
      Returns:
      true only when the pair had not been registered before, false for a replay.
    • purgeExpired

      public int purgeExpired(Instant now)
      Description copied from interface: ClientAssertionReplayRegistry
      Forgets the identifiers of the assertions that expired at or before an instant.
      Specified by:
      purgeExpired in interface ClientAssertionReplayRegistry
      Parameters:
      now - the current instant.
      Returns:
      the number of identifiers removed.