@Service(value="userPasswordManagement") public class UserPasswordManagementImpl extends Object implements UserPasswordManagement
Constructor and Description |
---|
UserPasswordManagementImpl(UserDao userDao,
ForgottenPasswordSecurityCodeDao forgottenPasswordSecurityCodeDao,
SecurityCodeManagement securityCodeManagement,
MailSender mailSender) |
Modifier and Type | Method and Description |
---|---|
void |
changePassword(Long userId,
String newPassword)
Change the password of a user.
|
void |
changePassword(String securityCode,
String password)
Change the password of a user who used the forgotten password feature
(
UserPasswordManagement.requestPasswordChange(String) ) to request a new password. |
void |
changePassword(User user,
String newPassword)
Change the password of a user.
|
boolean |
checkAndUpdatePassword(User user,
String password)
Check that the (hashed) password of the user matches the given clear text password.
|
boolean |
checkPassword(Long userId,
String password)
Check that the (hashed) password of the user matches the given clear text password.
|
boolean |
checkPassword(User user,
String password)
Check that the (hashed) password of the user matches the given clear text password.
|
void |
register(PasswordHashFunction hashFunction)
Register a hash function for generating and checking password hashes.
|
void |
requestPasswordChange(String email)
Request a new password for the given user.
|
void |
unregister(PasswordHashFunction hashFunction)
Remove a previously registered password hash function.
|
void |
validatePassword(String newPassword)
Validate that a password matches the minimum security requirements to be used in user
accounts
|
@Autowired public UserPasswordManagementImpl(UserDao userDao, ForgottenPasswordSecurityCodeDao forgottenPasswordSecurityCodeDao, SecurityCodeManagement securityCodeManagement, MailSender mailSender)
@Transactional(propagation=REQUIRED) public void changePassword(Long userId, String newPassword) throws PasswordValidationException, UserNotFoundException, AuthorizationException, ExternalUserPasswordChangeNotAllowedException
UserPasswordManagement
changePassword
in interface UserPasswordManagement
userId
- the ID of the user for whom the password should be changednewPassword
- the new clear text passwordPasswordValidationException
- in case the new password doesn't fulfill the minimum security requirements to be
used in user accountsUserNotFoundException
- in case the user with the given ID does not existAuthorizationException
- in case the current user is not the user with the userId or the current user is
not client admin or internal system userExternalUserPasswordChangeNotAllowedException
- in case the user was provided by the primary external user repository@Transactional(propagation=REQUIRED) public void changePassword(String securityCode, String password) throws SecurityCodeNotFoundException, PasswordValidationException, ExternalUserPasswordChangeNotAllowedException
UserPasswordManagement
UserPasswordManagement.requestPasswordChange(String)
) to request a new password.changePassword
in interface UserPasswordManagement
securityCode
- security code created by the forgotten password featurepassword
- the new clear text passwordSecurityCodeNotFoundException
- in case the security code does not exist or does not belong to a forgotten
password security codePasswordValidationException
- in case the new password doesn't fulfill the minimum security requirements to be
used in user accountsExternalUserPasswordChangeNotAllowedException
- in case the user was provided by the primary external user repository@Transactional(propagation=MANDATORY) public void changePassword(User user, String newPassword) throws PasswordValidationException, ExternalUserPasswordChangeNotAllowedException
UserPasswordManagement
Change the password of a user.
Note: this method does not check whether the current user is allowed to change the password. Moreover, an existing transaction is required.
changePassword
in interface UserPasswordManagement
user
- the user whose password should be changednewPassword
- the new clear text passwordPasswordValidationException
- in case the new password doesn't fulfill the minimum security requirements to be
used in user accountsExternalUserPasswordChangeNotAllowedException
- in case the user was provided by the primary external user repository@Transactional(propagation=MANDATORY) public boolean checkAndUpdatePassword(User user, String password)
UserPasswordManagement
Check that the (hashed) password of the user matches the given clear text password. If the password matches it will be checked whether the password should be updated to meet the current security requirements. An update will be necessary if the user's password was created with a hash function other than the current hash function or if the hash function didn't change but was reconfigured to produce a stronger hash value.
Note: if an update of password is necessary the given clear text password is not validated
with UserPasswordManagement.validatePassword(String)
. Moreover, an existing transaction is required.
checkAndUpdatePassword
in interface UserPasswordManagement
user
- the user whose password should be checked and updatedpassword
- the clear text password to test against@Transactional(propagation=REQUIRED, readOnly=true) public boolean checkPassword(Long userId, String password)
UserPasswordManagement
checkPassword
in interface UserPasswordManagement
userId
- the ID of the user whose password should be checkedpassword
- the clear text password to test againstpublic boolean checkPassword(User user, String password)
UserPasswordManagement
checkPassword
in interface UserPasswordManagement
user
- the user whose password should be checkedpassword
- the clear text password to test againstpublic void register(PasswordHashFunction hashFunction)
UserPasswordManagement
register
in interface UserPasswordManagement
hashFunction
- the function to register@Transactional(propagation=REQUIRED) public void requestPasswordChange(String email) throws UserNotFoundException, ExternalUserPasswordChangeNotAllowedException
UserPasswordManagement
UserPasswordManagement.changePassword(String, String)
.requestPasswordChange
in interface UserPasswordManagement
email
- the email of the user requesting the password changeUserNotFoundException
- in case there is no user with that emailExternalUserPasswordChangeNotAllowedException
- in case the user was provided by the primary external user repositorypublic void unregister(PasswordHashFunction hashFunction)
UserPasswordManagement
unregister
in interface UserPasswordManagement
hashFunction
- the hash function to removepublic void validatePassword(String newPassword) throws PasswordValidationException
UserPasswordManagement
validatePassword
in interface UserPasswordManagement
newPassword
- the password to validatePasswordValidationException
- in case the password is not validCopyright © 2019 Communote team. All rights reserved.