public RecoveryProcessor() { List<NotificationSendingModule> notificationSendingModules = IdentityMgtConfig.getInstance().getNotificationSendingModules(); this.defaultModule = notificationSendingModules.get(0); for (NotificationSendingModule module : notificationSendingModules) { this.modules.put(module.getNotificationType(), module); } this.dataStore = IdentityMgtConfig.getInstance().getRecoveryDataStore(); this.notificationSender = new NotificationSender(); questionProcessor = new ChallengeQuestionProcessor(); }
/** * Get all challenge questions * * @return array of questions * @throws IdentityMgtServiceException if fails */ public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException { ChallengeQuestionProcessor processor = IdentityMgtServiceComponent. getRecoveryProcessor().getQuestionProcessor(); List<ChallengeQuestionDTO> questionDTOs = null; try { questionDTOs = processor.getAllChallengeQuestions(); } catch (IdentityException e) { log.error("Error while loading user challenges", e); throw new IdentityMgtServiceException("Error while loading user challenges"); } return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]); }
/** * @param userName * @param tenantId * @return */ public int getNoOfChallengeQuestions(String userName, int tenantId) throws IdentityMgtServiceException { List<String> questions = getChallengeQuestionUris(userName, tenantId); return questions.size(); }
public boolean verifyUserChallengeAnswer(String userName, int tenantId, UserChallengesDTO challengesDTO) { boolean verification = false; try { if (log.isDebugEnabled()) { log.debug("Challenge Question from the user profile."); } UserChallengesDTO[] storedDto = getChallengeQuestionsOfUser(userName, tenantId, true); if (challengesDTO.getAnswer() == null || challengesDTO.getAnswer().trim().length() < 1) { return false; } for (UserChallengesDTO dto : storedDto) { if (dto.getId().equals(challengesDTO.getId())) { String hashedAnswer = Utils.doHash(challengesDTO.getAnswer().trim() .toLowerCase()); if (hashedAnswer.equals(dto.getAnswer())) { verification = true; } else { return false; } } } } catch (Exception e) { String msg = "No associated challenge question found for the user"; log.debug(msg, e); } return verification; }
List<ChallengeQuestionDTO> challengeQuestionDTOs = processor.getAllChallengeQuestions(); for (UserChallengesDTO userChallengesDTO : challengesDTOs){ boolean found = false ; processor.setChallengesOfUser(userName, tenantId, challengesDTOs); } catch (IdentityException e) { String errorMessage = "Error while persisting user challenges for user : " + userName;
/** * set all challenge questions * * @param challengeQuestionDTOs array of questions * @throws IdentityMgtServiceException if fails */ public void setChallengeQuestions(ChallengeQuestionDTO[] challengeQuestionDTOs) throws IdentityMgtServiceException { ChallengeQuestionProcessor processor = IdentityMgtServiceComponent. getRecoveryProcessor().getQuestionProcessor(); try { processor.setChallengeQuestions(challengeQuestionDTOs); } catch (IdentityException e) { log.error("Error while persisting user challenges", e); throw new IdentityMgtServiceException("Error while persisting user challenges"); } }
boolean verification = processor.verifyChallengeQuestion(userDTO.getUserId(), userDTO.getTenantId(), userChallengesDTOs);
idsDTO = processor.getQuestionProcessor().getUserChallengeQuestionIds(userDTO.getUserId(), userDTO.getTenantId()); idsDTO.setKey(bean.getKey()); if (log.isDebugEnabled()) {
userChallengesDTO = processor.getQuestionProcessor().getUserChallengeQuestion( userDTO.getUserId(), userDTO.getTenantId(), questionId); userChallengesDTO.setKey(bean.getKey());
userChallengesDTO.setAnswer(answer); boolean verification = processor.verifyUserChallengeAnswer(userDTO.getUserId(), userDTO.getTenantId(), userChallengesDTO);
public boolean verifyUserChallengeAnswer(String userName, int tenantId, UserChallengesDTO challengesDTO) { boolean verification = false; try { if (log.isDebugEnabled()) { log.debug("Challenge Question from the user profile."); } UserChallengesDTO[] storedDto = getChallengeQuestionsOfUser(userName, tenantId, true); if (challengesDTO.getAnswer() == null || challengesDTO.getAnswer().trim().length() < 1) { return false; } for (UserChallengesDTO dto : storedDto) { if (dto.getId().equals(challengesDTO.getId())) { String hashedAnswer = Utils.doHash(challengesDTO.getAnswer().trim() .toLowerCase()); if (hashedAnswer.equals(dto.getAnswer())) { verification = true; } else { return false; } } } } catch (Exception e) { String msg = "No associated challenge question found for the user"; log.debug(msg, e); } return verification; }
List<ChallengeQuestionDTO> challengeQuestionDTOs = processor.getAllChallengeQuestions(); for (UserChallengesDTO userChallengesDTO : challengesDTOs){ boolean found = false ; processor.setChallengesOfUser(userName, tenantId, challengesDTOs); } catch (IdentityException e) { String errorMessage = "Error while persisting user challenges for user : " + userName;
/** * set all challenge questions * * @param challengeQuestionDTOs array of questions * @throws IdentityMgtServiceException if fails */ public void setChallengeQuestions(ChallengeQuestionDTO[] challengeQuestionDTOs) throws IdentityMgtServiceException { ChallengeQuestionProcessor processor = IdentityMgtServiceComponent. getRecoveryProcessor().getQuestionProcessor(); try { processor.setChallengeQuestions(challengeQuestionDTOs); } catch (IdentityException e) { log.error("Error while persisting user challenges", e); throw new IdentityMgtServiceException("Error while persisting user challenges"); } }
boolean verification = processor.verifyChallengeQuestion(userDTO.getUserId(), userDTO.getTenantId(), userChallengesDTOs);
idsDTO = processor.getQuestionProcessor().getUserChallengeQuestionIds(userDTO.getUserId(), userDTO.getTenantId()); idsDTO.setKey(bean.getKey()); if (log.isDebugEnabled()) {
userChallengesDTO = processor.getQuestionProcessor().getUserChallengeQuestion( userDTO.getUserId(), userDTO.getTenantId(), questionId); userChallengesDTO.setKey(bean.getKey());
userChallengesDTO.setAnswer(answer); boolean verification = processor.verifyUserChallengeAnswer(userDTO.getUserId(), userDTO.getTenantId(), userChallengesDTO);
/** * @param userName * @param tenantId * @return */ public int getNoOfChallengeQuestions(String userName, int tenantId) throws IdentityMgtServiceException { List<String> questions = getChallengeQuestionUris(userName, tenantId); return questions.size(); }
UserChallengesDTO[] storedUserChallengeDTOs = getChallengeQuestionsOfUser(userName, tenantId, true);
/** * get all challenge questions * * @return array of questions * @throws IdentityMgtServiceException if fails */ public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException { ChallengeQuestionProcessor processor = IdentityMgtServiceComponent. getRecoveryProcessor().getQuestionProcessor(); List<ChallengeQuestionDTO> questionDTOs = null; try { questionDTOs = processor.getAllChallengeQuestions(); } catch (IdentityException e) { String errorMessage = "Error while loading user challenge questions"; log.error(errorMessage, e); throw new IdentityMgtServiceException(errorMessage); } return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]); }