use of com.liferay.portal.model.PasswordPolicy in project liferay-ide by liferay.
the class UserLocalServiceImpl method checkPasswordExpired.
/**
* Checks if the user's password is expired based on the password policy,
* and performs maintenance on the user's grace login and password reset
* data.
*
* @param user the user
* @throws PortalException if the user's password has expired and the grace
* login limit has been exceeded
* @throws SystemException if a system exception occurred
*/
@Override
public void checkPasswordExpired(User user) throws PortalException, SystemException {
if (LDAPSettingsUtil.isPasswordPolicyEnabled(user.getCompanyId())) {
return;
}
PasswordPolicy passwordPolicy = user.getPasswordPolicy();
if (isPasswordExpired(user)) {
int graceLoginCount = user.getGraceLoginCount();
if (graceLoginCount < passwordPolicy.getGraceLimit()) {
user.setGraceLoginCount(++graceLoginCount);
userPersistence.update(user);
} else {
user.setDigest(StringPool.BLANK);
userPersistence.update(user);
throw new PasswordExpiredException();
}
}
if (passwordPolicy.isChangeable() && passwordPolicy.isChangeRequired()) {
if (user.getLastLoginDate() == null) {
user.setPasswordReset(true);
userPersistence.update(user);
}
}
}
use of com.liferay.portal.model.PasswordPolicy in project liferay-ide by liferay.
the class UserLocalServiceImpl method validatePassword.
protected void validatePassword(long companyId, long userId, String password1, String password2) throws PortalException, SystemException {
if (Validator.isNull(password1) || Validator.isNull(password2)) {
throw new UserPasswordException(UserPasswordException.PASSWORD_INVALID);
}
if (!password1.equals(password2)) {
throw new UserPasswordException(UserPasswordException.PASSWORDS_DO_NOT_MATCH);
}
PasswordPolicy passwordPolicy = passwordPolicyLocalService.getPasswordPolicyByUserId(userId);
PwdToolkitUtil.validate(companyId, userId, password1, password2, passwordPolicy);
}
Aggregations