case UserPasswordException.PASSWORD_LENGTH: {
try {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
PasswordPolicy passwordPolicy = company.getDefaultUser().getPasswordPolicy();
liferayFacesContext.addGlobalErrorMessage(
"that-password-is-too-short-or-too-long-please-make-sure-your-password-is-between-x-and-512-characters",
new Object[] { String.valueOf(passwordPolicy.getMinLength()) });
}
catch (Exception e1) {
logger.error(e.getMessage(), e);
liferayFacesContext.addGlobalUnexpectedErrorMessage();
}
break;
}
case UserPasswordException.PASSWORD_NOT_CHANGEABLE: {
liferayFacesContext.addGlobalErrorMessage("your-password-cannot-be-changed");
break;
}
case UserPasswordException.PASSWORD_SAME_AS_CURRENT: {
liferayFacesContext.addGlobalErrorMessage(
"your-new-password-cannot-be-the-same-as-your-old-password-please-enter-in-a-different-password");
break;
}
case UserPasswordException.PASSWORD_TOO_TRIVIAL: {
liferayFacesContext.addGlobalErrorMessage("that-password-is-too-trivial");
break;
}
case UserPasswordException.PASSWORD_TOO_YOUNG: {
try {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
PasswordPolicy passwordPolicy = company.getDefaultUser().getPasswordPolicy();
liferayFacesContext.addGlobalErrorMessage(
"you-cannot-change-your-password-yet-please-wait-at-least-x-before-changing-your-password-again",
new Object[] { String.valueOf(passwordPolicy.getMinAge() * 1000) });
}
catch (Exception e1) {
logger.error(e.getMessage(), e);
liferayFacesContext.addGlobalUnexpectedErrorMessage();