use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.
the class Main method createUser.
private static String createUser(ModelPortType modelPort, UserType userType) throws FaultMessage {
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.ADD);
deltaType.setObjectToAdd(userType);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType operationListType = modelPort.executeChanges(deltaListType, null);
return ModelClientUtil.getOidFromDeltaOperationList(operationListType, deltaType);
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.
the class Main method deleteRole.
private static void deleteRole(ModelPortType modelPort, String oid) throws FaultMessage {
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
deltaType.setChangeType(ChangeTypeType.DELETE);
deltaType.setOid(oid);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ModelExecuteOptionsType executeOptionsType = new ModelExecuteOptionsType();
executeOptionsType.setRaw(true);
modelPort.executeChanges(deltaListType, executeOptionsType);
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.
the class Main method getUser.
private static UserType getUser(ModelPortType modelPort, String oid) throws FaultMessage {
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
modelPort.getObject(ModelClientUtil.getTypeQName(UserType.class), oid, options, objectHolder, resultHolder);
return (UserType) objectHolder.value;
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType in project midpoint by Evolveum.
the class Main method modifyRoleAssignment.
private static void modifyRoleAssignment(ModelPortType modelPort, String userOid, boolean isAdd, String... roleOids) throws FaultMessage {
ItemDeltaType assignmentDelta = new ItemDeltaType();
if (isAdd) {
assignmentDelta.setModificationType(ModificationTypeType.ADD);
} else {
assignmentDelta.setModificationType(ModificationTypeType.DELETE);
}
assignmentDelta.setPath(ModelClientUtil.createItemPathType("assignment"));
for (String roleOid : roleOids) {
assignmentDelta.getValue().add(ModelClientUtil.createRoleAssignment(roleOid));
}
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(userOid);
deltaType.getItemDelta().add(assignmentDelta);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(ModelClientUtil.createDeltaList(deltaType), null);
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
}
}
}
use of com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType 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);
}
}
Aggregations