use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.
the class TestSanity method test501NotifyChangeModifyAccount.
@Test
public void test501NotifyChangeModifyAccount() throws Exception {
final String TEST_NAME = "test501NotifyChangeModifyAccount";
TestUtil.displayTestTile(TEST_NAME);
OperationResult parentResult = new OperationResult(TEST_NAME);
PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
assertNotNull("User with the name angelika must exist.", userAngelika);
UserType user = userAngelika.asObjectable();
assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
String oid = user.getLinkRef().get(0).getOid();
ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
ObjectDeltaType delta = new ObjectDeltaType();
delta.setChangeType(ChangeTypeType.MODIFY);
delta.setObjectType(ShadowType.COMPLEX_TYPE);
ItemDeltaType mod1 = new ItemDeltaType();
mod1.setModificationType(ModificationTypeType.REPLACE);
ItemPathType path = new ItemPathType(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName")));
mod1.setPath(path);
RawType value = new RawType(new PrimitiveXNode<String>("newAngelika"), prismContext);
mod1.getValue().add(value);
delta.getItemDelta().add(mod1);
delta.setOid(oid);
LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(mod1));
LOGGER.info("delta: {}", DebugUtil.dump(mod1));
changeDescription.setObjectDelta(delta);
changeDescription.setOldShadowOid(oid);
changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
// WHEN
TaskType task = modelWeb.notifyChange(changeDescription);
// THEN
OperationResult result = OperationResult.createOperationResult(task.getResult());
display(result);
assertSuccess(result);
PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
UserType userAfterSync = userAngelikaAfterSync.asObjectable();
PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.
the class ModelClientUtil method createItemPathType.
public static ItemPathType createItemPathType(String stringPath) {
String pathDeclaration = "declare default namespace '" + NS_COMMON + "'; " + stringPath;
ItemPathType itemPathType = new ItemPathType(pathDeclaration);
return itemPathType;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.
the class SecurityEnforcerImpl method isApplicableItem.
private <O extends ObjectType> boolean isApplicableItem(Authorization autz, PrismObject<O> object, ObjectDelta<O> delta) throws SchemaException {
List<ItemPathType> itemPaths = autz.getItem();
if (itemPaths == null || itemPaths.isEmpty()) {
// No item constraints. Applicable for all items.
LOGGER.trace(" items empty");
return true;
}
for (ItemPathType itemPathType : itemPaths) {
ItemPath itemPath = itemPathType.getItemPath();
if (delta == null) {
if (object != null) {
if (object.containsItem(itemPath, false)) {
LOGGER.trace(" applicable object item " + itemPath);
return true;
}
}
} else {
ItemDelta<?, ?> itemDelta = delta.findItemDelta(itemPath);
if (itemDelta != null && !itemDelta.isEmpty()) {
LOGGER.trace(" applicable delta item " + itemPath);
return true;
}
}
}
LOGGER.trace(" no applicable item");
return false;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.
the class SecurityEnforcerImpl method getItems.
private Collection<ItemPath> getItems(Authorization autz) {
List<ItemPathType> itemPaths = autz.getItem();
Collection<ItemPath> items = new ArrayList<>(itemPaths.size());
for (ItemPathType itemPathType : itemPaths) {
ItemPath itemPath = itemPathType.getItemPath();
items.add(itemPath);
}
return items;
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.
the class ConsistencyTest method test511AssignAccountMorgan.
/**
* assign account to the user morgan. Account with the same 'uid' (not dn, nut other secondary identifier already exists)
* account should be linked to the user.
* @throws Exception
*/
@Test
public void test511AssignAccountMorgan() throws Exception {
final String TEST_NAME = "test511AssignAccountMorgan";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
openDJController.assumeRunning();
Task task = taskManager.createTaskInstance(ConsistencyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
//prepare new OU in opendj
Entry entry = openDJController.addEntryFromLdifFile(LDIF_CREATE_USERS_OU_FILENAME);
PrismObject<UserType> user = repositoryService.getObject(UserType.class, USER_MORGAN_OID, null, result);
display("User Morgan: ", user);
PrismReference linkRef = user.findReference(UserType.F_LINK_REF);
ExpressionType expression = new ExpressionType();
ObjectFactory of = new ObjectFactory();
RawType raw = new RawType(new PrimitiveXNode("uid=morgan,ou=users,dc=example,dc=com"), prismContext);
JAXBElement val = of.createValue(raw);
expression.getExpressionEvaluator().add(val);
MappingType mapping = new MappingType();
mapping.setExpression(expression);
ResourceAttributeDefinitionType attrDefType = new ResourceAttributeDefinitionType();
attrDefType.setRef(new ItemPathType(new ItemPath(getOpenDjSecondaryIdentifierQName())));
attrDefType.setOutbound(mapping);
ConstructionType construction = new ConstructionType();
construction.getAttribute().add(attrDefType);
construction.setResourceRef(ObjectTypeUtil.createObjectRef(resourceTypeOpenDjrepo));
AssignmentType assignment = new AssignmentType();
assignment.setConstruction(construction);
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationAddContainer(UserType.class, USER_MORGAN_OID, UserType.F_ASSIGNMENT, prismContext, assignment.asPrismContainerValue());
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
// assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus());
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userMorganType.getLinkRef().size());
String accountOid = userMorganType.getLinkRef().iterator().next().getOid();
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
assertShadowRepo(accountShadow, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertShadowModel(accountModel, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
ResourceAttribute attributes = ShadowUtil.getAttribute(accountModel, new QName(resourceTypeOpenDjrepo.getNamespace(), "uid"));
assertEquals("morgan", attributes.getAnyRealValue());
// TODO: check OpenDJ Account
}
Aggregations