use of org.wso2.carbon.identity.recovery.endpoint.dto.QuestionDTO in project carbon-identity-framework by wso2.
the class ChallengeQuestionProcessor method getAllChallengeQuestions.
/**
* @return
* @throws IdentityException
*/
public List<ChallengeQuestionDTO> getAllChallengeQuestions() throws IdentityException {
List<ChallengeQuestionDTO> questionDTOs = new ArrayList<ChallengeQuestionDTO>();
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Registry registry = IdentityMgtServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);
if (registry.resourceExists(IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS)) {
Collection collection = (Collection) registry.get(IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS);
String[] children = collection.getChildren();
for (String child : children) {
Resource resource = registry.get(child);
String question = resource.getProperty("question");
String isPromoteQuestion = resource.getProperty("isPromoteQuestion");
String questionSetId = resource.getProperty("questionSetId");
if (question != null) {
ChallengeQuestionDTO questionDTO = new ChallengeQuestionDTO();
questionDTO.setQuestion(question);
if (isPromoteQuestion != null) {
questionDTO.setPromoteQuestion(Boolean.parseBoolean(isPromoteQuestion));
}
if (questionSetId != null) {
questionDTO.setQuestionSetId(questionSetId);
}
questionDTO.setPromoteQuestion(false);
questionDTOs.add(questionDTO);
}
}
}
} catch (RegistryException e) {
throw IdentityException.error(e.getMessage(), e);
}
return questionDTOs;
}
use of org.wso2.carbon.identity.recovery.endpoint.dto.QuestionDTO in project identity-governance by wso2-extensions.
the class RecoveryUtil method getInitiateQuestionResponseDTO.
public static InitiateAllQuestionResponseDTO getInitiateQuestionResponseDTO(ChallengeQuestionsResponse challengeQuestionsResponse) {
InitiateAllQuestionResponseDTO initiateAllQuestionResponseDTO = new InitiateAllQuestionResponseDTO();
List<QuestionDTO> questionDTOs = new ArrayList<>();
for (ChallengeQuestion challengeQuestion : challengeQuestionsResponse.getQuestion()) {
QuestionDTO questionDTO = new QuestionDTO();
questionDTO.setQuestion(challengeQuestion.getQuestion());
questionDTO.setQuestionSetId(challengeQuestion.getQuestionSetId());
questionDTOs.add(questionDTO);
}
initiateAllQuestionResponseDTO.setQuestions(questionDTOs);
initiateAllQuestionResponseDTO.setKey(challengeQuestionsResponse.getCode());
LinkDTO linkDTO = new LinkDTO();
linkDTO.setRel("validate-answer");
linkDTO.setUri("/api/identity/recovery/v0.9");
initiateAllQuestionResponseDTO.setLink(linkDTO);
return initiateAllQuestionResponseDTO;
}
use of org.wso2.carbon.identity.recovery.endpoint.dto.QuestionDTO in project identity-governance by wso2-extensions.
the class RecoveryUtil method getInitiateQuestionResponseDTO.
public static InitiateQuestionResponseDTO getInitiateQuestionResponseDTO(ChallengeQuestionResponse challengeQuestionResponse) {
InitiateQuestionResponseDTO initiateQuestionResponseDTO = new InitiateQuestionResponseDTO();
QuestionDTO questionDTO = new QuestionDTO();
if (challengeQuestionResponse.getQuestion() != null) {
questionDTO.setQuestion(challengeQuestionResponse.getQuestion().getQuestion());
questionDTO.setQuestionSetId(challengeQuestionResponse.getQuestion().getQuestionSetId());
initiateQuestionResponseDTO.setQuestion(questionDTO);
}
initiateQuestionResponseDTO.setKey(challengeQuestionResponse.getCode());
LinkDTO linkDTO = new LinkDTO();
if (IdentityRecoveryConstants.RECOVERY_STATUS_COMPLETE.equals(challengeQuestionResponse.getStatus())) {
linkDTO.setRel("set-password");
linkDTO.setUri("/api/identity/recovery/v0.9");
} else {
linkDTO.setRel("validate-answer");
linkDTO.setUri("/api/identity/recovery/v0.9");
}
initiateQuestionResponseDTO.setLink(linkDTO);
return initiateQuestionResponseDTO;
}
Aggregations