Search in sources :

Example 71 with ProtectedStringType

use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.

the class TestOpenDjReadablePassword method assertShadowPassword.

@Override
protected void assertShadowPassword(ShadowType provisioningShadow) throws Exception {
    CredentialsType credentials = provisioningShadow.getCredentials();
    if (credentials == null) {
        return;
    }
    PasswordType passwordType = credentials.getPassword();
    if (passwordType == null) {
        return;
    }
    ProtectedStringType passwordValue = passwordType.getValue();
    assertNotNull("Missing password value in " + provisioningShadow, passwordValue);
    assertFalse("Empty password value in " + provisioningShadow, passwordValue.isEmpty());
    String clearPassword = protector.decryptString(passwordValue);
    display("Clear password of " + provisioningShadow + ": " + clearPassword);
    PrismContainerValue<PasswordType> passwordContainer = passwordType.asPrismContainerValue();
    PrismProperty<ProtectedStringType> valueProp = passwordContainer.findProperty(PasswordType.F_VALUE);
    assertFalse("Incomplete password value in " + provisioningShadow, valueProp.isIncomplete());
}
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 72 with ProtectedStringType

use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.

the class TestOpenDjIncompletePassword method assertShadowPassword.

@Override
protected void assertShadowPassword(ShadowType provisioningShadow) {
    CredentialsType credentials = provisioningShadow.getCredentials();
    if (credentials == null) {
        return;
    }
    PasswordType passwordType = credentials.getPassword();
    if (passwordType == null) {
        return;
    }
    ProtectedStringType passwordValue = passwordType.getValue();
    assertNull("Unexpected password value in " + provisioningShadow + ": " + passwordValue, passwordValue);
    PrismContainerValue<PasswordType> passwordContainer = passwordType.asPrismContainerValue();
    PrismProperty<ProtectedStringType> valueProp = passwordContainer.findProperty(PasswordType.F_VALUE);
    assertTrue("Incomplete flag is NOT set for password value in " + provisioningShadow, valueProp.isIncomplete());
}
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 73 with ProtectedStringType

use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.

the class AbstractEDirTest method test220ModifyUserBarbossaPassword.

@Test
public void test220ModifyUserBarbossaPassword() throws Exception {
    final String TEST_NAME = "test220ModifyUserBarbossaPassword";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ProtectedStringType userPasswordPs = new ProtectedStringType();
    userPasswordPs.setClearValue("hereThereBeMonsters");
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyUserReplace(USER_BARBOSSA_OID, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), task, result, userPasswordPs);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    assertAttribute(entry, "title", "Captain");
    assertLdapPassword(USER_BARBOSSA_USERNAME, "hereThereBeMonsters");
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.apache.directory.api.ldap.model.entry.Entry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 74 with ProtectedStringType

use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.

the class AbstractLdapConnTest method test220ModifyUserBarbossaPassword.

@Test
public void test220ModifyUserBarbossaPassword() throws Exception {
    final String TEST_NAME = "test220ModifyUserBarbossaPassword";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ProtectedStringType userPasswordPs = new ProtectedStringType();
    userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_2);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyUserReplace(USER_BARBOSSA_OID, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), task, result, userPasswordPs);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    assertAttribute(entry, "title", "Captain");
    assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD_2);
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
    assertLdapConnectorInstances(1, 2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.apache.directory.api.ldap.model.entry.Entry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 75 with ProtectedStringType

use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.

the class TestSanity 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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) XNode(com.evolveum.midpoint.prism.xnode.XNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) Document(org.w3c.dom.Document) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)120 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)48 Test (org.testng.annotations.Test)48 Task (com.evolveum.midpoint.task.api.Task)39 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 QName (javax.xml.namespace.QName)20 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)18 PasswordType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)18 CredentialsType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)11 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)10 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)9 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)9 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)9 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)9 Document (org.w3c.dom.Document)8 ArrayList (java.util.ArrayList)7 Entry (org.apache.directory.api.ldap.model.entry.Entry)7