use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class SecurityQuestionsPanel method loadPageModel.
private PasswordQuestionsDto loadPageModel() {
LOGGER.debug("Loading user for Security Question Page.");
GuiProfiledPrincipal principalUser = AuthUtil.getPrincipalUser();
PasswordQuestionsDto dto = new PasswordQuestionsDto(principalUser.getOid());
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
try {
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
PrismObject<UserType> user = getPageBase().getModelService().getObject(UserType.class, principalUser.getOid(), null, task, subResult);
dto.setUserQuestionAnswers(createUsersSecurityQuestionsList(user));
subResult.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Couldn't get user Questions, Probably not set yet", ex);
} finally {
result.recomputeStatus();
}
CredentialsPolicyType credPolicy = principalUser.getApplicableSecurityPolicy().getCredentials();
List<SecurityQuestionDefinitionType> questionsDef = new ArrayList<>();
// Security Policy set question numbers
if (credPolicy != null && credPolicy.getSecurityQuestions() != null) {
// Actual Policy Question List
questionsDef = getEnabledSecurityQuestions(credPolicy);
} else {
LOGGER.debug("Couldn't load credentials for security questions");
}
result = new OperationResult(OPERATION_LOAD_QUESTION_POLICY);
try {
/*User's Pre-Set Question List*/
List<SecurityQuestionAnswerDTO> userQuestionList = dto.getUserQuestionAnswers();
/* check if user's set number of
* questions matches the policy or not*/
// Case that policy have more than users's number of numbers
int questionSize = questionsDef.size();
if (userQuestionList == null) {
dto.getActualQuestionAnswers().addAll(executeAddingQuestions(questionSize, 0, questionsDef));
// TODO same questions check should be implemented
} else if (questionSize > userQuestionList.size()) {
dto.getActualQuestionAnswers().addAll(executePasswordQuestionsAndAnswers(userQuestionList, questionsDef, userQuestionList.size()));
// QUESTION NUMBER BIGGER THAN QUESTION LIST
// rest of the questions
int difference = questionSize - userQuestionList.size();
dto.getActualQuestionAnswers().addAll(executeAddingQuestions(difference, userQuestionList.size(), questionsDef));
} else if (questionSize <= userQuestionList.size()) {
// QUESTION NUMBER SMALLER THAN QUESTION LIST OR EQUALS TO QUESTION LIST
dto.getActualQuestionAnswers().addAll(executePasswordQuestionsAndAnswers(userQuestionList, questionsDef, 0));
}
} catch (Exception ex) {
result.recordFatalError(getString("PageMyPasswordQuestions.message.couldNotLoadSysConfig"), ex);
}
return dto;
}
Aggregations