Class ChangePasswordUseCase

java.lang.Object
com.irurueta.authserver.authorization.application.account.ChangePasswordUseCase

@Service public class ChangePasswordUseCase extends Object
Use case that lets a signed-in user choose a new password. Every token of the user is revoked afterwards, in the same transaction as the password update, so a failed revocation never leaves the new password with the old tokens.
  • Field Details

    • userAccountRepository

      private final UserAccountRepository userAccountRepository
      Port that stores the accounts.
    • passwordHasher

      private final PasswordHasher passwordHasher
      Port that hashes passwords.
    • compromisedPasswordCheck

      private final CompromisedPasswordCheck compromisedPasswordCheck
      Port that checks passwords against leaked ones.
    • revokeUserAuthorizationsUseCase

      private final RevokeUserAuthorizationsUseCase revokeUserAuthorizationsUseCase
      Use case that revokes the tokens of the user.
    • passwordPolicy

      private final PasswordPolicy passwordPolicy
      Rules a new password must follow.
  • Constructor Details

    • ChangePasswordUseCase

      public ChangePasswordUseCase()
  • Method Details

    • execute

      @Transactional public void execute(String username, String currentPassword, String newPassword)
      Changes the password of a user.
      Parameters:
      username - name of the user.
      currentPassword - the clear-text current password.
      newPassword - the clear-text new password.
      Throws:
      InvalidCredentialsException - if the user is unknown or the current password is wrong.
      InvalidPasswordException - if the new password breaks the policy.
      CompromisedPasswordException - if the new password is known to be compromised.