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;
}
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();
}
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;
}
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;
}
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);
}
Aggregations