Class ConfirmTotpUseCase
java.lang.Object
com.irurueta.authserver.authorization.application.totp.ConfirmTotpUseCase
Use case that finishes the enrolment of an authenticator app with the first code it shows. The step of that code is
stored so it cannot be replayed, the credential is confirmed and the recovery codes are generated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockSource of the current time.private final GenerateRecoveryCodesUseCaseUse case that creates the recovery codes.private final TotpAlgorithmThe TOTP algorithm.private final TotpCredentialRepositoryPort that stores the TOTP credentials.private final TotpSecretCipherPort that decrypts the secrets. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConfirms the enrolment.tryConfirm(UUID userId, String code) Confirms the enrolment, answering a wrong code with an empty result instead of an exception, so that a caller running in the same transaction can still count the failure (an exception leaving a transactional method marks the whole transaction for rollback).
-
Field Details
-
totpCredentialRepository
Port that stores the TOTP credentials. -
totpSecretCipher
Port that decrypts the secrets. -
totpAlgorithm
The TOTP algorithm. -
generateRecoveryCodesUseCase
Use case that creates the recovery codes. -
clock
Source of the current time.
-
-
Constructor Details
-
ConfirmTotpUseCase
public ConfirmTotpUseCase()
-
-
Method Details
-
execute
Confirms the enrolment.- Parameters:
userId- identifier of the user.code- the code shown by the authenticator app.- Returns:
- the clear-text recovery codes, to be shown once.
- Throws:
TotpNotEnrolledException- if no enrolment was started.TotpAlreadyEnabledException- if the enrolment was already confirmed.InvalidTotpCodeException- if the code is wrong.
-
tryConfirm
Confirms the enrolment, answering a wrong code with an empty result instead of an exception, so that a caller running in the same transaction can still count the failure (an exception leaving a transactional method marks the whole transaction for rollback).- Parameters:
userId- identifier of the user.code- the code shown by the authenticator app.- Returns:
- the clear-text recovery codes, to be shown once; empty when the code is wrong.
- Throws:
TotpNotEnrolledException- if no enrolment was started.TotpAlreadyEnabledException- if the enrolment was already confirmed.
-