Class GenerateRecoveryCodesUseCase

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

@Service @Transactional public class GenerateRecoveryCodesUseCase extends Object
Use case that creates a fresh set of recovery codes for a user, replacing any previous set. The clear-text codes are returned once; only their hashes are stored. Recovery codes stand in for a second factor, so they are only issued to a user who has confirmed one.
  • Field Details

    • CODE_COUNT

      public static final int CODE_COUNT
      Number of codes in a set.
      See Also:
    • recoveryCodeRepository

      private final RecoveryCodeRepository recoveryCodeRepository
      Port that stores the recovery codes.
    • passwordHasher

      private final PasswordHasher passwordHasher
      Port that hashes the codes like passwords.
    • recoveryCodes

      private final RecoveryCodes recoveryCodes
      Creator of the codes.
    • hasConfirmedSecondFactorUseCase

      private final HasConfirmedSecondFactorUseCase hasConfirmedSecondFactorUseCase
      Use case that tells whether the user has confirmed a second factor.
  • Constructor Details

    • GenerateRecoveryCodesUseCase

      public GenerateRecoveryCodesUseCase()
  • Method Details

    • execute

      public List<String> execute(UUID userId)
      Generates the codes.
      Parameters:
      userId - identifier of the user.
      Returns:
      the clear-text codes, to be shown to the user once.
      Throws:
      TotpNotEnrolledException - if the user has no confirmed second factor.