Search in sources :

Example 26 with ModelPortType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 27 with ModelPortType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 28 with ModelPortType

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;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 29 with ModelPortType

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());
        }
    }
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 30 with ModelPortType

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);
    }
}
Also used : ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Aggregations

ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)14 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)10 Holder (javax.xml.ws.Holder)10 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)8 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)7 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)7 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)7 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)6 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)6 BindingProvider (javax.xml.ws.BindingProvider)6 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)5 JAXBException (javax.xml.bind.JAXBException)5 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)4