Пример #1
0
  /**
   * Method to reset the password at the time of login.
   *
   * @param securityDetailsHolder - having emailId, secutiryDetails and password.
   * @return status - true/false
   */
  @Override
  public final boolean resetPassword(final SecurityDetailsHolder securityDetailsHolder) {

    boolean status = false;

    LOGGER.info("In resetPassword method");
    if (securityDetailsHolder.isForceReset()) {
      ForcefulReset forcefulReset = new ForcefulReset();
      forcefulReset.setExistingEmail(securityDetailsHolder.getEmailId());
      forcefulReset.setNewPassword(securityDetailsHolder.getPassword());
      forcefulReset.setSourceSystem(AuthorServicesConstants.SOURCESYSTEM);

      status = userManagement.forceFulReset(forcefulReset);
      if (status) {
        sendNotification.notifyByEmail(securityDetailsHolder.getEmailId(), passwordResetTemplateId);
      }

    } else {
      if (securityDetailsHolder.getSecurityDetails().isEmpty()) {
        throw new ASException(securityquestioncode, securityquestionmessage);
      } else {
        List<UserSecurityQuestionsEntry> userSecurityQuestionsEntriesList = null;
        PasswordResetRequest passwordResetRequest = new PasswordResetRequest();

        PasswordReset passwordReset = new PasswordReset();
        passwordReset.setExistingEmail(securityDetailsHolder.getEmailId());
        passwordReset.setNewPassword(securityDetailsHolder.getPassword());
        passwordReset.setSourceSystem(AuthorServicesConstants.SOURCESYSTEM);

        UserSecurityQuestions userSecurityQuestions = new UserSecurityQuestions();
        UserSecurityQuestionsMap userSecurityQuestionsMap = new UserSecurityQuestionsMap();
        userSecurityQuestionsEntriesList = new ArrayList<UserSecurityQuestionsEntry>();
        UserSecurityQuestionsEntry userSecurityQuestionsEntry = null;

        List<SecurityDetails> securityDetailsList = securityDetailsHolder.getSecurityDetails();
        for (SecurityDetails securityDetails : securityDetailsList) {

          userSecurityQuestionsEntry = new UserSecurityQuestionsEntry();
          userSecurityQuestionsEntry.setKey(securityDetails.getSecurityQuestion());
          userSecurityQuestionsEntry.setText(securityDetails.getSecurityAnswer());
          userSecurityQuestionsEntriesList.add(userSecurityQuestionsEntry);
        }
        userSecurityQuestionsMap.setEntry(userSecurityQuestionsEntriesList);
        userSecurityQuestions.setUserSecurityQuestionsMap(userSecurityQuestionsMap);

        passwordReset.setUserSQuestions(userSecurityQuestions);

        passwordResetRequest.setUpdateUserSecurityAttributes(passwordReset);
        status = userManagement.resetPassword(passwordResetRequest);
        if (status) {
          sendNotification.notifyByEmail(
              securityDetailsHolder.getEmailId(), passwordResetTemplateId);
        }
      }
    }
    return status;
  }
Пример #2
0
  /**
   * Validate security questions.
   *
   * @param securityDetailsHolder the security details holder
   * @return true, if successful
   */
  @Override
  public final boolean validateSecurityQuestions(
      final SecurityDetailsHolder securityDetailsHolder) {

    LOGGER.info("In validateSecurityQuestions method");
    SecurityQuestionsValidateRequest securityQuestionsValidateRequest =
        new SecurityQuestionsValidateRequest();
    ValidateUserSecurityQA validateUserSecurityQA = new ValidateUserSecurityQA();
    UserSecurityQuestions userSecurityQuestions = new UserSecurityQuestions();
    UserSecurityQuestionsMap userSecurityQuestionsMap = new UserSecurityQuestionsMap();
    List<UserSecurityQuestionsEntry> userSecurityQuestionsEntryList =
        new ArrayList<UserSecurityQuestionsEntry>();
    UserSecurityQuestionsEntry userSecurityQuestionsEntry = null;
    List<SecurityDetails> securityDetailsList = securityDetailsHolder.getSecurityDetails();
    for (SecurityDetails securityDetails : securityDetailsList) {

      userSecurityQuestionsEntry = new UserSecurityQuestionsEntry();
      userSecurityQuestionsEntry.setKey(securityDetails.getSecurityQuestion());
      userSecurityQuestionsEntry.setText(securityDetails.getSecurityAnswer());
      userSecurityQuestionsEntryList.add(userSecurityQuestionsEntry);
    }
    userSecurityQuestionsMap.setEntry(userSecurityQuestionsEntryList);
    userSecurityQuestions.setUserSecurityQuestionsMap(userSecurityQuestionsMap);
    final String emailId = securityDetailsHolder.getEmailId();
    validateUserSecurityQA.setLogin(emailId);
    validateUserSecurityQA.setUserSecurityQuestions(userSecurityQuestions);
    securityQuestionsValidateRequest.setValidateUserSecurityQA(validateUserSecurityQA);
    try {
      return userManagement.validateSecurityQuestions(securityQuestionsValidateRequest);
    } catch (UserException userException) {
      LOGGER.error(AuthorServicesConstants.PRINTSTACKTRACE, userException);
      // need to put correct templteId here
      sendNotification.notifyByEmail(emailId, templateId);
      throw new UserException(userException.getErrorCode(), userException.getDescription());
    }
  }