use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class SearchShadowOwnerTest method searchShadowOwnerIsRole.
@Test
public void searchShadowOwnerIsRole() throws Exception {
OperationResult result = new OperationResult("List owner");
//look for account owner
PrismObject<RoleType> role = repositoryService.searchShadowOwner("11223355", null, result);
assertNotNull("No owner for account", role);
PrismProperty name = role.findProperty(ObjectType.F_NAME);
AssertJUnit.assertNotNull(name);
String orig = ((PolyString) name.getRealValue()).getOrig();
// there are two object which own tested shadow
if ("Judge".equals(orig) || "lazyman vm".equals(orig)) {
return;
}
AssertJUnit.fail("Unexpected object name for shadow owner '" + orig + "'");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class Main method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
ModelPortType modelPort = createModelPort(args);
SystemConfigurationType configurationType = getConfiguration(modelPort);
System.out.println("Got system configuration");
// System.out.println(configurationType);
UserType userAdministrator = searchUserByName(modelPort, "administrator");
System.out.println("Got administrator user: " + userAdministrator.getOid());
// System.out.println(userAdministrator);
RoleType sailorRole = searchRoleByName(modelPort, "Sailor");
System.out.println("Got Sailor role");
// System.out.println(sailorRole);
Collection<ResourceType> resources = listResources(modelPort);
System.out.println("Resources (" + resources.size() + ")");
// dump(resources);
Collection<UserType> users = listUsers(modelPort);
System.out.println("Users (" + users.size() + ")");
// dump(users);
Collection<TaskType> tasks = listTasks(modelPort);
System.out.println("Tasks (" + tasks.size() + ")");
// dump(tasks);
// System.out.println("Next scheduled times: ");
// for (TaskType taskType : tasks) {
// System.out.println(" - " + getOrig(taskType.getName()) + ": " + taskType.getNextRunStartTimestamp());
// }
String userGuybrushoid = createUserGuybrush(modelPort, sailorRole);
System.out.println("Created user guybrush, OID: " + userGuybrushoid);
UserType userGuybrush = getUser(modelPort, userGuybrushoid);
System.out.println("Fetched user guybrush:");
// System.out.println(userGuybrush);
System.out.println("Users fullName: " + ModelClientUtil.getOrig(userGuybrush.getFullName()));
String userLeChuckOid = createUserFromSystemResource(modelPort, "user-lechuck.xml");
System.out.println("Created user lechuck, OID: " + userLeChuckOid);
changeUserPassword(modelPort, userGuybrushoid, "MIGHTYpirate");
System.out.println("Changed user password");
changeUserGivenName(modelPort, userLeChuckOid, "CHUCK");
System.out.println("Changed user given name");
assignRoles(modelPort, userGuybrushoid, ROLE_PIRATE_OID, ROLE_CAPTAIN_OID);
System.out.println("Assigned roles");
unAssignRoles(modelPort, userGuybrushoid, ROLE_CAPTAIN_OID);
System.out.println("Unassigned roles");
Collection<RoleType> roles = listRequestableRoles(modelPort);
System.out.println("Found " + roles.size() + " requestable roles");
// System.out.println(roles);
String seaSuperuserRole = createRoleFromSystemResource(modelPort, "role-sea-superuser.xml");
System.out.println("Created role Sea Superuser, OID: " + seaSuperuserRole);
assignRoles(modelPort, userLeChuckOid, seaSuperuserRole);
System.out.println("Assigned role Sea Superuser to LeChuck");
modifyRoleModifyInducement(modelPort, seaSuperuserRole);
System.out.println("Modified role Sea Superuser - modified resource inducement");
modifyRoleReplaceInducement(modelPort, seaSuperuserRole, 2, ROLE_CAPTAIN_OID);
System.out.println("Modified role Sea Superuser - changed role inducement");
reconcileUser(modelPort, userLeChuckOid);
System.out.println("LeChuck reconciled.");
// Uncomment the following lines if you want to see what midPoint really did
// ... because deleting the user will delete also all the traces (except logs and audit of course).
deleteUser(modelPort, userGuybrushoid);
deleteUser(modelPort, userLeChuckOid);
deleteRole(modelPort, seaSuperuserRole);
System.out.println("Deleted user(s)");
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractLdapSynchronizationTest method test830AddGroupFools.
/**
* Add a new group. Check that this event is ignored.
*/
@Test
public void test830AddGroupFools() throws Exception {
final String TEST_NAME = "test830AddGroupFools";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
long tsStart = System.currentTimeMillis();
// WHEN
TestUtil.displayWhen(TEST_NAME);
addLdapGroup(GROUP_FOOLS_CN, GROUP_FOOLS_DESCRIPTION, toGroupDn("nobody"));
waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
long tsEnd = System.currentTimeMillis();
PrismObject<RoleType> roleFools = findObjectByName(RoleType.class, GROUP_FOOLS_CN);
assertNull("Unexpected role " + roleFools, roleFools);
assertStepSyncToken(getSyncTaskOid(), 8, tsStart, tsEnd);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test30DeleteAssignment.
@Test
public void test30DeleteAssignment() throws Exception {
//given
//when
// ObjectModificationType modification = prismContext.getPrismJaxbProcessor().unmarshalObject(
// new File(TEST_DIR, "modify-delete-assignment.xml"), ObjectModificationType.class);
//
// ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
AssignmentType a = new AssignmentType();
a.setId(4L);
ObjectDelta<RoleType> delta = ObjectDelta.createModificationDeleteContainer(RoleType.class, "00000000-8888-6666-0000-100000000005", RoleType.F_ASSIGNMENT, prismContext, a);
OperationResult result = new OperationResult("delete assignment");
repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
//then
AssertJUnit.assertTrue(result.isSuccess());
result = new OperationResult("get role");
PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
AssertJUnit.assertTrue(result.isSuccess());
PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
AssertJUnit.assertNotNull(inducement);
AssertJUnit.assertEquals(3, inducement.getValues().size());
PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
AssertJUnit.assertNotNull(assignment);
AssertJUnit.assertEquals(1, assignment.getValues().size());
AssertJUnit.assertNotNull(assignment.getValue(1L));
Session session = open();
try {
Query query = session.createSQLQuery("select count(*) from m_assignment where owner_oid=:oid and id=:id");
query.setParameter("oid", delta.getOid());
query.setParameter("id", 4);
Number number = (Number) query.uniqueResult();
AssertJUnit.assertEquals(0, number.intValue());
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method listRequestableRoles.
protected Collection<RoleType> listRequestableRoles() throws SAXException, IOException, FaultMessage, JAXBException {
SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:requestable</path>" + "<value>true</value>" + "</equal>");
QueryType query = new QueryType();
query.setFilter(filter);
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
return (Collection) objectList.getObject();
}
Aggregations