use of com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testCheckExpression.
private <O extends ObjectType> void testCheckExpression(String newPassword, LimitationsType lims, PrismObject<O> object, String shortDesc, Task task, OperationResult result, StringBuilder message) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
List<CheckExpressionType> checkExpressions = lims.getCheckExpression();
if (checkExpressions.isEmpty()) {
return;
}
for (CheckExpressionType checkExpression : checkExpressions) {
ExpressionType expressionType = checkExpression.getExpression();
if (expressionType == null) {
return;
}
if (!checkExpression(newPassword, expressionType, object, shortDesc, task, result)) {
String msg = checkExpression.getFailureMessage();
if (msg == null) {
msg = "Check expression failed";
}
result.addSubresult(new OperationResult("Check expression", OperationResultStatus.FATAL_ERROR, msg));
message.append(msg);
message.append("\n");
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType in project midpoint by Evolveum.
the class ValuePolicyProcessor method checkAttempt.
private <O extends ObjectType> boolean checkAttempt(String generatedValue, StringPolicyType policy, PrismObject<O> object, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
LimitationsType limitationsType = policy.getLimitations();
if (limitationsType == null) {
return true;
}
List<CheckExpressionType> checkExpressionTypes = limitationsType.getCheckExpression();
if (!checkExpressions(generatedValue, checkExpressionTypes, object, shortDesc, task, result)) {
LOGGER.trace("Check expression returned false for generated value in {}", shortDesc);
return false;
}
// TODO Check pattern
return true;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testCheckExpression.
private List<StringLimitationResult> testCheckExpression(String newPassword, LimitationsType lims, ExpressionProfile expressionProfile, ObjectBasedValuePolicyOriginResolver<?> originResolver, String shortDesc, Task task, OperationResult result, List<LocalizableMessage> messages) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
List<StringLimitationResult> limitations = new ArrayList<>();
for (CheckExpressionType checkExpression : lims.getCheckExpression()) {
ExpressionType expressionType = checkExpression.getExpression();
if (expressionType == null) {
continue;
}
StringLimitationResult limitation = new StringLimitationResult();
PolyStringType name = null;
if (checkExpression.getDisplay() != null) {
name = checkExpression.getDisplay().getLabel();
limitation.setHelp(checkExpression.getDisplay().getHelp());
}
if (name == null) {
name = new PolyStringType("Check expression");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.checkExpression");
name.setTranslation(translation);
}
limitation.setName(name);
limitation.setSuccess(true);
if (!checkExpression(newPassword, expressionType, expressionProfile, originResolver, shortDesc, task, result)) {
LocalizableMessage msg;
if (checkExpression.getLocalizableFailureMessage() != null) {
msg = LocalizationUtil.toLocalizableMessage(checkExpression.getLocalizableFailureMessage());
} else if (checkExpression.getFailureMessage() != null) {
msg = LocalizableMessageBuilder.buildFallbackMessage(checkExpression.getFailureMessage());
} else {
msg = LocalizableMessageBuilder.buildKey("ValuePolicy.checkExpressionFailed");
}
result.addSubresult(new OperationResult("Check expression", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
}
limitations.add(limitation);
}
return limitations;
}
Aggregations