use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class PageSecurityQuestions method loadPageModel.
private PasswordQuestionsDto loadPageModel() {
LOGGER.debug("Loading user.");
final String userOid = getPageParameters().get(SESSION_ATTRIBUTE_POID).toString();
PrismObject<UserType> user = runPrivileged(new Producer<PrismObject<UserType>>() {
@Override
public PrismObject<UserType> run() {
Task task = createAnonymousTask(OPERATION_LOAD_USER);
OperationResult subResult = task.getResult();
try {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
return getModelService().getObject(UserType.class, userOid, options, task, subResult);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LOGGER.error("Error getting user {}: {}", userOid, e.getMessage(), e);
// we do not want to provide any information to the attacker.
return null;
}
}
});
principalModel.setObject(user);
PasswordQuestionsDto dto = new PasswordQuestionsDto();
dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
return dto;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class UserMenuPanel method loadModel.
private PasswordQuestionsDto loadModel(PageBase parentPage) {
LOGGER.trace("Loading user for Security Question Page.");
PasswordQuestionsDto dto = new PasswordQuestionsDto();
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
if (parentPage == null) {
parentPage = ((PageBase) getPage());
}
try {
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
if (principal == null) {
result.recordNotApplicableIfUnknown();
return null;
}
String userOid = principal.getOid();
Task task = parentPage.createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
Collection options = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
PrismObject<UserType> user = parentPage.getModelService().getObject(UserType.class, userOid, options, task, subResult);
userModel.setObject(user);
jpegPhoto = user == null ? null : (user.asObjectable() == null ? null : user.asObjectable().getJpegPhoto());
dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
subResult.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Couldn't get user Questions, Probably not set yet", ex);
} finally {
result.recomputeStatus();
isUserModelLoaded = true;
}
return dto;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class PageMyPasswordQuestions method loadPageModel.
private PasswordQuestionsDto loadPageModel() {
LOGGER.debug("Loading user for Security Question Page.");
PasswordQuestionsDto dto = new PasswordQuestionsDto();
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
try {
String userOid = SecurityUtils.getPrincipalUser().getOid();
Task task = createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
PrismObject<UserType> user = getModelService().getObject(UserType.class, userOid, null, task, subResult);
dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
subResult.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Couldn't get user Questions, Probably not set yet", ex);
} finally {
result.recomputeStatus();
}
return dto;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class MyPasswordQuestionsPanel method initLayout.
public void initLayout() {
// final Label question = new Label (F_QUESTION, mod.getPwdQuestion());
final Label question = new Label(F_QUESTION, new PropertyModel<PasswordQuestionsDto>(mod, PasswordQuestionsDto.F_MY_QUESTIONS__QUESTIONITSELF));
question.setOutputMarkupId(true);
add(question);
final TextField<String> answer = new TextField<String>(F_ANSWER, new PropertyModel(mod, SecurityQuestionAnswerDTO.F_PASSWORD_QUESTION_ANSWER));
answer.setRequired(true);
answer.setOutputMarkupId(true);
add(answer);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto in project midpoint by Evolveum.
the class PageSecurityQuestions method loadUserAndSecurityQuestions.
private void loadUserAndSecurityQuestions(PageParameters parameters) {
String userOid = parameters.get(SESSION_ATTRIBUTE_POID).toString();
LOGGER.trace("Processing security questions for user {}", userOid);
PrismObject<UserType> user = runPrivileged((Producer<PrismObject<UserType>>) () -> {
Task task = createAnonymousTask(OPERATION_LOAD_USER);
OperationResult subResult = task.getResult();
try {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
return getModelService().getObject(UserType.class, userOid, options, task, subResult);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LOGGER.error("Error getting user {}: {}", userOid, e.getMessage(), e);
// we do not want to provide any information to the attacker.
return null;
}
});
this.user = user;
if (user == null) {
// TODO
throw new RestartResponseException(PageLogin.class);
}
questions = new PasswordQuestionsDto(userOid);
questions.setUserQuestionAnswers(createUsersSecurityQuestionsList(user));
}
Aggregations