Class TotpCodeVerifier
java.lang.Object
com.irurueta.authserver.authorization.api.web.totp.TotpCodeVerifier
Sends a posted code to the use case of its kind (
TotpCodeKind): a TOTP code, a recovery code, or the first
code of an authenticator app enrolled during the sign-in. The use cases count the failures, lock the second factor
after too many and clear the counter on success.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfirmTotpAtSignInUseCaseUse case that confirms an enrolment during the sign-in.private final VerifyRecoveryCodeUseCaseUse case that verifies (and consumes) a recovery code.private final VerifyTotpUseCaseUse case that verifies a TOTP code. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanconfirmEnrolment(TotpAuthenticationToken request, UUID userId, String username) Confirms an enrolment and hands the new recovery codes back through the request.booleanverify(TotpAuthenticationToken request, UUID userId, String username) Verifies a posted code; for an enrolment, the new recovery codes are handed back through the request.
-
Field Details
-
verifyTotpUseCase
Use case that verifies a TOTP code. -
verifyRecoveryCodeUseCase
Use case that verifies (and consumes) a recovery code. -
confirmTotpAtSignInUseCase
Use case that confirms an enrolment during the sign-in.
-
-
Constructor Details
-
TotpCodeVerifier
public TotpCodeVerifier()
-
-
Method Details
-
verify
Verifies a posted code; for an enrolment, the new recovery codes are handed back through the request.- Parameters:
request- the verification request.userId- identifier of the user.username- name of the user, for the audit log.- Returns:
truewhen the code is accepted.- Throws:
SecondFactorLockedException- if the second factor of the user is locked.TotpNotEnrolledException- if an enrolment code is posted while no enrolment was started.TotpAlreadyEnabledException- if an enrolment code is posted for an app that is already enabled.
-
confirmEnrolment
Confirms an enrolment and hands the new recovery codes back through the request.- Parameters:
request- the verification request.userId- identifier of the user.username- name of the user.- Returns:
truewhen the code confirmed the enrolment.
-