@Test public void testWithTargetTypeWithAnyOf() throws IOException { AttributeValueType value = new AttributeValueType(); value.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); value.getContent().add(new String("value")); AttributeDesignatorType designator = new AttributeDesignatorType(); designator.setAttributeId("foo:bar"); designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); designator.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION.stringValue()); MatchType match = new MatchType(); match.setMatchId(XACML3.ID_FUNCTION_STRING_EQUAL.stringValue()); match.setAttributeValue(value); match.setAttributeDesignator(designator); AllOfType allOf = new AllOfType(); allOf.getMatch().add(match); AnyOfType anyOf = new AnyOfType(); anyOf.getAllOf().add(allOf); TargetType target = new TargetType(); target.getAnyOf().add(anyOf); RuleType rule = new RuleType(); rule.setRuleId("id:rule"); rule.setEffect(EffectType.PERMIT); AttributeValueType expressionValue = new AttributeValueType(); expressionValue.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); expressionValue.getContent().add(new String("a string value")); designator = new AttributeDesignatorType(); designator.setAttributeId("foo:bar"); designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); designator.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION.stringValue()); ApplyType applyOneAndOnly = new ApplyType(); applyOneAndOnly.setDescription("apply this"); applyOneAndOnly.setFunctionId(XACML3.ID_FUNCTION_STRING_ONE_AND_ONLY.stringValue()); applyOneAndOnly.getExpression().add(new ObjectFactory().createAttributeDesignator(designator)); ApplyType applyOneAndOnly2 = new ApplyType(); applyOneAndOnly2.setDescription("apply this"); applyOneAndOnly2.setFunctionId(XACML3.ID_FUNCTION_STRING_ONE_AND_ONLY.stringValue()); applyOneAndOnly2.getExpression().add(new ObjectFactory().createAttributeValue(expressionValue)); ApplyType apply = new ApplyType(); apply.setDescription("apply this"); apply.setFunctionId(XACML3.ID_FUNCTION_STRING_EQUAL.stringValue()); apply.getExpression().add(new ObjectFactory().createApply(applyOneAndOnly)); apply.getExpression().add(new ObjectFactory().createApply(applyOneAndOnly2)); ConditionType condition = new ConditionType(); condition.setExpression(new ObjectFactory().createApply(apply)); rule.setCondition(condition); AttributeValueType val = new AttributeValueType(); val.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); val.getContent().add(new String("obligation data")); AttributeAssignmentExpressionType assignment = new AttributeAssignmentExpressionType(); assignment.setAttributeId("ob:id:1"); assignment.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue()); assignment.setExpression(new ObjectFactory().createAttributeValue(val)); AttributeValueType val2 = new AttributeValueType(); val2.setDataType(XACML3.ID_DATATYPE_STRING.stringValue()); val2.getContent().add(new String("iamperformer")); AttributeAssignmentExpressionType assignment2 = new AttributeAssignmentExpressionType(); assignment2.setAttributeId("performer"); assignment2.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue()); assignment2.setExpression(new ObjectFactory().createAttributeValue(val2)); ObligationExpressionType ob = new ObligationExpressionType(); ob.setFulfillOn(EffectType.PERMIT); ob.setObligationId("id:obligation"); ob.getAttributeAssignmentExpression().add(assignment); ob.getAttributeAssignmentExpression().add(assignment2); ObligationExpressionsType obs = new ObligationExpressionsType(); obs.getObligationExpression().add(ob); RuleType obligationRule = new RuleType(); obligationRule.setRuleId("id:rule:obligations"); obligationRule.setEffect(EffectType.DENY); obligationRule.setObligationExpressions(obs); PolicyType policy = new PolicyType(); policy.setDescription("i am a description. @CreatedBy: policy designer"); policy.setTarget(target); policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule); policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(obligationRule); policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(new VariableDefinitionType()); PolicyRestAdapter adapter = new PolicyRestAdapter(); adapter.setPolicyData(policy); adapter.setPolicyName("name"); ActionPolicyController controller = new ActionPolicyController(); assertThatCode(() -> controller.prePopulateActionPolicyData(adapter)).doesNotThrowAnyException(); }
public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter) { ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { return; } PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); setPolicyAdapterPolicyNameAndDesc(policyAdapter, policy); TargetType target = policy.getTarget(); if (target == null) { return; } setPolicyAdapterAttributes(policyAdapter, target.getAnyOf()); List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object o : ruleList) { if (!(o instanceof RuleType)) { continue; } setPolicyAdapterRuleAlgorithmschoices(policyAdapter, (RuleType) o); ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions(); setPolicyAdapterActionData(policyAdapter, obligations); } }
ActionPolicyController extends RestrictedBaseController { public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter) { ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { return; } PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); setPolicyAdapterPolicyNameAndDesc(policyAdapter, policy); TargetType target = policy.getTarget(); if (target == null) { return; } setPolicyAdapterAttributes(policyAdapter, target.getAnyOf()); List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object o : ruleList) { if (!(o instanceof RuleType)) { continue; } setPolicyAdapterRuleAlgorithmschoices(policyAdapter, (RuleType) o); ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions(); setPolicyAdapterActionData(policyAdapter, obligations); } } }
ActionPolicyController extends RestrictedBaseController { public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter) { ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { return; } PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); setPolicyAdapterPolicyNameAndDesc(policyAdapter, policy); TargetType target = policy.getTarget(); if (target == null) { return; } setPolicyAdapterAttributes(policyAdapter, target.getAnyOf()); List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object o : ruleList) { if (!(o instanceof RuleType)) { continue; } setPolicyAdapterRuleAlgorithmschoices(policyAdapter, (RuleType) o); ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions(); setPolicyAdapterActionData(policyAdapter, obligations); } } ActionPolicyController(); }
ActionPolicyController extends RestrictedBaseController { public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter) { ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { return; } PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); setPolicyAdapterPolicyNameAndDesc(policyAdapter, policy); TargetType target = policy.getTarget(); if (target == null) { return; } setPolicyAdapterAttributes(policyAdapter, target.getAnyOf()); List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object o : ruleList) { if (!(o instanceof RuleType)) { continue; } setPolicyAdapterRuleAlgorithmschoices(policyAdapter, (RuleType) o); ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions(); setPolicyAdapterActionData(policyAdapter, obligations); } } ActionPolicyController(); void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter); }
ActionPolicyController extends RestrictedBaseController { public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter) { ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { return; } PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); setPolicyAdapterPolicyNameAndDesc(policyAdapter, policy); TargetType target = policy.getTarget(); if (target == null) { return; } setPolicyAdapterAttributes(policyAdapter, target.getAnyOf()); List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object o : ruleList) { if (!(o instanceof RuleType)) { continue; } setPolicyAdapterRuleAlgorithmschoices(policyAdapter, (RuleType) o); ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions(); setPolicyAdapterActionData(policyAdapter, obligations); } } ActionPolicyController(); void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter);  }