use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProhibitedValuesType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testProhibitedValues.
private StringLimitationResult testProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, ObjectBasedValuePolicyOriginResolver<?> originResolver, String shortDesc, Task task, OperationResult result, List<LocalizableMessage> messages) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (prohibitedValuesType == null || originResolver == null) {
return null;
}
StringLimitationResult limitation = new StringLimitationResult();
PolyStringType name = new PolyStringType("prohibited value");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.prohibitedValueName");
name.setTranslation(translation);
limitation.setName(name);
PolyStringType help = new PolyStringType("");
PolyStringTranslationType helpTranslation = new PolyStringTranslationType();
helpTranslation.setKey("ValuePolicy.prohibitedValue");
help.setTranslation(helpTranslation);
limitation.setHelp(help);
limitation.setSuccess(true);
Consumer<ProhibitedValueItemType> failAction = (prohibitedItemType) -> {
LocalizableMessage msg = new LocalizableMessageBuilder().key("ValuePolicy.prohibitedValue").build();
result.addSubresult(new OperationResult("Prohibited value", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
};
checkProhibitedValues(newPassword, prohibitedValuesType, originResolver, failAction, shortDesc, task, result);
return limitation;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProhibitedValuesType in project midpoint by Evolveum.
the class ValuePolicyProcessor method checkProhibitedValues.
private <O extends ObjectType, R extends ObjectType> boolean checkProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, ObjectBasedValuePolicyOriginResolver<O> originResolver, Consumer<ProhibitedValueItemType> failAction, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (prohibitedValuesType == null || originResolver == null) {
return true;
}
MutableBoolean isAcceptable = new MutableBoolean(true);
for (ProhibitedValueItemType prohibitedItemType : prohibitedValuesType.getItem()) {
ItemPathType itemPathType = prohibitedItemType.getPath();
if (itemPathType == null) {
throw new SchemaException("No item path defined in prohibited item in " + shortDesc);
}
ItemPath itemPath = itemPathType.getItemPath();
ResultHandler<R> handler = (object, objectResult) -> {
PrismProperty<Object> objectProperty = object.findProperty(itemPath);
if (objectProperty == null) {
return true;
}
if (isMatching(newPassword, objectProperty)) {
if (failAction != null) {
failAction.accept(prohibitedItemType);
}
isAcceptable.setValue(false);
return false;
}
return true;
};
originResolver.resolve(prohibitedItemType, handler, shortDesc, task, result);
}
return isAcceptable.booleanValue();
}
Aggregations