use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType in project midpoint by Evolveum.
the class SecurityHelper method postProcessSecurityPolicy.
private void postProcessSecurityPolicy(SecurityPolicyType securityPolicyType, Task task, OperationResult result) {
CredentialsPolicyType creds = securityPolicyType.getCredentials();
if (creds != null) {
PasswordCredentialsPolicyType passwd = creds.getPassword();
if (passwd != null) {
postProcessPasswordCredentialPolicy(securityPolicyType, passwd, task, result);
}
for (NonceCredentialsPolicyType nonce : creds.getNonce()) {
postProcessCredentialPolicy(securityPolicyType, nonce, "nonce credential policy", task, result);
}
SecurityQuestionsCredentialsPolicyType securityQuestions = creds.getSecurityQuestions();
if (securityQuestions != null) {
postProcessCredentialPolicy(securityPolicyType, securityQuestions, "security questions credential policy", task, result);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType 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.SecurityQuestionsCredentialsPolicyType in project midpoint by Evolveum.
the class SecurityQuestionAuthneticationEvaluatorImpl method getEffectiveCredentialPolicy.
@Override
protected CredentialPolicyType getEffectiveCredentialPolicy(SecurityPolicyType securityPolicy, SecurityQuestionsAuthenticationContext authnCtx) throws SchemaException {
SecurityQuestionsCredentialsPolicyType policy = authnCtx.getPolicy();
if (policy == null) {
policy = SecurityUtil.getEffectiveSecurityQuestionsCredentialsPolicy(securityPolicy);
}
authnCtx.setPolicy(policy);
return policy;
}
Aggregations