Search in sources :

Example 6 with PasswordType

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;
}
Also used : PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)

Example 7 with 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);
}
Also used : MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)

Example 8 with PasswordType

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 9 with PasswordType

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);
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 10 with PasswordType

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);
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Aggregations

PasswordType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)23 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)18 CredentialsType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)16 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 Test (org.testng.annotations.Test)8 Task (com.evolveum.midpoint.task.api.Task)7 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 PasswordHistoryEntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1