Search in sources :

Example 1 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class PageResetPassword method finishChangePassword.

@Override
protected void finishChangePassword(final OperationResult result, AjaxRequestTarget target) {
    if (result.getStatus() == OperationResultStatus.SUCCESS) {
        result.setMessage(getString("PageResetPassword.reset.successful"));
        setResponsePage(PageLogin.class);
        PrismObject<UserType> user = getUser();
        if (user == null) {
            SecurityContextHolder.getContext().setAuthentication(null);
            return;
        }
        UserType userType = user.asObjectable();
        if (userType.getCredentials() != null && userType.getCredentials().getNonce() != null) {
            try {
                ObjectDelta<UserType> deleteNonceDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, userType.getOid(), SchemaConstants.PATH_NONCE, getPrismContext(), userType.getCredentials().getNonce().clone());
                WebModelServiceUtils.save(deleteNonceDelta, result, this);
            } catch (SchemaException e) {
            //nothing to do, just let the nonce here.. it will be invalid 
            }
        }
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    showResult(result);
    target.add(getFeedbackPanel());
//		get(ID_MAIN_FORM).setVisible(false);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 2 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType 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 3 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class WorkItemPanel method initLayout.

protected void initLayout(Form mainForm, PageBase pageBase) {
    WebMarkupContainer additionalInfoColumn = new WebMarkupContainer(ID_ADDITIONAL_INFO_COLUMN);
    WebMarkupContainer historyContainer = new WebMarkupContainer(ID_HISTORY_CONTAINER);
    historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT), UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL, (int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL)));
    final VisibleEnableBehaviour historyContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().hasHistory();
        }
    };
    historyContainer.add(historyContainerVisible);
    historyContainer.add(WebComponentUtil.createHelp(ID_HISTORY_HELP));
    additionalInfoColumn.add(historyContainer);
    WebMarkupContainer relatedWorkItemsContainer = new WebMarkupContainer(ID_RELATED_WORK_ITEMS_CONTAINER);
    final IModel<List<WorkItemDto>> relatedWorkItemsModel = new PropertyModel<>(getModel(), WorkItemDto.F_OTHER_WORK_ITEMS);
    final ISortableDataProvider<WorkItemDto, String> relatedWorkItemsProvider = new ListDataProvider<>(this, relatedWorkItemsModel);
    relatedWorkItemsContainer.add(new WorkItemsPanel(ID_RELATED_WORK_ITEMS, relatedWorkItemsProvider, null, 10, WorkItemsPanel.View.ITEMS_FOR_PROCESS));
    final VisibleEnableBehaviour relatedWorkItemsContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !relatedWorkItemsModel.getObject().isEmpty();
        }
    };
    relatedWorkItemsContainer.add(relatedWorkItemsContainerVisible);
    relatedWorkItemsContainer.add(WebComponentUtil.createHelp(ID_RELATED_WORK_ITEMS_HELP));
    additionalInfoColumn.add(relatedWorkItemsContainer);
    final WebMarkupContainer relatedWorkflowRequestsContainer = new WebMarkupContainer(ID_RELATED_REQUESTS_CONTAINER);
    final IModel<List<ProcessInstanceDto>> relatedWorkflowRequestsModel = new PropertyModel<>(getModel(), WorkItemDto.F_RELATED_WORKFLOW_REQUESTS);
    final ISortableDataProvider<ProcessInstanceDto, String> relatedWorkflowRequestsProvider = new ListDataProvider<>(this, relatedWorkflowRequestsModel);
    relatedWorkflowRequestsContainer.add(new ProcessInstancesPanel(ID_RELATED_REQUESTS, relatedWorkflowRequestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, new PropertyModel<>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
    final VisibleEnableBehaviour relatedWorkflowRequestsContainerVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !relatedWorkflowRequestsModel.getObject().isEmpty();
        }
    };
    relatedWorkflowRequestsContainer.add(relatedWorkflowRequestsContainerVisible);
    relatedWorkflowRequestsContainer.add(WebComponentUtil.createHelp(ID_RELATED_REQUESTS_HELP));
    additionalInfoColumn.add(relatedWorkflowRequestsContainer);
    final VisibleEnableBehaviour additionalInfoColumnVisible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return historyContainerVisible.isVisible() || relatedWorkItemsContainerVisible.isVisible() || relatedWorkflowRequestsContainerVisible.isVisible();
        }
    };
    additionalInfoColumn.add(additionalInfoColumnVisible);
    add(additionalInfoColumn);
    WebMarkupContainer primaryInfoColumn = new WebMarkupContainer(ID_PRIMARY_INFO_COLUMN);
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_BY, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_NAME)));
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_BY_FULL_NAME, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_FULL_NAME)));
    //		primaryInfoColumn.add(new Label(ID_REQUESTED_ON, new PropertyModel(getModel(), WorkItemDto.F_STARTED_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_WORK_ITEM_CREATED_ON, new PropertyModel(getModel(), WorkItemDto.F_CREATED_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_WORK_ITEM_DEADLINE, new PropertyModel(getModel(), WorkItemDto.F_DEADLINE_FORMATTED_FULL)));
    primaryInfoColumn.add(new Label(ID_ORIGINALLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_ORIGINAL_ASSIGNEE_FULL)));
    primaryInfoColumn.add(new Label(ID_CURRENTLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_CURRENT_ASSIGNEES_FULL)));
    primaryInfoColumn.add(new Label(ID_CANDIDATES, new PropertyModel(getModel(), WorkItemDto.F_CANDIDATES)));
    WebMarkupContainer stageInfoContainer = new WebMarkupContainer(ID_STAGE_INFO_CONTAINER);
    primaryInfoColumn.add(stageInfoContainer);
    stageInfoContainer.add(new Label(ID_STAGE_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_STAGE_INFO)));
    stageInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getStageInfo() != null));
    WebMarkupContainer escalationLevelInfoContainer = new WebMarkupContainer(ID_ESCALATION_LEVEL_INFO_CONTAINER);
    primaryInfoColumn.add(escalationLevelInfoContainer);
    escalationLevelInfoContainer.add(new Label(ID_ESCALATION_LEVEL_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_ESCALATION_LEVEL_INFO)));
    escalationLevelInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getEscalationLevelInfo() != null));
    WebMarkupContainer requesterCommentContainer = new WebMarkupContainer(ID_REQUESTER_COMMENT_CONTAINER);
    requesterCommentContainer.setOutputMarkupId(true);
    primaryInfoColumn.add(requesterCommentContainer);
    requesterCommentContainer.add(new Label(ID_REQUESTER_COMMENT_MESSAGE, new PropertyModel<String>(getModel(), WorkItemDto.F_REQUESTER_COMMENT)));
    //primaryInfoColumn.add(new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<SceneDto>(getModel(), WorkItemDto.F_DELTAS)));
    primaryInfoColumn.add(new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<>(getModel(), WorkItemDto.F_CHANGES)));
    primaryInfoColumn.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return additionalInfoColumnVisible.isVisible() ? "col-md-5" : "col-md-12";
        }
    }));
    add(primaryInfoColumn);
    add(new AjaxFallbackLink(ID_SHOW_REQUEST) {

        public void onClick(AjaxRequestTarget target) {
            String oid = WorkItemPanel.this.getModelObject().getTaskOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageTaskEdit.class, parameters);
            }
        }
    });
    add(WebComponentUtil.createHelp(ID_SHOW_REQUEST_HELP));
    WebMarkupContainer additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION, new PropertyModel<>(getModel(), WorkItemDto.F_ADDITIONAL_INFORMATION));
    add(additionalInformation);
    WorkItemDto dto = getModelObject();
    ApprovalStageDefinitionType level = WfContextUtil.getCurrentStageDefinition(dto.getWorkflowContext());
    WebMarkupContainer additionalAttribues = new WebMarkupContainer(ID_ADDITIONAL_ATTRIBUTES);
    add(additionalAttribues);
    additionalAttribues.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            return (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null);
        }

        ;
    });
    if (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null) {
        String formOid = level.getFormRef().getOid();
        ObjectType focus = dto.getFocus(pageBase);
        if (focus == null) {
            // TODO FIXME (this should not occur anyway)
            focus = new UserType(pageBase.getPrismContext());
        }
        Task task = pageBase.createSimpleTask(OPERATION_LOAD_CUSTOM_FORM);
        DynamicFormPanel<?> customForm = new DynamicFormPanel<>(ID_CUSTOM_FORM, focus.asPrismObject(), formOid, mainForm, task, pageBase);
        additionalAttribues.add(customForm);
    } else {
        additionalAttribues.add(new Label(ID_CUSTOM_FORM));
    }
    add(new TextArea<>(ID_APPROVER_COMMENT, new PropertyModel<String>(getModel(), WorkItemDto.F_APPROVER_COMMENT)));
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TaskChangesPanel(com.evolveum.midpoint.web.page.admin.server.TaskChangesPanel) ItemApprovalHistoryPanel(com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ApprovalStageDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalStageDefinitionType) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PageTaskEdit(com.evolveum.midpoint.web.page.admin.server.PageTaskEdit) PropertyModel(org.apache.wicket.model.PropertyModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AttributeModifier(org.apache.wicket.AttributeModifier) WorkItemsPanel(com.evolveum.midpoint.web.component.wf.WorkItemsPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 4 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class WorkItemSummaryPanel method getTitleModel.

@Override
protected IModel<String> getTitleModel() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            UserType requester = dtoModel.getObject().getRequester();
            String displayName = WebComponentUtil.getDisplayName(requester.asPrismObject());
            String name = WebComponentUtil.getName(requester.asPrismObject());
            if (displayName != null) {
                return getString("TaskSummaryPanel.requestedByWithFullName", displayName, name);
            } else {
                return getString("TaskSummaryPanel.requestedBy", name);
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 5 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class PageRegistrationConfirmation method assignAdditionalRoleIfPresent.

private OperationResult assignAdditionalRoleIfPresent(String userOid, NonceType nonceType, OperationResult result) {
    //		SecurityContextHolder.getContext().setAuthentication(token);
    return runPrivileged(() -> {
        List<ItemDelta> userDeltas = new ArrayList<>();
        if (nonceType.getName() != null) {
            Task task = createAnonymousTask(OPERATION_FINISH_REGISTRATION);
            ObjectDelta<UserType> assignRoleDelta = null;
            try {
                AssignmentType assignment = new AssignmentType();
                assignment.setTargetRef(ObjectTypeUtil.createObjectRef(nonceType.getName(), ObjectTypes.ABSTRACT_ROLE));
                getPrismContext().adopt(assignment);
                userDeltas.add((ItemDelta) ContainerDelta.createModificationAdd(UserType.F_ASSIGNMENT, UserType.class, getPrismContext(), assignment));
                assignRoleDelta = ObjectDelta.createModifyDelta(userOid, userDeltas, UserType.class, getPrismContext());
                assignRoleDelta.setPrismContext(getPrismContext());
            } catch (SchemaException e) {
                result.recordFatalError("Could not create delta");
                return result;
            }
            WebModelServiceUtils.save(assignRoleDelta, result, task, PageRegistrationConfirmation.this);
            result.computeStatusIfUnknown();
        }
        return result;
    });
//		SecurityContextHolder.getContext().setAuthentication(null);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)903 Test (org.testng.annotations.Test)767 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)741 Task (com.evolveum.midpoint.task.api.Task)576 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)217 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)192 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)104 PrismObject (com.evolveum.midpoint.prism.PrismObject)100 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)99 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)88 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)85 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)83 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)77 ArrayList (java.util.ArrayList)74 QName (javax.xml.namespace.QName)74 File (java.io.File)72 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)58 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)55 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)55