use of com.liferay.portal.PasswordExpiredException 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);
}
}
}
Aggregations