Пример #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
  /**
   * Security questions.
   *
   * @param emailId the email id
   * @return the security details holder
   */
  @Override
  public final SecurityQuestionsList userSecurityQuestions(final String emailId) {

    LOGGER.info("In securityQuestions method");
    SecurityQuestionsList securityQuestionsList = new SecurityQuestionsList();
    List<SecurityDetails> securityDetailsList = new ArrayList<SecurityDetails>();
    List<String> retrieveSecurityQuestionsList = new ArrayList<String>();
    SecurityDetails securityDetails = null;
    int i = 0;
    RetrieveSecurityQuestions retrieveSecurityQuestions =
        userManagement.userSecurityQuestions(emailId);
    SystemSecurityQuestions systemSecurityQuestions =
        retrieveSecurityQuestions.getSystemSecurityQuestions();
    if (null == systemSecurityQuestions) {
      throw new UserException(noSecutirySetupCode, noSecutirySetupMsg);
    }
    retrieveSecurityQuestionsList =
        retrieveSecurityQuestions.getSystemSecurityQuestions().getSecurityQuestionList();

    for (String list : retrieveSecurityQuestionsList) {

      securityDetails = new SecurityDetails();
      securityDetails.setSecurityQuestionId("SecurityQuestion" + (++i));
      securityDetails.setSecurityQuestion(list);
      securityDetailsList.add(securityDetails);
    }
    securityQuestionsList.setSecurityDetails(securityDetailsList);

    return securityQuestionsList;
  }
Пример #3
0
  /**
   * Method to authenticate user. calling external system to authenticate user.
   *
   * @param login the login
   * @param sharedServieRequest - having user information .
   * @return status - true/false
   */
  @Override
  public final SecurityResponse login(
      final Login login, final SharedServieRequest sharedServieRequest) {

    LOGGER.info("In login method");
    return userManagement.authenticateUser(sharedServieRequest);
  }
Пример #4
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());
    }
  }