use of com.evolveum.midpoint.schema.expression.ScriptExpressionProfile in project midpoint by Evolveum.
the class ExpressionProfileCompiler method compileScriptProfile.
private ScriptExpressionProfile compileScriptProfile(ScriptExpressionProfileType scriptType, List<ExpressionPermissionProfile> permissionProfiles) throws SchemaException {
ScriptExpressionProfile profile = new ScriptExpressionProfile(scriptType.getLanguage());
profile.setDecision(AccessDecision.translate(scriptType.getDecision()));
profile.setTypeChecking(scriptType.isTypeChecking());
profile.setPermissionProfile(findPermissionProfile(permissionProfiles, scriptType.getPermissionProfile()));
return profile;
}
use of com.evolveum.midpoint.schema.expression.ScriptExpressionProfile in project midpoint by Evolveum.
the class AbstractScriptTest method getExpressionProfile.
protected ExpressionProfile getExpressionProfile(ScriptExpressionProfile scriptExpressionProfile) {
if (scriptExpressionProfile == null) {
return null;
}
ExpressionProfile expressionProfile = new ExpressionProfile(this.getClass().getSimpleName());
expressionProfile.setDecision(AccessDecision.DENY);
ExpressionEvaluatorProfile evaluatorProfile = new ExpressionEvaluatorProfile(ScriptExpressionEvaluatorFactory.ELEMENT_NAME);
expressionProfile.add(evaluatorProfile);
evaluatorProfile.setDecision(AccessDecision.DENY);
evaluatorProfile.add(scriptExpressionProfile);
return expressionProfile;
}
use of com.evolveum.midpoint.schema.expression.ScriptExpressionProfile in project midpoint by Evolveum.
the class AbstractScriptTest method createScriptExpression.
private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition<?> outputDefinition) {
String language = expressionType.getLanguage();
ScriptExpression expression = new ScriptExpression(scriptExpressionfactory.getEvaluators().get(language), expressionType);
expression.setOutputDefinition(outputDefinition);
expression.setObjectResolver(scriptExpressionfactory.getObjectResolver());
expression.setFunctions(new ArrayList<>(scriptExpressionfactory.getFunctions()));
ScriptExpressionProfile scriptExpressionProfile = getScriptExpressionProfile(language);
expression.setScriptExpressionProfile(scriptExpressionProfile);
expression.setExpressionProfile(getExpressionProfile(scriptExpressionProfile));
return expression;
}
use of com.evolveum.midpoint.schema.expression.ScriptExpressionProfile in project midpoint by Evolveum.
the class TestGroovyExpressionsSandbox method getScriptExpressionProfile.
@Override
protected ScriptExpressionProfile getScriptExpressionProfile(String language) {
ScriptExpressionProfile profile = new ScriptExpressionProfile(language);
profile.setTypeChecking(true);
ExpressionPermissionProfile permissionProfile = new ExpressionPermissionProfile(this.getClass().getSimpleName());
profile.setPermissionProfile(permissionProfile);
permissionProfile.addClassAccessRule(Poison.class, AccessDecision.ALLOW);
permissionProfile.addClassAccessRule(Poison.class, "smell", AccessDecision.DENY);
permissionProfile.addClassAccessRule(Poison.class, "drink", AccessDecision.DENY);
permissionProfile.addClassAccessRule(String.class, AccessDecision.ALLOW);
permissionProfile.addClassAccessRule(String.class, "execute", AccessDecision.DENY);
permissionProfile.addClassAccessRule(List.class, AccessDecision.ALLOW);
permissionProfile.addClassAccessRule(List.class, "execute", AccessDecision.DENY);
permissionProfile.setDecision(AccessDecision.ALLOW);
return profile;
}
use of com.evolveum.midpoint.schema.expression.ScriptExpressionProfile in project midpoint by Evolveum.
the class ScriptExpressionFactory method processScriptExpressionProfile.
private ScriptExpressionProfile processScriptExpressionProfile(ExpressionProfile expressionProfile, String language, String shortDesc) throws SecurityViolationException {
if (expressionProfile == null) {
return null;
}
ExpressionEvaluatorProfile evaluatorProfile = expressionProfile.getEvaluatorProfile(ScriptExpressionEvaluatorFactory.ELEMENT_NAME);
if (evaluatorProfile == null) {
if (expressionProfile.getDecision() == AccessDecision.ALLOW) {
return null;
} else {
throw new SecurityViolationException("Access to script expression evaluator " + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc);
}
}
ScriptExpressionProfile scriptProfile = evaluatorProfile.getScriptExpressionProfile(language);
if (scriptProfile == null) {
if (evaluatorProfile.getDecision() == AccessDecision.ALLOW) {
return null;
} else {
throw new SecurityViolationException("Access to script language " + language + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc);
}
}
return scriptProfile;
}
Aggregations