Class GenerateRecoveryCodesUseCase
java.lang.Object
com.irurueta.authserver.authorization.application.totp.GenerateRecoveryCodesUseCase
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of codes in a set.private final HasConfirmedSecondFactorUseCaseUse case that tells whether the user has confirmed a second factor.private final PasswordHasherPort that hashes the codes like passwords.private final RecoveryCodeRepositoryPort that stores the recovery codes.private final RecoveryCodesCreator of the codes. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
CODE_COUNT
public static final int CODE_COUNTNumber of codes in a set.- See Also:
-
recoveryCodeRepository
Port that stores the recovery codes. -
passwordHasher
Port that hashes the codes like passwords. -
recoveryCodes
Creator of the codes. -
hasConfirmedSecondFactorUseCase
Use case that tells whether the user has confirmed a second factor.
-
-
Constructor Details
-
GenerateRecoveryCodesUseCase
public GenerateRecoveryCodesUseCase()
-
-
Method Details
-
execute
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.
-