Search in sources :

Example 51 with ProtectedStringType

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

the class AbstractPasswordTest method test412InitializeRappDummyLifecycle.

@Test
public void test412InitializeRappDummyLifecycle() throws Exception {
    final String TEST_NAME = "test412InitializeRappDummyLifecycle";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_RAPP_OID);
    display("User before", userBefore);
    String accountLifecycleOid = getLinkRefOid(userBefore, RESOURCE_DUMMY_LIFECYCLE_OID);
    ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createEmptyModifyDelta(ShadowType.class, accountLifecycleOid, prismContext);
    ProtectedStringType passwordPs = new ProtectedStringType();
    passwordPs.setClearValue(USER_PASSWORD_VALID_1);
    shadowDelta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_VALUE, passwordPs);
    shadowDelta.addModificationReplaceProperty(ObjectType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    executeChanges(shadowDelta, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_RAPP_OID);
    display("User after", userAfter);
    assertLinks(userAfter, 3);
    accountLifecycleOid = getLinkRefOid(userAfter, RESOURCE_DUMMY_LIFECYCLE_OID);
    assertDummyAccount(RESOURCE_DUMMY_LIFECYCLE_NAME, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true);
    assertDummyPassword(RESOURCE_DUMMY_LIFECYCLE_NAME, USER_RAPP_USERNAME, USER_PASSWORD_VALID_1);
    PrismObject<ShadowType> accountShadowLifecycle = repositoryService.getObject(ShadowType.class, accountLifecycleOid, null, result);
    display("Repo shadow LIFECYCLE", accountShadowLifecycle);
    assertAccountShadowRepo(accountShadowLifecycle, accountLifecycleOid, USER_RAPP_USERNAME, getDummyResourceType(RESOURCE_DUMMY_LIFECYCLE_NAME));
    assertShadowLifecycle(accountShadowLifecycle, SchemaConstants.LIFECYCLE_ACTIVE);
    assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true);
    assertDummyPassword(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_PASSWORD_VALID_1);
    assertUserPassword(userAfter, USER_PASSWORD_VALID_1);
    assertDefaultDummyAccount(USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true);
    assertDummyPassword(null, USER_RAPP_USERNAME, USER_PASSWORD_VALID_1);
    // RED shadows
    String accountRedOid = getLinkRefOid(userAfter, RESOURCE_DUMMY_RED_OID);
    PrismObject<ShadowType> accountShadowRed = repositoryService.getObject(ShadowType.class, accountRedOid, null, result);
    display("Repo shadow RED", accountShadowRed);
    assertAccountShadowRepo(accountShadowRed, accountRedOid, USER_RAPP_USERNAME, getDummyResourceType(RESOURCE_DUMMY_RED_NAME));
    assertShadowLifecycle(accountShadowRed, SchemaConstants.LIFECYCLE_ACTIVE);
    PrismObject<ShadowType> accountModelRed = modelService.getObject(ShadowType.class, accountRedOid, null, task, result);
    display("Model shadow RED", accountModelRed);
    assertAccountShadowModel(accountModelRed, accountRedOid, USER_RAPP_USERNAME, getDummyResourceType(RESOURCE_DUMMY_RED_NAME));
    assertShadowLifecycle(accountModelRed, SchemaConstants.LIFECYCLE_ACTIVE);
    // DEFAULT shadows
    String accountDefaultOid = getLinkRefOid(userAfter, RESOURCE_DUMMY_OID);
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountDefaultOid, null, task, result);
    assertDummyAccountShadowModel(accountModel, accountDefaultOid, USER_RAPP_USERNAME, USER_RAPP_FULLNAME);
    assertShadowLifecycle(accountModel, null);
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountDefaultOid, null, result);
    assertDummyAccountShadowRepo(accountShadow, accountDefaultOid, USER_RAPP_USERNAME);
    assertShadowLifecycle(accountShadow, null);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 52 with ProtectedStringType

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

the class AbstractPasswordTest method test060CheckJackPasswordModelInteraction.

@Test
public void test060CheckJackPasswordModelInteraction() throws Exception {
    final String TEST_NAME = "test060CheckJackPasswordModelInteraction";
    TestUtil.displayTestTile(this, TEST_NAME);
    if (getPasswordStorageType() == CredentialsStorageTypeType.NONE) {
        // Nothing to check in this case
        return;
    }
    // GIVEN
    Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN, THEN
    ProtectedStringType userPasswordPsGood = new ProtectedStringType();
    userPasswordPsGood.setClearValue(USER_PASSWORD_1_CLEAR);
    assertTrue("Good password check failed", modelInteractionService.checkPassword(USER_JACK_OID, userPasswordPsGood, task, result));
    ProtectedStringType userPasswordPsBad = new ProtectedStringType();
    userPasswordPsBad.setClearValue("this is not a password");
    assertFalse("Bad password check failed", modelInteractionService.checkPassword(USER_JACK_OID, userPasswordPsBad, task, result));
    ProtectedStringType userPasswordPsEmpty = new ProtectedStringType();
    assertFalse("Empty password check failed", modelInteractionService.checkPassword(USER_JACK_OID, userPasswordPsEmpty, task, result));
    assertFalse("Null password check failed", modelInteractionService.checkPassword(USER_JACK_OID, null, task, result));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 53 with ProtectedStringType

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

the class AbstractPasswordTest method test112ModifyJackPasswordUserAndAccount.

/**
	 * Modify both user and account password. As password outbound mapping is weak the user should have its own password
	 * and account should have its own password.
	 */
@Test
public void test112ModifyJackPasswordUserAndAccount() throws Exception {
    final String TEST_NAME = "test112ModifyJackPasswordUserAndAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    ProtectedStringType userPasswordPs4 = new ProtectedStringType();
    userPasswordPs4.setClearValue(USER_PASSWORD_4_CLEAR);
    ObjectDelta<UserType> userDelta = createModifyUserReplaceDelta(USER_JACK_OID, PASSWORD_VALUE_PATH, userPasswordPs4);
    ProtectedStringType userPasswordPs5 = new ProtectedStringType();
    userPasswordPs5.setClearValue(USER_PASSWORD_5_CLEAR);
    ObjectDelta<ShadowType> accountDelta = createModifyAccountShadowReplaceDelta(accountJackOid, getDummyResourceObject(), PASSWORD_VALUE_PATH, userPasswordPs5);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(accountDelta, userDelta);
    lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack, "Jack Sparrow");
    // User should still have old password
    assertUserPassword(userJack, USER_PASSWORD_4_CLEAR);
    // Account has new password
    assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_5_CLEAR);
    assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 54 with ProtectedStringType

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

the class TestPasswordAuthenticationEvaluator method getGuybrushPassword.

private ProtectedStringType getGuybrushPassword() {
    ProtectedStringType protectedString = new ProtectedStringType();
    protectedString.setClearValue(USER_GUYBRUSH_PASSWORD);
    return protectedString;
}
Also used : ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 55 with ProtectedStringType

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

the class TestSecurityQuestionsAuthenticationEvaluator method getSecurityQuestionAnswer.

private SecurityQuestionAnswerType getSecurityQuestionAnswer() {
    SecurityQuestionAnswerType questionAnswer = new SecurityQuestionAnswerType();
    questionAnswer.setQuestionIdentifier(SECURITY_QUESTION_ID);
    ProtectedStringType protectedString = new ProtectedStringType();
    protectedString.setClearValue(SECURITY_QUESTION_GOOD_ANSWER_GUYBRUSH);
    questionAnswer.setQuestionAnswer(protectedString);
    return questionAnswer;
}
Also used : SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

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