Search in sources :

Example 31 with AssignmentType

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

the class TestRetirement method createOrg.

private PrismObject<OrgType> createOrg(String name, String parentOrgOid) throws SchemaException {
    PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
    OrgType orgType = org.asObjectable();
    orgType.setName(new PolyStringType(name));
    orgType.getOrgType().add(ORG_TYPE_FUNCTIONAL);
    AssignmentType metaRoleAssignment = new AssignmentType();
    ObjectReferenceType metaRoleAssignmentTargetRef = new ObjectReferenceType();
    metaRoleAssignmentTargetRef.setOid(ROLE_META_ORG_OID);
    metaRoleAssignmentTargetRef.setType(RoleType.COMPLEX_TYPE);
    metaRoleAssignment.setTargetRef(metaRoleAssignmentTargetRef);
    orgType.getAssignment().add(metaRoleAssignment);
    if (parentOrgOid != null) {
        AssignmentType parentAssignment = new AssignmentType();
        ObjectReferenceType parentAssignmentTargetRef = new ObjectReferenceType();
        parentAssignmentTargetRef.setOid(parentOrgOid);
        parentAssignmentTargetRef.setType(OrgType.COMPLEX_TYPE);
        parentAssignment.setTargetRef(parentAssignmentTargetRef);
        orgType.getAssignment().add(parentAssignment);
    }
    return org;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 32 with AssignmentType

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

the class TestSecurityBasic method test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta.

/**
	 * MID-3136
	 */
@Test
public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws Exception {
    final String TEST_NAME = "test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    cleanupAutzTest(USER_JACK_OID);
    assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    login(USER_JACK_USERNAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assertReadAllow(NUMBER_OF_ALL_USERS + 1);
    assertAddDeny();
    assertModifyDeny();
    assertDeleteDeny();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertAssignments(user, 2);
    assertAssignedRole(user, ROLE_ASSIGN_REQUESTABLE_ROLES_OID);
    assertAllow("assign business role to jack", (task, result) -> assignPrametricRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, ORG_MINISTRY_OF_RUM_OID, null, task, result));
    user = getUser(USER_JACK_OID);
    assertAssignments(user, 3);
    assertAssignedRole(user, ROLE_BUSINESS_1_OID);
    assertDeny("assign application role to jack", (task, result) -> {
        Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
        ContainerDelta<AssignmentType> assignmentDelta1 = ContainerDelta.createDelta(UserType.F_ASSIGNMENT, getUserDefinition());
        PrismContainerValue<AssignmentType> cval = new PrismContainerValue<AssignmentType>(prismContext);
        assignmentDelta1.addValueToAdd(cval);
        PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF);
        targetRef.getValue().setOid(ROLE_BUSINESS_2_OID);
        targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE);
        targetRef.getValue().setRelation(null);
        cval.setId(123L);
        ContainerDelta<AssignmentType> assignmentDelta = assignmentDelta1;
        modifications.add(assignmentDelta);
        ObjectDelta<UserType> userDelta1 = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
        ObjectDelta<UserType> userDelta = userDelta1;
        Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
        modelService.executeChanges(deltas, null, task, result);
    });
    assertAllow("unassign business role from jack", (task, result) -> unassignPrametricRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, ORG_MINISTRY_OF_RUM_OID, null, task, result));
    user = getUser(USER_JACK_OID);
    display("user after (expected 2 assignments)", user);
    assertAssignments(user, 2);
    RoleSelectionSpecification spec = getAssignableRoleSpecification(getUser(USER_JACK_OID));
    assertRoleTypes(spec);
    assertFilter(spec.getFilter(), TypeFilter.class);
    assertGlobalStateUntouched();
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) PrismReference(com.evolveum.midpoint.prism.PrismReference) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 33 with AssignmentType

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

the class TestAssignmentErrors method setupUserAssignAccountDeletedShadowRecompute.

private PrismObject<UserType> setupUserAssignAccountDeletedShadowRecompute(final String TEST_NAME, String dummyResourceOid, String dummyResourceName, String userName, String userFullName) throws Exception {
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    getDummyResource().resetBreakMode();
    PrismObject<UserType> user = createUser(userName, userFullName);
    AssignmentType assignmentType = createConstructionAssignment(dummyResourceOid, ShadowKindType.ACCOUNT, null);
    user.asObjectable().getAssignment().add(assignmentType);
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    user.asObjectable().setActivation(activationType);
    addObject(user);
    // precondition
    assertDummyAccount(dummyResourceName, userName, userFullName, true);
    // Re-read user to get the links
    user = getUser(user.getOid());
    display("User before", user);
    String shadowOidBefore = getSingleLinkOid(user);
    // precondition
    PrismObject<ShadowType> shadowBefore = repositoryService.getObject(ShadowType.class, shadowOidBefore, null, result);
    display("Shadow before", shadowBefore);
    // delete just the shadow, not the account
    repositoryService.deleteObject(ShadowType.class, shadowOidBefore, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertNoRepoCache();
    dummyAuditService.clear();
    return user;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 34 with AssignmentType

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

the class AbstractModelIntegrationTest method getUserAssignment.

protected AssignmentType getUserAssignment(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PrismObject<UserType> user = getUser(userOid);
    List<AssignmentType> assignments = user.asObjectable().getAssignment();
    for (AssignmentType assignment : assignments) {
        ObjectReferenceType targetRef = assignment.getTargetRef();
        if (targetRef != null && roleOid.equals(targetRef.getOid())) {
            return assignment;
        }
    }
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 35 with AssignmentType

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

the class AbstractModelIntegrationTest method fillinUserAssignmentAccountConstruction.

protected void fillinUserAssignmentAccountConstruction(PrismObject<UserType> user, String resourceOid) {
    AssignmentType assignmentType = new AssignmentType();
    ConstructionType accountConstruntion = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    resourceRef.setType(ResourceType.COMPLEX_TYPE);
    accountConstruntion.setResourceRef(resourceRef);
    accountConstruntion.setKind(ShadowKindType.ACCOUNT);
    assignmentType.setConstruction(accountConstruntion);
    user.asObjectable().getAssignment().add(assignmentType);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)115 Test (org.testng.annotations.Test)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)53 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)44 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)23 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)16 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)16 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)16 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)15 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)14 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)14 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)13 ArrayList (java.util.ArrayList)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)12 ConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)12 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)10