Search in sources :

Example 56 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test002CorrelationMoreThanOne.

@Test
public void test002CorrelationMoreThanOne() throws Exception {
    String TEST_NAME = "test002CorrelationMoreThanOne";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    List<ConditionalSearchFilterType> filters = new ArrayList<>();
    ConditionalSearchFilterType filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_FIRST_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_SECOND_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, filters, resourceType, getSystemConfiguration(), task, result);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 57 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test006CorrelationFindCaseInsensitive.

@Test
public void test006CorrelationFindCaseInsensitive() throws Exception {
    String TEST_NAME = "test006CorrelationFindCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    List<ConditionalSearchFilterType> queries = new ArrayList<>();
    queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    //		resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    Collection<? extends ItemDelta> modifications = PropertyDelta.createModificationReplacePropertyCollection(UserType.F_NAME, userType.getDefinition(), new PolyString("JACK", "jack"));
    repositoryService.modifyObject(UserType.class, USER_JACK_OID, modifications, result);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, queries, resourceType, getSystemConfiguration(), task, result);
    System.out.println("matched users " + matchedUsers);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "JACK", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 58 with UserType

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

the class PageUserHistory method createMainPanel.

@Override
protected AbstractObjectMainPanel<UserType> createMainPanel(String id) {
    return new FocusMainPanel<UserType>(id, getObjectModel(), getAssignmentsModel(), getProjectionModel(), this) {

        @Override
        protected List<ITab> createTabs(final PageAdminObjectDetails<UserType> parentPage) {
            List<ITab> tabs = new ArrayList<>();
            FocusTabVisibleBehavior authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_BASIC_URL);
            tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.basic"), authorization) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return createFocusDetailsTabPanel(panelId, parentPage);
                }
            });
            //hidden, will be displayed in future version
            //                authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_PROJECTIONS_URL);
            //                tabs.add(
            //                        new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.projections"), authorization) {
            //
            //                            private static final long serialVersionUID = 1L;
            //
            //                            @Override
            //                            public WebMarkupContainer createPanel(String panelId) {
            //                                return createFocusProjectionsTabPanel(panelId, parentPage);
            //                            }
            //
            //                            @Override
            //                            public String getCount() {
            //                                return Integer.toString(getProjectionModel().getObject() == null ?
            //                                        0 : getProjectionModel().getObject().size());
            //                            }
            //                        });
            authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_ASSIGNMENTS_URL);
            tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.assignments"), authorization) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return createFocusAssignmentsTabPanel(panelId, parentPage);
                }

                @Override
                public String getCount() {
                    return Integer.toString(getAssignmentsModel().getObject() == null ? 0 : getAssignmentsModel().getObject().size());
                }
            });
            authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_DELEGATED_TO_ME_URL);
            tabs.add(new CountablePanelTab(parentPage.createStringResource("FocusType.delegatedToMe"), authorization) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new AssignmentTablePanel<UserType>(panelId, parentPage.createStringResource("FocusType.delegatedToMe"), getDelegatedToMeModel()) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
                            DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), true, new ArrayList<AssignmentsPreviewDto>(), PageUserHistory.this);
                            item.add(editor);
                        }

                        @Override
                        public String getExcludeOid() {
                            return getObject().getOid();
                        }

                        @Override
                        protected List<InlineMenuItem> createAssignmentMenu() {
                            return new ArrayList<>();
                        }
                    };
                }

                @Override
                public String getCount() {
                    return Integer.toString(getDelegatedToMeModel().getObject() == null ? 0 : getDelegatedToMeModel().getObject().size());
                }
            });
            return tabs;
        }

        @Override
        protected boolean getOptionsPanelVisibility() {
            return false;
        }
    };
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) DelegationEditorPanel(com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) ArrayList(java.util.ArrayList) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) PageAdminObjectDetails(com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) FocusMainPanel(com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel) FocusTabVisibleBehavior(com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior) ArrayList(java.util.ArrayList) List(java.util.List) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 59 with UserType

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

the class Expression method evaluate.

public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
    ExpressionVariables processedVariables = null;
    try {
        processedVariables = processInnerVariables(context.getVariables(), context.getContextDescription(), context.getTask(), context.getResult());
        ExpressionEvaluationContext contextWithProcessedVariables = context.shallowClone();
        contextWithProcessedVariables.setVariables(processedVariables);
        PrismValueDeltaSetTriple<V> outputTriple;
        ObjectReferenceType runAsRef = null;
        if (expressionType != null) {
            runAsRef = expressionType.getRunAsRef();
        }
        if (runAsRef == null) {
            outputTriple = evaluateExpressionEvaluators(contextWithProcessedVariables);
        } else {
            UserType userType = objectResolver.resolve(runAsRef, UserType.class, null, "runAs in " + context.getContextDescription(), context.getTask(), context.getResult());
            LOGGER.trace("Running {} as {} ({})", context.getContextDescription(), userType, runAsRef);
            try {
                outputTriple = securityEnforcer.runAs(() -> {
                    try {
                        return evaluateExpressionEvaluators(contextWithProcessedVariables);
                    } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException e) {
                        throw new TunnelException(e);
                    }
                }, userType.asPrismObject());
            } catch (TunnelException te) {
                Throwable e = te.getCause();
                if (e instanceof RuntimeException) {
                    throw (RuntimeException) e;
                }
                if (e instanceof Error) {
                    throw (Error) e;
                }
                if (e instanceof SchemaException) {
                    throw (SchemaException) e;
                }
                if (e instanceof ExpressionEvaluationException) {
                    throw (ExpressionEvaluationException) e;
                }
                if (e instanceof ObjectNotFoundException) {
                    throw (ObjectNotFoundException) e;
                }
                throw te;
            }
        }
        traceSuccess(context, processedVariables, outputTriple);
        return outputTriple;
    } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | RuntimeException | Error e) {
        traceFailure(context, processedVariables, e);
        throw e;
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 60 with UserType

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

the class AbstractAdLdapMultidomainTest method test260EnableGyubrush.

@Test
public void test260EnableGyubrush() throws Exception {
    final String TEST_NAME = "test260EnableGyubrush";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyUserReplace(USER_GUYBRUSH_OID, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), task, result, ActivationStatusType.ENABLED);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> user = getUser(USER_GUYBRUSH_OID);
    assertAdministrativeStatus(user, ActivationStatusType.ENABLED);
    Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME);
    assertAttribute(entry, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512");
    String shadowOid = getSingleLinkOid(user);
    PrismObject<ShadowType> shadow = getObject(ShadowType.class, shadowOid);
    assertAccountEnabled(shadow);
    assertLdapPassword(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, "wanna.be.a.123");
//        assertLdapConnectorInstances(2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

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