Class ConfirmPhoneUseCase
java.lang.Object
com.irurueta.authserver.authorization.application.sms.ConfirmPhoneUseCase
Confirms a phone with the code that was sent to it. Every way of failing returns the same
false: no
pending verification, an expired or burnt code, a wrong code and a number that another user verified meanwhile.
Confirming a number other than the verified one replaces a second factor: the replacement is audited as the removal of the old phone, and every trusted device of the user is revoked, as disabling TOTP does, because those browsers were remembered in place of a factor the user no longer has.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockSource of the current time.private final OneTimeCodeHasherHasher of the verification code.private final PhoneVerificationRepositoryPort that stores the pending verification.private final RecordSecurityEventUseCaseUse case that records the audit events.(package private) static final StringStart of the detail of the audit event of a replaced phone, followed by the number of revoked devices.private final SmsPropertiesSMS settings.private final TrustedDeviceRepositoryPort that stores the trusted devices.private final UserPhoneRepositoryPort that stores the verified phones. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanConfirms the phone of a user.private booleanverify(UUID userId, String username, PhoneVerification pending, Instant now) Stores the verified phone, clears the pending verification and handles the replacement of another number.
-
Field Details
-
REPLACED_DETAIL
Start of the detail of the audit event of a replaced phone, followed by the number of revoked devices.- See Also:
-
userPhoneRepository
Port that stores the verified phones. -
phoneVerificationRepository
Port that stores the pending verification. -
oneTimeCodeHasher
Hasher of the verification code. -
trustedDeviceRepository
Port that stores the trusted devices. -
recordSecurityEventUseCase
Use case that records the audit events. -
smsProperties
SMS settings. -
clock
Source of the current time.
-
-
Constructor Details
-
ConfirmPhoneUseCase
public ConfirmPhoneUseCase()
-
-
Method Details
-
execute
Confirms the phone of a user.- Parameters:
userId- identifier of the user.username- name of the user, for the audit log.code- the code as typed.- Returns:
truewhen the code was right and the phone is now verified.
-
verify
Stores the verified phone, clears the pending verification and handles the replacement of another number.- Parameters:
userId- identifier of the user.username- name of the user, for the audit log.pending- the verification that was confirmed.now- the current instant.- Returns:
truewhen the phone was stored,falsewhen another user owns the number.
-