Class JdbcTotpCredentialRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.totp.JdbcTotpCredentialRepository
- All Implemented Interfaces:
TotpCredentialRepository
@Repository
public class JdbcTotpCredentialRepository
extends Object
implements TotpCredentialRepository
TotpCredentialRepository over the totp_credentials table.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringStatement that records a step only when it is newer than the stored one, atomically.private static final StringStatement confirming the credential of a user.private static final StringStatement deleting the credential of a user.private static final StringQuery returning the credential of a user.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the statements.private final TotpCredentialRowMapperMaps a row to a credential.private static final StringStatement inserting a credential, or replacing the one of the same user. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadvanceLastUsedStep(UUID userId, long step) Records the step of an accepted code, in one atomic step that only succeeds when the step is newer than the stored one, so that two concurrent requests cannot both spend the same code.voidMarks the credential of a user as confirmed.voiddeleteByUser(UUID userId) Deletes the credential of a user.findByUser(UUID userId) Finds the credential of a user.voidsave(TotpCredential credential) Stores a credential, replacing any previous one of the same user.
-
Field Details
-
FIND_BY_USER
Query returning the credential of a user.- See Also:
-
UPSERT
Statement inserting a credential, or replacing the one of the same user.- See Also:
-
CONFIRM
Statement confirming the credential of a user.- See Also:
-
ADVANCE_LAST_USED_STEP
Statement that records a step only when it is newer than the stored one, atomically.- See Also:
-
DELETE_BY_USER
Statement deleting the credential of a user.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the statements. -
totpCredentialRowMapper
Maps a row to a credential.
-
-
Constructor Details
-
JdbcTotpCredentialRepository
public JdbcTotpCredentialRepository()
-
-
Method Details
-
findByUser
Description copied from interface:TotpCredentialRepositoryFinds the credential of a user.- Specified by:
findByUserin interfaceTotpCredentialRepository- Parameters:
userId- identifier of the user.- Returns:
- the credential, or an empty optional when the user has none.
-
save
Description copied from interface:TotpCredentialRepositoryStores a credential, replacing any previous one of the same user.- Specified by:
savein interfaceTotpCredentialRepository- Parameters:
credential- the credential to store.
-
confirm
Description copied from interface:TotpCredentialRepositoryMarks the credential of a user as confirmed.- Specified by:
confirmin interfaceTotpCredentialRepository- Parameters:
userId- identifier of the user.
-
advanceLastUsedStep
Description copied from interface:TotpCredentialRepositoryRecords the step of an accepted code, in one atomic step that only succeeds when the step is newer than the stored one, so that two concurrent requests cannot both spend the same code.- Specified by:
advanceLastUsedStepin interfaceTotpCredentialRepository- Parameters:
userId- identifier of the user.step- step of the accepted code.- Returns:
truewhen the step was newer and has been recorded.
-
deleteByUser
Description copied from interface:TotpCredentialRepositoryDeletes the credential of a user.- Specified by:
deleteByUserin interfaceTotpCredentialRepository- Parameters:
userId- identifier of the user.
-