Class ConfirmTotpAtSignInUseCase

java.lang.Object
com.irurueta.authserver.authorization.application.totp.ConfirmTotpAtSignInUseCase

@Service @Transactional public class ConfirmTotpAtSignInUseCase extends Object
Use case that confirms the enrolment of an authenticator app inside the sign-in, where the code also stands as the second factor of that sign-in: like VerifyTotpUseCase, a locked second factor is refused, a wrong code counts towards the lockout and a right one clears the counter and is audited.
  • Field Details

    • confirmTotpUseCase

      private final ConfirmTotpUseCase confirmTotpUseCase
      Use case that confirms the enrolment.
    • checkSecondFactorLockoutUseCase

      private final CheckSecondFactorLockoutUseCase checkSecondFactorLockoutUseCase
      Use case that tells whether the second factor is locked (and serializes the attempts of a user).
    • registerSecondFactorFailureUseCase

      private final RegisterSecondFactorFailureUseCase registerSecondFactorFailureUseCase
      Use case that counts a failure.
    • resetSecondFactorFailuresUseCase

      private final ResetSecondFactorFailuresUseCase resetSecondFactorFailuresUseCase
      Use case that clears the failures.
    • recordSecurityEventUseCase

      private final RecordSecurityEventUseCase recordSecurityEventUseCase
      Use case that records the audit events.
  • Constructor Details

    • ConfirmTotpAtSignInUseCase

      public ConfirmTotpAtSignInUseCase()
  • Method Details

    • execute

      public Optional<List<String>> execute(UUID userId, String username, String code)
      Confirms the enrolment with the first code of the authenticator app.
      Parameters:
      userId - identifier of the user.
      username - name of the user, for the audit log.
      code - the code as typed.
      Returns:
      the clear-text recovery codes, to be shown once; empty when the code is wrong (the failure is counted).
      Throws:
      SecondFactorLockedException - if the second factor of the user is locked.
      TotpNotEnrolledException - if no enrolment was started.
      TotpAlreadyEnabledException - if the enrolment was already confirmed.