Skip to content

Commit

Permalink
Adapting backported fix for missing global focus policy rule conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 6, 2017
1 parent e06efed commit 4500ee4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Expand Up @@ -401,9 +401,10 @@ private <F extends FocusType> void processFocusFocus(LensContext<F> context, Str
}

private <F extends FocusType> void evaluateFocusPolicyRules(LensContext<F> context, String activityDescription,
XMLGregorianCalendar now, Task task, OperationResult result) throws PolicyViolationException, SchemaException {
XMLGregorianCalendar now, Task task, OperationResult result)
throws PolicyViolationException, SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
triggerAssignmentFocusPolicyRules(context, activityDescription, now, task, result);
triggerGlobalRules(context);
triggerGlobalRules(context, task, result);
}

// TODO: should we really do this? Focus policy rules (e.g. forbidden modifications) are irrelevant in this situation,
Expand All @@ -423,7 +424,9 @@ private <F extends FocusType> void triggerAssignmentFocusPolicyRules(LensContext
}
}

private <F extends FocusType> void triggerGlobalRules(LensContext<F> context) throws SchemaException, PolicyViolationException {
private <F extends FocusType> void triggerGlobalRules(LensContext<F> context, Task task,
OperationResult result)
throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException {
PrismObject<SystemConfigurationType> systemConfiguration = context.getSystemConfiguration();
if (systemConfiguration == null) {
return;
Expand All @@ -440,8 +443,10 @@ private <F extends FocusType> void triggerGlobalRules(LensContext<F> context) th
for (GlobalPolicyRuleType globalPolicyRule: systemConfiguration.asObjectable().getGlobalPolicyRule()) {
ObjectSelectorType focusSelector = globalPolicyRule.getFocusSelector();
if (cacheRepositoryService.selectorMatches(focusSelector, focus, LOGGER, "Global policy rule "+globalPolicyRule.getName()+": ")) {
EvaluatedPolicyRule evaluatedRule = new EvaluatedPolicyRuleImpl(globalPolicyRule, null);
triggerRule(focusContext, evaluatedRule);
if (policyRuleProcessor.isRuleConditionTrue(globalPolicyRule, focus, null, context, task, result)) {
EvaluatedPolicyRule evaluatedRule = new EvaluatedPolicyRuleImpl(globalPolicyRule, null);
triggerRule(focusContext, evaluatedRule);
}
}
}
}
Expand Down
Expand Up @@ -650,7 +650,7 @@ public <F extends FocusType> void addGlobalPoliciesToAssignments(LensContext<F>
}
}

private <F extends FocusType> boolean isRuleConditionTrue(GlobalPolicyRuleType globalPolicyRule, PrismObject<F> focus,
public <F extends FocusType> boolean isRuleConditionTrue(GlobalPolicyRuleType globalPolicyRule, PrismObject<F> focus,
EvaluatedAssignmentImpl<F> evaluatedAssignment, LensContext<F> context, Task task, OperationResult result)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
MappingType condition = globalPolicyRule.getCondition();
Expand All @@ -668,7 +668,7 @@ private <F extends FocusType> boolean isRuleConditionTrue(GlobalPolicyRuleType g
new PrismPropertyDefinitionImpl<>(CONDITION_OUTPUT_NAME, DOMUtil.XSD_BOOLEAN, prismContext))
.addVariableDefinition(ExpressionConstants.VAR_USER, focusOdo)
.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdo)
.addVariableDefinition(ExpressionConstants.VAR_TARGET, evaluatedAssignment.getTarget())
.addVariableDefinition(ExpressionConstants.VAR_TARGET, evaluatedAssignment != null ? evaluatedAssignment.getTarget() : null)
.addVariableDefinition(ExpressionConstants.VAR_ASSIGNMENT, evaluatedAssignment) // TODO: ok?
.rootNode(focusOdo);

Expand Down

0 comments on commit 4500ee4

Please sign in to comment.