Search in sources :

Example 21 with PasswordType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.

the class ObjectValuePolicyEvaluator method validateHistory.

private void validateHistory(String clearValue, StringBuilder messageBuilder, OperationResult result) throws SchemaException {
    if (!QNameUtil.match(CredentialsType.F_PASSWORD, credentialQName)) {
        LOGGER.trace("Skipping validating {} history, only passowrd history is supported", shortDesc);
        return;
    }
    int historyLegth = getHistoryLength();
    if (historyLegth == 0) {
        LOGGER.trace("Skipping validating {} history, because history length is set to zero", shortDesc);
        return;
    }
    PasswordType currentPasswordType = (PasswordType) oldCredentialType;
    if (currentPasswordType == null) {
        LOGGER.trace("Skipping validating {} history, because it is empty", shortDesc);
        return;
    }
    ProtectedStringType newPasswordPs = new ProtectedStringType();
    newPasswordPs.setClearValue(clearValue);
    if (passwordEquals(newPasswordPs, currentPasswordType.getValue())) {
        LOGGER.trace("{} matched current value", shortDesc);
        appendHistoryViolationMessage(messageBuilder, result);
        return;
    }
    List<PasswordHistoryEntryType> sortedHistoryList = getSortedHistoryList(currentPasswordType.asPrismContainerValue().findContainer(PasswordType.F_HISTORY_ENTRY), false);
    int i = 1;
    for (PasswordHistoryEntryType historyEntry : sortedHistoryList) {
        if (i >= historyLegth) {
            // success (history has more entries than needed)
            return;
        }
        if (passwordEquals(newPasswordPs, historyEntry.getValue())) {
            LOGGER.trace("Password history entry #{} matched (changed {})", i, historyEntry.getChangeTimestamp());
            appendHistoryViolationMessage(messageBuilder, result);
            return;
        }
        i++;
    }
}
Also used : PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 22 with PasswordType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.

the class SecurityQuestionAuthneticationEvaluatorImpl method passwordMatches.

@Override
protected boolean passwordMatches(ConnectionEnvironment connEnv, MidPointPrincipal principal, SecurityQuestionsCredentialsType passwordType, SecurityQuestionsAuthenticationContext authCtx) {
    SecurityQuestionsCredentialsPolicyType policy = authCtx.getPolicy();
    Integer iNumberOfQuestions = policy.getQuestionNumber();
    int numberOfQuestions = 0;
    if (iNumberOfQuestions != null) {
        numberOfQuestions = iNumberOfQuestions.intValue();
    }
    Map<String, String> enteredQuestionsAnswers = authCtx.getQuestionAnswerMap();
    if (numberOfQuestions > enteredQuestionsAnswers.size()) {
        return false;
    }
    List<SecurityQuestionAnswerType> quetionsAnswers = passwordType.getQuestionAnswer();
    int matched = 0;
    for (SecurityQuestionAnswerType questionAnswer : quetionsAnswers) {
        String enteredAnswer = enteredQuestionsAnswers.get(questionAnswer.getQuestionIdentifier());
        if (StringUtils.isNotBlank(enteredAnswer)) {
            if (decryptAndMatch(connEnv, principal, questionAnswer.getQuestionAnswer(), enteredAnswer)) {
                matched++;
            }
        }
    }
    return matched > 0 && matched >= numberOfQuestions;
}
Also used : SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType) SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType)

Example 23 with PasswordType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method test103ModifyUserPasswordAgain.

@Test
public void test103ModifyUserPasswordAgain() throws Exception {
    final String TEST_NAME = "test103ModifyUserPasswordAgain";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    modifyUserChangePassword(USER_JACK_OID, PASSWORD3, task, result);
    // THEN
    PrismObject<UserType> jackAfterSecondChange = getObject(UserType.class, USER_JACK_OID);
    assertNotNull("User Jack was not found.", jackAfterSecondChange);
    UserType jackTypeAfterSecondChange = jackAfterSecondChange.asObjectable();
    CredentialsType credentialsTypeAfterSecondChange = jackTypeAfterSecondChange.getCredentials();
    assertNotNull("No credentials set for user Jack", credentialsTypeAfterSecondChange);
    PasswordType passwordTypeAfterSecondChnage = credentialsTypeAfterSecondChange.getPassword();
    assertNotNull("No password set for user Jack", passwordTypeAfterSecondChnage);
    ProtectedStringType passwordAfterSecondChange = passwordTypeAfterSecondChnage.getValue();
    assertNotNull("Password musn't be null", passwordAfterSecondChange);
    assertEquals("Password doesn't match", PASSWORD3, protector.decryptString(passwordAfterSecondChange));
    assertPasswordHistoryEntries(passwordTypeAfterSecondChnage, PASSWORD1, PASSWORD2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

Example 24 with PasswordType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method test202createUserJackNoPasswordHistory.

@Test
public void test202createUserJackNoPasswordHistory() throws Exception {
    final String TEST_NAME = "test202createUserJackNoPasswordHistory";
    TestUtil.displayTestTile(TEST_NAME);
    // WHEN
    addObject(USER_JACK_FILE);
    // THEN
    PrismObject<UserType> userJack = getObject(UserType.class, USER_JACK_OID);
    assertNotNull("Expected to find user Jack, but no one exists here", userJack);
    UserType userJackType = userJack.asObjectable();
    CredentialsType credentials = userJackType.getCredentials();
    assertNotNull("User Jack has no credentials", credentials);
    PasswordType password = credentials.getPassword();
    assertNotNull("User Jack has no password", password);
    List<PasswordHistoryEntryType> historyEntries = password.getHistoryEntry();
    assertEquals("Expected no history entries, but found: " + historyEntries.size(), 0, historyEntries.size());
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) Test(org.testng.annotations.Test)

Example 25 with PasswordType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method test102ModifyUserPassword.

@Test
public void test102ModifyUserPassword() throws Exception {
    final String TEST_NAME = "test102ModifyUserPassword";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    modifyUserChangePassword(USER_JACK_OID, PASSWORD2, task, result);
    // THEN
    PrismObject<UserType> jack = getObject(UserType.class, USER_JACK_OID);
    assertNotNull("User Jack was not found.", jack);
    UserType jackType = jack.asObjectable();
    CredentialsType credentialsType = jackType.getCredentials();
    assertNotNull("No credentials set for user Jack", credentialsType);
    PasswordType passwordType = credentialsType.getPassword();
    assertNotNull("No password set for user Jack", passwordType);
    ProtectedStringType passwordAfterChange = passwordType.getValue();
    assertNotNull("Password musn't be null", passwordAfterChange);
    assertEquals("Password doesn't match", PASSWORD2, protector.decryptString(passwordAfterChange));
    assertPasswordHistoryEntries(passwordType, USER_JACK_PASSWORD, PASSWORD1);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

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