use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestWSSecurity method test130AddRolesAndUsersAsAdministrator.
@Test
public void test130AddRolesAndUsersAsAdministrator() throws Exception {
final String TEST_NAME = "test130AddRolesAndUsersAsAdministrator";
displayTestTitle(TEST_NAME);
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_DIGEST);
RoleType role = ModelClientUtil.unmarshallFile(ROLE_WS_FILE);
addObject(role);
role = ModelClientUtil.unmarshallFile(ROLE_READER_FILE);
addObject(role);
role = ModelClientUtil.unmarshallFile(ROLE_ADDER_FILE);
addObject(role);
UserType user = ModelClientUtil.unmarshallFile(USER_CYCLOPS_FILE);
String userCyclopsOid = addObject(user);
user = ModelClientUtil.unmarshallFile(USER_SOMEBODY_FILE);
addObject(user);
user = ModelClientUtil.unmarshallFile(USER_DARTHADDER_FILE);
addObject(user);
user = ModelClientUtil.unmarshallFile(USER_NOPASSWORD_FILE);
addObject(user);
// GET user
UserType userAfter = getObject(UserType.class, userCyclopsOid);
assertUser(userAfter, userCyclopsOid, USER_CYCLOPS_USERNAME);
assertObjectCount(UserType.class, 6);
assertObjectCount(RoleType.class, 5);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method searchRoleByName.
protected RoleType searchRoleByName(String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
// WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
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:name</path>" + "<value>" + roleName + "</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;
List<ObjectType> objects = objectList.getObject();
if (objects.isEmpty()) {
return null;
}
if (objects.size() == 1) {
return (RoleType) objects.get(0);
}
throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class Main method listRequestableRoles.
private static Collection<RoleType> listRequestableRoles(ModelPortType modelPort) 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();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class Main method createRole.
private static String createRole(ModelPortType modelPort, RoleType roleType) throws FaultMessage {
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
deltaType.setChangeType(ChangeTypeType.ADD);
deltaType.setObjectToAdd(roleType);
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.common.common_3.RoleType in project midpoint by Evolveum.
the class Main method createUserGuybrush.
private static String createUserGuybrush(ModelPortType modelPort, RoleType role) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
UserType user = new UserType();
user.setName(ModelClientUtil.createPolyStringType("guybrush", doc));
user.setFullName(ModelClientUtil.createPolyStringType("Guybrush Threepwood", doc));
user.setGivenName(ModelClientUtil.createPolyStringType("Guybrush", doc));
user.setFamilyName(ModelClientUtil.createPolyStringType("Threepwood", doc));
user.setEmailAddress("guybrush@meleeisland.net");
user.getOrganization().add(ModelClientUtil.createPolyStringType("Pirate Brethren International", doc));
user.getOrganizationalUnit().add(ModelClientUtil.createPolyStringType("Pirate Wannabes", doc));
user.setCredentials(ModelClientUtil.createPasswordCredentials("IwannaBEaPIRATE"));
if (role != null) {
// create user with a role assignment
AssignmentType roleAssignment = ModelClientUtil.createRoleAssignment(role.getOid());
user.getAssignment().add(roleAssignment);
}
return createUser(modelPort, user);
}
Aggregations