use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.
the class ModelClientUtil method createPasswordType.
public static PasswordType createPasswordType(String password) {
PasswordType passwordType = new PasswordType();
passwordType.setValue(createProtectedString(password));
return passwordType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.
the class ProvisioningUtil method addPasswordMetadata.
public static void addPasswordMetadata(PasswordType p, XMLGregorianCalendar now, PrismObject<UserType> owner) {
MetadataType metadata = p.getMetadata();
if (metadata != null) {
return;
}
// Supply some metadata if they are not present. However the
// normal thing is that those metadata are provided by model
metadata = new MetadataType();
metadata.setCreateTimestamp(now);
if (owner != null) {
metadata.creatorRef(owner.getOid(), null);
}
p.setMetadata(metadata);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.
the class TestAssignmentErrors method test210UserSharptoothAssignAccountBrokenGeneric.
// PARTIAL_ERROR: Unable to get object from the resource. Probably it has not been created yet because of previous unavailability of the resource.
// TODO: timeout or explicit retry
// @Test
// public void test205UserLemonheadRecovery() throws Exception {
// final String TEST_NAME = "test205UserLemonheadRecovery";
// TestUtil.displayTestTile(this, TEST_NAME);
//
// // GIVEN
// Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
// OperationResult result = task.getResult();
// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
//
// dummyResource.setBreakMode(BreakMode.NONE);
// dummyAuditService.clear();
//
// // WHEN
// //not expected that it fails, instead the error in the result is expected
// modelService.recompute(UserType.class, userLemonheadOid, task, result);
//
// result.computeStatus();
//
// display(result);
// // This has to be a partial error as some changes were executed (user) and others were not (account)
// TestUtil.assertSuccess(result);
//
// // Check audit
// display("Audit", dummyAuditService);
// dummyAuditService.assertSimpleRecordSanity();
// dummyAuditService.assertRecords(2);
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertTarget(userLemonheadOid);
// dummyAuditService.assertExecutionOutcome(OperationResultStatus.HANDLED_ERROR);
// dummyAuditService.assertExecutionMessage();
//
// }
@Test
public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception {
final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
PrismObject<UserType> user = createUser(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME);
CredentialsType credentialsType = new CredentialsType();
PasswordType passwordType = new PasswordType();
ProtectedStringType passwordPs = new ProtectedStringType();
passwordPs.setClearValue(USER_SHARPTOOTH_PASSWORD_1_CLEAR);
passwordType.setValue(passwordPs);
credentialsType.setPassword(passwordType);
user.asObjectable().setCredentials(credentialsType);
addObject(user);
userSharptoothOid = user.getOid();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(user.getOid(), RESOURCE_DUMMY_OID, null, true);
deltas.add(accountAssignmentUserDelta);
getDummyResource().setBreakMode(BreakMode.GENERIC);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
//not expected that it fails, instead the error in the result is expected
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display(result);
// This has to be a partial error as some changes were executed (user) and others were not (account)
TestUtil.assertPartialError(result);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class, OperationResultStatus.FATAL_ERROR);
dummyAuditService.assertTarget(user.getOid());
dummyAuditService.assertExecutionOutcome(OperationResultStatus.PARTIAL_ERROR);
dummyAuditService.assertExecutionMessage();
LensContext<UserType> lastLensContext = lensDebugListener.getLastLensContext();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = lastLensContext.getExecutedDeltas();
display("Executed deltas", executedDeltas);
assertEquals("Unexpected number of execution deltas in context", 2, executedDeltas.size());
Iterator<ObjectDeltaOperation<? extends ObjectType>> i = executedDeltas.iterator();
ObjectDeltaOperation<? extends ObjectType> deltaop1 = i.next();
assertEquals("Unexpected result of first executed deltas", OperationResultStatus.SUCCESS, deltaop1.getExecutionResult().getStatus());
ObjectDeltaOperation<? extends ObjectType> deltaop2 = i.next();
assertEquals("Unexpected result of second executed deltas", OperationResultStatus.FATAL_ERROR, deltaop2.getExecutionResult().getStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertUserLdapPassword.
protected void assertUserLdapPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = user.asObjectable().getCredentials();
assertNotNull("No credentials in " + user, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + user, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertLdapPassword(protectedStringType, expectedPassword, user);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertPassword.
protected void assertPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = user.asObjectable().getCredentials();
assertNotNull("No credentials in " + user, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + user, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertNotNull("No password value in " + user, protectedStringType);
String decryptedUserPassword = protector.decryptString(protectedStringType);
assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword);
}
Aggregations