use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TestSanityLegacy method test023ChangeUserPasswordJAXB.
/**
* Similar to previous test just the request is constructed a bit differently.
*/
@Test
public void test023ChangeUserPasswordJAXB() throws Exception {
final String TEST_NAME = "test023ChangeUserPasswordJAXB";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
final String NEW_PASSWORD = "abandonSHIP";
Document doc = ModelClientUtil.getDocumnent();
ObjectDeltaType userDelta = new ObjectDeltaType();
userDelta.setOid(USER_JACK_OID);
userDelta.setChangeType(ChangeTypeType.MODIFY);
userDelta.setObjectType(UserType.COMPLEX_TYPE);
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
ProtectedStringType pass = new ProtectedStringType();
pass.setClearValue(NEW_PASSWORD);
XNode passValue = ((PrismContextImpl) prismContext).getBeanMarshaller().marshall(pass);
System.out.println("PASSWORD VALUE: " + passValue.debugDump());
RawType passwordValue = new RawType(passValue, prismContext);
passwordDelta.getValue().add(passwordValue);
userDelta.getItemDelta().add(passwordDelta);
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(userDelta);
// THEN
assertUserPasswordChange(NEW_PASSWORD, result);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TestSanityLegacy method test501NotifyChangeModifyAccount.
@Test
public void test501NotifyChangeModifyAccount() throws Exception {
TestUtil.displayTestTile("test501NotifyChangeModifyAccount");
OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
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);
//TODO: shouldn't it be JaxbElement<PolyString>?
// Element el = DOMUtil.createElement(DOMUtil.getDocument(), new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName"));
// el.setTextContent("newAngelika");
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);
TaskType task = modelWeb.notifyChange(changeDescription);
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.ItemDeltaType in project midpoint by Evolveum.
the class TestUcfOpenDj method test610ChangePassword.
@Test
public void test610ChangePassword() throws Exception {
final String TEST_NAME = "test610ChangePassword";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
ResourceAttributeContainer resourceObject = createResourceObject("uid=drake,ou=People,dc=example,dc=com", "Sir Francis Drake", "Drake");
PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject);
OperationResult addResult = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
// Add a testing object
cc.addObject(shadow, null, null, addResult);
String entryUuid = (String) resourceObject.getPrimaryIdentifier().getValue().getValue();
Entry entry = openDJController.searchAndAssertByEntryUuid(entryUuid);
display("Entry before change", entry);
String passwordBefore = OpenDJController.getAttributeValue(entry, "userPassword");
// We have set no password during create, therefore the password should
// be empty
assertNull(passwordBefore);
ObjectClassComplexTypeDefinition accountDefinition = resourceObject.getDefinition().getComplexTypeDefinition();
Collection<ResourceAttribute<?>> identifiers = resourceObject.getPrimaryIdentifiers();
// Determine object class from the schema
OperationResult result = new OperationResult(this.getClass().getName() + ".testFetchObject");
// WHEN
Set<Operation> changes = new HashSet<Operation>();
ProtectedStringType passPs = protector.encryptString("salalala");
ItemDeltaType propMod = new ItemDeltaType();
//create modification path
Document doc = DOMUtil.getDocument();
ItemPathType path = new ItemPathType("credentials/password/value");
// PropertyPath propPath = new PropertyPath(new PropertyPath(ResourceObjectShadowType.F_CREDENTIALS), CredentialsType.F_PASSWORD);
propMod.setPath(path);
//set the replace value
MapXNode passPsXnode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(passPs, null);
RawType value = new RawType(passPsXnode, prismContext);
propMod.getValue().add(value);
//set the modificaion type
propMod.setModificationType(ModificationTypeType.REPLACE);
PropertyDelta passDelta = (PropertyDelta) DeltaConvertor.createItemDelta(propMod, shadow.getDefinition());
PropertyModificationOperation passwordModification = new PropertyModificationOperation(passDelta);
changes.add(passwordModification);
// PasswordChangeOperation passwordChange = new PasswordChangeOperation(passPs);
// changes.add(passwordChange);
cc.modifyObject(accountDefinition, identifiers, changes, null, result);
// THEN
entry = openDJController.searchAndAssertByEntryUuid(entryUuid);
display("Entry after change", entry);
String passwordAfter = OpenDJController.getAttributeValue(entry, "userPassword");
assertNotNull(passwordAfter);
System.out.println("Account password: " + passwordAfter);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method modifyObject.
protected ObjectDeltaOperationType modifyObject(Class objectType, String oid, String path, ModificationTypeType modType, Object value, ModelExecuteOptionsType optionsType, boolean assertSuccess) throws Exception {
System.out.println("Modifying " + objectType.getSimpleName() + " " + oid + " (path: " + path + ")");
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(objectType));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
if (path != null) {
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(modType);
itemDelta.setPath(createNonDefaultItemPathType(path));
if (!(value instanceof Collection)) {
itemDelta.getValue().add(value);
} else {
itemDelta.getValue().addAll((Collection) value);
}
deltaType.getItemDelta().add(itemDelta);
}
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType odolist = modelPort.executeChanges(deltaListType, optionsType);
return assertExecuteChangesSuccess(odolist, deltaType, assertSuccess);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class Main method changeUserGivenName.
private static void changeUserGivenName(ModelPortType modelPort, String oid, String newValue) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
ObjectDeltaType userDelta = new ObjectDeltaType();
userDelta.setOid(oid);
userDelta.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
userDelta.setChangeType(ChangeTypeType.MODIFY);
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(ModificationTypeType.REPLACE);
itemDelta.setPath(ModelClientUtil.createItemPathType("givenName"));
itemDelta.getValue().add(ModelClientUtil.createPolyStringType(newValue, doc));
userDelta.getItemDelta().add(itemDelta);
ObjectDeltaListType deltaList = new ObjectDeltaListType();
deltaList.getDelta().add(userDelta);
modelPort.executeChanges(deltaList, null);
}
Aggregations