Search in sources :

Example 1 with PasswordQuestionsDto

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Collection(java.util.Collection) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 2 with PasswordQuestionsDto

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 3 with PasswordQuestionsDto

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto) RestartResponseException(org.apache.wicket.RestartResponseException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException)

Example 4 with PasswordQuestionsDto

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);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) TextField(org.apache.wicket.markup.html.form.TextField) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 5 with PasswordQuestionsDto

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));
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) RestartResponseException(org.apache.wicket.RestartResponseException) Collection(java.util.Collection) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Aggregations

PasswordQuestionsDto (com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 Task (com.evolveum.midpoint.task.api.Task)5 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 Collection (java.util.Collection)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 GuiProfiledPrincipal (com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 SecurityQuestionAnswerDTO (com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO)1 ArrayList (java.util.ArrayList)1 Label (org.apache.wicket.markup.html.basic.Label)1 TextField (org.apache.wicket.markup.html.form.TextField)1 PropertyModel (org.apache.wicket.model.PropertyModel)1