Search in sources :

Example 6 with NonceCredentialsPolicyType

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

the class PageSelfRegistration method generateNonce.

private <O extends ObjectType> String generateNonce(NonceCredentialsPolicyType noncePolicy, PrismObject<O> user, Task task, 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(), PageSelfRegistration.this, task, result);
        policy = valuePolicy.asObjectable();
    }
    return getModelInteractionService().generateValue(policy != null ? policy.getStringPolicy() : null, 24, false, user, "nonce generation (registration)", task, result);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)

Example 7 with NonceCredentialsPolicyType

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

the class SecurityPolicyUtil method getCredentialPolicy.

public static NonceCredentialsPolicyType getCredentialPolicy(String policyName, SecurityPolicyType securityPolicy) throws SchemaException {
    CredentialsPolicyType credentialsPolicy = securityPolicy.getCredentials();
    if (credentialsPolicy == null) {
        return null;
    }
    List<NonceCredentialsPolicyType> noncePolicies = credentialsPolicy.getNonce();
    List<NonceCredentialsPolicyType> availableNoncePolicies = new ArrayList<>();
    for (NonceCredentialsPolicyType noncePolicy : noncePolicies) {
        if (noncePolicy.getName() == null && policyName == null) {
            availableNoncePolicies.add(noncePolicy);
        }
        if (noncePolicy.getName() == null && policyName != null) {
            continue;
        }
        if (noncePolicy.getName() != null && policyName == null) {
            continue;
        }
        if (noncePolicy.getName().equals(policyName)) {
            availableNoncePolicies.add(noncePolicy);
        }
    }
    if (availableNoncePolicies.size() > 1) {
        throw new SchemaException("Found more than one nonce credentials policy. Please review your configuration");
    }
    if (availableNoncePolicies.size() == 0) {
        return null;
    }
    return availableNoncePolicies.iterator().next();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) ArrayList(java.util.ArrayList) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType)

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