Class JdbcOneTimeCodeRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.ott.JdbcOneTimeCodeRepository
- All Implemented Interfaces:
OneTimeCodeRepository
OneTimeCodeRepository over the ott_codes table. It opens no transaction: replacing a code runs in
the caller's, and every other operation is a single statement.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringStatement spending a code.private static final StringStatement deleting the codes of a binding and a user name.private static final StringStatement deleting the expired codes.private static final StringQuery returning the newest unexpired code of a binding and a user name.private static final StringStatement counting a failed attempt atomically and returning the new count.private static final StringStatement storing a code.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the statements.private final OneTimeCodeRowMapperMaps a row to a code. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintdeleteExpired(Instant now) findActive(String bindingId, String username, Instant now) intvoidsave(OneTimeCode code)
-
Field Details
-
DELETE_BY_BINDING
Statement deleting the codes of a binding and a user name.- See Also:
-
INSERT
Statement storing a code.- See Also:
-
FIND_ACTIVE
Query returning the newest unexpired code of a binding and a user name.- See Also:
-
INCREMENT_ATTEMPTS
Statement counting a failed attempt atomically and returning the new count.- See Also:
-
CONSUME
Statement spending a code.- See Also:
-
DELETE_EXPIRED
Statement deleting the expired codes.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the statements. -
oneTimeCodeRowMapper
Maps a row to a code.
-
-
Constructor Details
-
JdbcOneTimeCodeRepository
public JdbcOneTimeCodeRepository()
-
-
Method Details
-
save
- Specified by:
savein interfaceOneTimeCodeRepository
-
findActive
- Specified by:
findActivein interfaceOneTimeCodeRepository
-
incrementAttempts
- Specified by:
incrementAttemptsin interfaceOneTimeCodeRepository
-
consume
- Specified by:
consumein interfaceOneTimeCodeRepository
-
deleteExpired
- Specified by:
deleteExpiredin interfaceOneTimeCodeRepository
-