+ private void createRainydayRule(PolicyType decisionPolicy, String errorcode, String treatment, boolean permitRule) {
+ RuleType rule = new RuleType();
+
+ rule.setRuleId(UUID.randomUUID().toString());
+
+ if (permitRule) {
+ rule.setEffect(EffectType.PERMIT);
+ } else {
+ rule.setEffect(EffectType.DENY);
+ }
+ rule.setTarget(new TargetType());
+
+ // Create Target in Rule
+ AllOfType allOfInRule = new AllOfType();
+
+ // Creating match for ACCESS in rule target
+ MatchType accessMatch = new MatchType();
+ AttributeValueType accessAttributeValue = new AttributeValueType();
+ accessAttributeValue.setDataType(STRING_DATATYPE);
+ accessAttributeValue.getContent().add("DECIDE");
+ accessMatch.setAttributeValue(accessAttributeValue);
+ AttributeDesignatorType accessAttributeDesignator = new AttributeDesignatorType();
+ URI accessURI = null;
+ try {
+ accessURI = new URI(ACTION_ID);
+ } catch (URISyntaxException e) {
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "DecisionPolicy", "Exception creating ACCESS URI");
+ }
+ accessAttributeDesignator.setCategory(CATEGORY_ACTION);
+ accessAttributeDesignator.setDataType(STRING_DATATYPE);
+ accessAttributeDesignator.setAttributeId(new IdentifierImpl(accessURI).stringValue());
+ accessMatch.setAttributeDesignator(accessAttributeDesignator);
+ accessMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
+
+ allOfInRule.getMatch().add(accessMatch);
+
+ // Creating match for ErrorCode in rule target
+ MatchType errorcodeMatch = new MatchType();
+ AttributeValueType errorcodeAttributeValue = new AttributeValueType();
+ errorcodeAttributeValue.setDataType(STRING_DATATYPE);
+ errorcodeAttributeValue.getContent().add(errorcode);
+ errorcodeMatch.setAttributeValue(errorcodeAttributeValue);
+ AttributeDesignatorType errorcodeAttributeDesignator = new AttributeDesignatorType();
+ errorcodeAttributeDesignator.setCategory(CATEGORY_ACTION);
+ errorcodeAttributeDesignator.setDataType(STRING_DATATYPE);
+ errorcodeAttributeDesignator.setAttributeId("ErrorCode");
+ errorcodeMatch.setAttributeDesignator(errorcodeAttributeDesignator);
+ errorcodeMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
+
+ allOfInRule.getMatch().add(errorcodeMatch);
+
+ AnyOfType anyOfInRule = new AnyOfType();
+ anyOfInRule.getAllOf().add(allOfInRule);
+
+ TargetType targetInRule = new TargetType();
+ targetInRule.getAnyOf().add(anyOfInRule);
+
+ rule.setTarget(targetInRule);
+
+ AdviceExpressionsType adviceExpressions = new AdviceExpressionsType();
+ AdviceExpressionType adviceExpression = new AdviceExpressionType();
+ adviceExpression.setAdviceId(RAINY_DAY);
+ adviceExpression.setAppliesTo(EffectType.PERMIT);
+
+ AttributeAssignmentExpressionType assignment = new AttributeAssignmentExpressionType();
+ assignment.setAttributeId("treatment");
+ assignment.setCategory(CATEGORY_RESOURCE);
+
+ AttributeValueType treatmentAttributeValue = new AttributeValueType();
+ treatmentAttributeValue.setDataType(STRING_DATATYPE);
+ treatmentAttributeValue.getContent().add(treatment);
+ assignment.setExpression(new ObjectFactory().createAttributeValue(treatmentAttributeValue));
+
+ adviceExpression.getAttributeAssignmentExpression().add(assignment);
+ adviceExpressions.getAdviceExpression().add(adviceExpression);
+ rule.setAdviceExpressions(adviceExpressions);
+ decisionPolicy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule);
+ policyAdapter.setPolicyData(decisionPolicy);
+
+ }
+