/** * This method checks if a new password follows the rules for * new passwords, which are defined by a Class implementing the * <code>{@link org.opencms.security.I_CmsPasswordHandler}</code> * interface and configured in the opencms.properties file.<p> * * If this method throws no exception the password is valid.<p> * * @param password the new password that has to be checked * * @throws CmsSecurityException if the password is not valid */ public void validatePassword(String password) throws CmsSecurityException { OpenCms.getPasswordHandler().validatePassword(password); }
/** * This method checks if a new password follows the rules for * new passwords, which are defined by a Class implementing the * <code>{@link org.opencms.security.I_CmsPasswordHandler}</code> * interface and configured in the opencms.properties file.<p> * * If this method throws no exception the password is valid.<p> * * @param password the new password that has to be checked * * @throws CmsSecurityException if the password is not valid */ public void validatePassword(String password) throws CmsSecurityException { OpenCms.getPasswordHandler().validatePassword(password); }
/** * Sets the password of this user.<p> * * @param value the password to set */ public void setPassword(String value) { try { OpenCms.getPasswordHandler().validatePassword(value); } catch (CmsSecurityException e) { throw new CmsIllegalArgumentException(e.getMessageContainer()); } m_password = value; }
/** * Sets the password of this user.<p> * * @param value the password to set */ public void setPassword(String value) { try { OpenCms.getPasswordHandler().validatePassword(value); } catch (CmsSecurityException e) { throw new CmsIllegalArgumentException(e.getMessageContainer()); } m_password = value; }
/** * Sets the new password.<p> * * @param newPwd the new password to set */ public void setNewPwd(String newPwd) { // leave password unchanged, if the new password is empty if (CmsStringUtil.isEmpty(newPwd)) { return; } try { OpenCms.getPasswordHandler().validatePassword(newPwd); } catch (CmsSecurityException e) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_NEWPWD_0), e); } m_newPwd = newPwd; }
/** * Sets the new password.<p> * * @param newPwd the new password to set */ public void setNewPwd(String newPwd) { // leave password unchanged, if the new password is empty if (CmsStringUtil.isEmpty(newPwd)) { return; } try { OpenCms.getPasswordHandler().validatePassword(newPwd); } catch (CmsSecurityException e) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_NEWPWD_0), e); } m_newPwd = newPwd; }
/** * Validates the passwords, checking if they match and fulfill the requirements of the password handler.<p> * Will show the appropriate errors if necessary.<p> * * @param password1 password 1 * @param password2 password 2 * * @return <code>true</code> if valid */ boolean validatePasswords(String password1, String password2) { if (!password1.equals(password2)) { showPasswordMatchError(true); return false; } showPasswordMatchError(false); try { OpenCms.getPasswordHandler().validatePassword(password1); m_form.getPassword1Field().setComponentError(null); return true; } catch (CmsException e) { m_form.setErrorPassword1(new UserError(e.getLocalizedMessage(m_locale)), OpenCmsTheme.SECURITY_INVALID); return false; } } }
/** * Checks the security level of the given password.<p> * * @param password the password */ void checkSecurity(String password) { I_CmsPasswordHandler handler = OpenCms.getPasswordHandler(); try { handler.validatePassword(password); if (handler instanceof I_CmsPasswordSecurityEvaluator) { SecurityLevel level = ((I_CmsPasswordSecurityEvaluator)handler).evaluatePasswordSecurity(password); m_form.setErrorPassword1(null, OpenCmsTheme.SECURITY + "-" + level.name()); } else { m_form.setErrorPassword1(null, OpenCmsTheme.SECURITY_STRONG); } } catch (CmsSecurityException e) { m_form.setErrorPassword1(new UserError(e.getLocalizedMessage(m_locale)), OpenCmsTheme.SECURITY_INVALID); } if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_form.getPassword2())) { showPasswordMatchError(!password.equals(m_form.getPassword2())); } }