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