Search in sources :

Example 1 with NonceCredentialsPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType 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);
        }
    }
}
Also used : PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)

Example 2 with NonceCredentialsPolicyType

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

the class PageForgotPassword method generateNonce.

private <O extends ObjectType> String generateNonce(NonceCredentialsPolicyType noncePolicy, Task task, PrismObject<O> user, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
    ValuePolicyType policy = null;
    if (noncePolicy != null && noncePolicy.getValuePolicyRef() != null) {
        PrismObject<ValuePolicyType> valuePolicy = WebModelServiceUtils.loadObject(ValuePolicyType.class, noncePolicy.getValuePolicyRef().getOid(), PageForgotPassword.this, task, result);
        policy = valuePolicy.asObjectable();
    }
    return getModelInteractionService().generateValue(policy != null ? policy.getStringPolicy() : null, 24, false, user, "nonce generation", task, result);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)

Example 3 with NonceCredentialsPolicyType

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

the class PageSelfRegistration method createCredentials.

private void createCredentials(UserType user, NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
    NonceType nonceType = createNonce(noncePolicy, task, result);
    // PasswordType password = createPassword();
    CredentialsType credentials = user.getCredentials();
    if (user.getCredentials() == null) {
        credentials = new CredentialsType();
        user.setCredentials(credentials);
    }
    credentials.setNonce(nonceType);
// credentials.setPassword(password);
// return credentials;
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) NonceType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType)

Example 4 with NonceCredentialsPolicyType

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

the class PageForgotPassword method saveUserNonce.

private OperationResult saveUserNonce(final UserType user, final NonceCredentialsPolicyType noncePolicy) {
    return runPrivileged(new Producer<OperationResult>() {

        @Override
        public OperationResult run() {
            Task task = createAnonymousTask("generateUserNonce");
            task.setChannel(SchemaConstants.CHANNEL_GUI_RESET_PASSWORD_URI);
            task.setOwner(user.asPrismObject());
            OperationResult result = new OperationResult("generateUserNonce");
            ProtectedStringType nonceCredentials = new ProtectedStringType();
            try {
                nonceCredentials.setClearValue(generateNonce(noncePolicy, task, user.asPrismObject(), result));
                NonceType nonceType = new NonceType();
                nonceType.setValue(nonceCredentials);
                ObjectDelta<UserType> nonceDelta;
                nonceDelta = ObjectDelta.createModificationReplaceContainer(UserType.class, user.getOid(), SchemaConstants.PATH_NONCE, getPrismContext(), nonceType);
                WebModelServiceUtils.save(nonceDelta, result, task, PageForgotPassword.this);
            } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException e) {
                result.recordFatalError("Failed to generate nonce for user");
                LoggingUtils.logException(LOGGER, "Failed to generate nonce for user: " + e.getMessage(), e);
            }
            result.computeStatusIfUnknown();
            return result;
        }
    });
}
Also used : Task(com.evolveum.midpoint.task.api.Task) NonceType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 5 with NonceCredentialsPolicyType

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

the class PageSelfRegistration method createNonce.

private NonceType createNonce(NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
    ProtectedStringType nonceCredentials = new ProtectedStringType();
    nonceCredentials.setClearValue(generateNonce(noncePolicy, null, task, result));
    NonceType nonceType = new NonceType();
    nonceType.setValue(nonceCredentials);
    return nonceType;
}
Also used : NonceType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Aggregations

NonceType (com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType)3 CredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType)2 NonceCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType)2 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 CredentialsType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)1 PasswordCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType)1 SecurityQuestionsCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)1 ArrayList (java.util.ArrayList)1