/** * Creates a new instance.<p> * * @param cms the CMS context * @param user the user * @param locale the locale */ public CmsSetPasswordDialog(final CmsObject cms, CmsUser user, Locale locale) { super(cms, user, locale); // hide the old password field, it's not required m_form.hideOldPassword(); }
/** * Displays some additional text.<p> * * @param text the text to display */ public void setAdditionalMessage(String text) { m_form.setAdditionalText(text); }
/** * Clears the wrong old password error.<p> */ void clearOldPasswordError() { m_form.setErrorOldPassword(null, null); }
String password1 = m_form.getPassword1(); String password2 = m_form.getPassword2(); String oldPassword = m_form.getOldPassword(); boolean error = false; m_form.setErrorPassword1( new UserError( Messages.get().getBundle(m_locale).key(Messages.GUI_PWCHANGE_DIFFERENT_PASSWORD_REQUIRED_0)), m_cms.setPassword(m_user.getName(), oldPassword, password1); } catch (CmsException e) { m_form.setErrorOldPassword( new UserError(e.getLocalizedMessage(m_locale)), OpenCmsTheme.SECURITY_INVALID);
m_form = new CmsPasswordForm(m_locale); setContent(m_form); if (OpenCms.getPasswordHandler() instanceof I_CmsPasswordSecurityEvaluator) { m_form.setSecurityHint( ((I_CmsPasswordSecurityEvaluator)OpenCms.getPasswordHandler()).getPasswordSecurityHint(m_locale)); m_form.getOldPasswordField().setImmediate(true); m_form.getPassword1Field().setImmediate(true); m_form.getPassword2Field().setImmediate(true); m_form.getOldPasswordField().addValueChangeListener(new ValueChangeListener() { m_form.getPassword1Field().addTextChangeListener(new TextChangeListener() { m_form.getPassword2Field().addTextChangeListener(new TextChangeListener() {
return; String password1 = m_form.getPassword1(); String password2 = m_form.getPassword2(); String error = null; if (validatePasswords(password1, password2)) { m_form.setErrorPassword1(new UserError(error), OpenCmsTheme.SECURITY_INVALID); } else { CmsVaadinUtils.showAlert(
/** * 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())); } }
/** * 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 whether the passwords match.<p> * * @param password2 the password 2 value */ void checkPasswordMatch(String password2) { if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(password2)) { showPasswordMatchError(!password2.equals(m_form.getPassword1())); } }