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++;
}
}
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;
}
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);
}
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());
}
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);
}
Aggregations