Class RegisterAccountUseCase
java.lang.Object
com.irurueta.authserver.authorization.application.account.RegisterAccountUseCase
Use case that registers an account. The account starts disabled and unverified; a signed verification token is
e-mailed to the address. The answer is always the same and the password is always hashed, so neither the answer
nor its timing reveals whether the address or the username is taken. What the address receives differs only where
its owner learns nothing new:
- a registered address gets a neutral "already registered" message: its owner already knows it has an account;
- a new address with a taken username gets the usual verification message, whose token names no account, so following it fails exactly like an expired link. The username is never confirmed to whoever controls the address, so the endpoint cannot be used to find out which usernames exist.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AccountMailerPort that sends the e-mails.private final CompromisedPasswordCheckPort that checks passwords against leaked ones.static final StringAuthority granted to registered accounts.private final PasswordHasherPort that hashes passwords.private final PasswordPolicyRules a new password must follow.private final SignedTokenServicePort that issues the verification token.private final UserAccountRepositoryPort that stores the accounts.static final DurationHow long the e-mailed verification token stays valid. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DEFAULT_AUTHORITY
Authority granted to registered accounts.- See Also:
-
VERIFICATION_TTL
How long the e-mailed verification token stays valid. -
userAccountRepository
Port that stores the accounts. -
passwordHasher
Port that hashes passwords. -
compromisedPasswordCheck
Port that checks passwords against leaked ones. -
signedTokenService
Port that issues the verification token. -
accountMailer
Port that sends the e-mails. -
passwordPolicy
Rules a new password must follow.
-
-
Constructor Details
-
RegisterAccountUseCase
public RegisterAccountUseCase()
-
-
Method Details
-
execute
Registers an account.- Parameters:
username- name the user will sign in with.email- e-mail address of the user.password- the chosen clear-text password.- Throws:
InvalidPasswordException- if the password breaks the policy.CompromisedPasswordException- if the password is known to be compromised.
-