Examples of PasswordReset


Examples of org.broadleafcommerce.common.security.util.PasswordReset

        Customer customer = customerService.readCustomerByUsername(entity.findProperty("username").getValue());
        if (StringUtils.isEmpty(customer.getEmailAddress())) {
            throw new ServiceException("Unable to update password because an email address is not available for this customer. An email address is required to send the customer the new system generated password.");
        }
       
        PasswordReset passwordReset = new PasswordReset();
        passwordReset.setUsername(entity.findProperty("username").getValue());
        passwordReset.setPasswordChangeRequired(false);
        passwordReset.setEmail(customer.getEmailAddress());
        passwordReset.setPasswordLength(22);
        passwordReset.setSendResetEmailReliableAsync(false);
       
        customer = customerService.resetPassword(passwordReset);
       
        return entity;
    }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  /* (non-Javadoc)
   * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(java.lang.Object)
   */
  @Override
  protected ModelAndView onSubmit(Object command) throws Exception {
    PasswordReset passwd = (PasswordReset) command;
    Map<String,String> model = new HashMap<String,String>();
    try{
      userService.requestPasswordReset(passwd.getEmailAddress());
      model.put("message", "msg.instructions-for-reset-sent");
      model.put("title", "label.forgot-password");
    } catch (Exception ce) {
      try {
        _log.error("Failed to send password request email.",ce);
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  @Override
  protected ModelAndView onSubmit(HttpServletRequest request,
      HttpServletResponse response, Object command, BindException errors)
      throws Exception {
    boolean success = false;
    PasswordReset passwd = (PasswordReset) command;
    if (StringUtil.isEmpty(passwd.getCipher())) {
      success = userService.confirmPasswordReset(passwd.getEmailAddress(), passwd.getToken())
      if (!success)
        errors.reject("error.unauthorized-password-reset-by-email-token", "Invalid email and confirmation code combination.");
    } else {
      success = userService.confirmPasswordResetByCipher(passwd);     
      if (!success)
        errors.reject("error.unauthorized-password-reset-by-cipher", "Invalid link or password request has expired. " +
            "You can retry using the form below or request for new password reset.");
    }
    if (success) {
      Map<String,Object> model = new HashMap<String,Object>();
      model.put(getCommandName(), passwd);
      request.getSession().setAttribute(SECURE_SESSION_KEY, SECURE_SESSION_CODE+passwd.getEmailAddress());
      // next page is to change password
      model.put("action", "change");
      return new ModelAndView(getSuccessView(),model);
    } else {
      return showForm(request, errors, getFormView());
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  /* (non-Javadoc)
   * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
   */
  public void validate(Object clazz, Errors e) {
    PasswordReset obj = (PasswordReset) clazz;
    if (StringUtil.isEmpty(obj.getCipher())) {
      ValidationUtils.rejectIfEmptyOrWhitespace(e, "emailAddress", "error.required", new Object[]{"Email Address"});
      ValidationUtils.rejectIfEmptyOrWhitespace(e, "token", "error.required", new Object[]{"Confirmation Code"});
    } else {
      ValidationUtils.rejectIfEmptyOrWhitespace(e, "cipher", "error.required", new Object[]{"Link Cipher Code"});     
    }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  /* (non-Javadoc)
   * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
   */
  public void validate(Object clazz, Errors e) {
    PasswordReset obj = (PasswordReset) clazz;
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "emailAddress", "error.required", new Object[]{"Email Address"});
    if (!StringUtil.isEmpty(obj.getEmailAddress()) && !coreUserDAO.isRegisteredByEmail(obj.getEmailAddress())) {
      e.rejectValue("emailAddress","msg.email-address-is-not-registered",
          "Sorry, but your email address is not registered.");
    }
  }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  /* (non-Javadoc)
   * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
   */
  public void validate(Object clazz, Errors e) {
    PasswordReset obj = (PasswordReset) clazz;
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "emailAddress", "error.required", new Object[]{"Email Address"});
    if (!StringUtil.isEmpty(obj.getEmailAddress()) && !coreUserDAO.isRegisteredByEmail(obj.getEmailAddress())) {
      e.rejectValue("emailAddress","msg.email-address-is-not-registered",
          "Sorry, but your email address is not registered.");
    }
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "password", "error.required", new Object[]{"Password"});
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "confirmPassword", "error.required", new Object[]{"Confirm Password"});
    if (!StringUtil.isEmpty(obj.getPassword()) && (obj.getPassword().length()<6)) {
      e.reject("err.your-password-should-be-at-least-6-characters-long","Your password should be at least 6 characters long.");
    }
    if (!StringUtil.isEmpty(obj.getPassword()) && !StringUtil.isEmpty(obj.getConfirmPassword()) &&
        !obj.getPassword().equals(obj.getConfirmPassword()) ) {       
      e.reject("err.your-password-confirmation-did-not-match-with-password",
          "Your password confirmation did not match with password.");
    }
  }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

 
  @Test
  public void testRequestPasswordReset() {
    String email = "admin@ideyatech.com";
    userService.requestPasswordReset(email);
    PasswordReset example = new PasswordReset();
    example.setEmailAddress(email);
    example.setStatus(PasswordReset.STATUS_ACTIVE);
    assertNotSame(0, passwordResetDAO.countByExample(example,true));
    try {
      userService.requestPasswordReset("garbage@bin.com");
      fail("No exception thrown on missing email address");
    } catch (RuntimeException re) { 
View Full Code Here

Examples of org.opentides.bean.PasswordReset

 
  @Test
  public void testConfirmPasswordResetByEmailToken() {
        String email = "admin@ideyatech.com";
        userService.requestPasswordReset(email);
    PasswordReset example = new PasswordReset();
    example.setEmailAddress(email);
    example.setStatus(PasswordReset.STATUS_ACTIVE);
    List<PasswordReset> actuals = passwordResetDAO.findByExample(example, true);
    PasswordReset actual = actuals.get(0);
    assertFalse(userService.confirmPasswordReset(email, "dummy"));
    assertTrue(userService.confirmPasswordReset(email, actual.getToken()));
  }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

  @Test
  public void testConfirmPasswordResetByCipher() {
    String email = "admin@ideyatech.com";
        userService.requestPasswordReset(email);
    PasswordReset example = new PasswordReset();
    example.setEmailAddress(email);
    example.setStatus(PasswordReset.STATUS_ACTIVE);
    List<PasswordReset> actuals = passwordResetDAO.findByExample(example, true);
    PasswordReset actual = actuals.get(0);
    PasswordReset dummy = new PasswordReset();
    dummy.setCipher("dummy");
    assertFalse(userService.confirmPasswordResetByCipher(dummy));
    assertTrue(userService.confirmPasswordResetByCipher(actual));
  }
View Full Code Here

Examples of org.opentides.bean.PasswordReset

    assertTrue(userService.confirmPasswordResetByCipher(actual));
  }
 
  public void testResetPasswordFail() {
    String email = "admin@ideyatech.com";
    PasswordReset dummy = new PasswordReset();
    dummy.setEmailAddress(email);
    dummy.setToken("dummy");
    assertFalse(userService.resetPassword(dummy));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.