/** * Return a collection of all assertions used in the given policy component, * optionally including optional assertions. * The policy need not be normalised, so any policy references will have to be resolved. * @param pc the policy component * @param includeOptional flag indicating if optional assertions should be included * @return the assertions */ Collection<Assertion> getAssertions(PolicyComponent pc, boolean includeOptional) { Collection<Assertion> assertions = new ArrayList<>(); if (Constants.TYPE_ASSERTION == pc.getType()) { Assertion a = (Assertion)pc; if (includeOptional || !a.isOptional()) { assertions.add(a); } } else { addAssertions(pc, includeOptional, assertions); } return assertions; } Collection<Assertion> getAssertions(EffectivePolicy pc, boolean includeOptional) {
/** * Return a collection of all assertions used in the given policy component, * optionally including optional assertions. * The policy need not be normalised, so any policy references will have to be resolved. * @param pc the policy component * @param includeOptional flag indicating if optional assertions should be included * @return the assertions */ Collection<Assertion> getAssertions(PolicyComponent pc, boolean includeOptional) { Collection<Assertion> assertions = new ArrayList<>(); if (Constants.TYPE_ASSERTION == pc.getType()) { Assertion a = (Assertion)pc; if (includeOptional || !a.isOptional()) { assertions.add(a); } } else { addAssertions(pc, includeOptional, assertions); } return assertions; } Collection<Assertion> getAssertions(EffectivePolicy pc, boolean includeOptional) {
Collection<Assertion> getAssertions(EffectivePolicy pc, boolean includeOptional) { if (pc == null || pc.getChosenAlternative() == null) { return null; } Collection<Assertion> assertions = new ArrayList<>(); for (Assertion assertion : pc.getChosenAlternative()) { if (Constants.TYPE_ASSERTION == assertion.getType()) { if (includeOptional || !assertion.isOptional()) { assertions.add(assertion); } } else { addAssertions(assertion, includeOptional, assertions); } } return assertions; }
Collection<Assertion> getAssertions(EffectivePolicy pc, boolean includeOptional) { if (pc == null || pc.getChosenAlternative() == null) { return null; } Collection<Assertion> assertions = new ArrayList<>(); for (Assertion assertion : pc.getChosenAlternative()) { if (Constants.TYPE_ASSERTION == assertion.getType()) { if (includeOptional || !assertion.isOptional()) { assertions.add(assertion); } } else { addAssertions(assertion, includeOptional, assertions); } } return assertions; }
void addAssertions(PolicyComponent pc, boolean includeOptional, Collection<Assertion> assertions) { if (Constants.TYPE_ASSERTION == pc.getType()) { Assertion a = (Assertion)pc; if (includeOptional || !a.isOptional()) { assertions.add((Assertion)pc); } return; } if (Constants.TYPE_POLICY_REF == pc.getType()) { PolicyReference pr = (PolicyReference)pc; pc = pr.normalize(registry, false); } PolicyOperator po = (PolicyOperator)pc; List<PolicyComponent> pcs = CastUtils.cast(po.getPolicyComponents(), PolicyComponent.class); for (PolicyComponent child : pcs) { addAssertions(child, includeOptional, assertions); } }
void addAssertions(PolicyComponent pc, boolean includeOptional, Collection<Assertion> assertions) { if (Constants.TYPE_ASSERTION == pc.getType()) { Assertion a = (Assertion)pc; if (includeOptional || !a.isOptional()) { assertions.add((Assertion)pc); } return; } if (Constants.TYPE_POLICY_REF == pc.getType()) { PolicyReference pr = (PolicyReference)pc; pc = pr.normalize(registry, false); } PolicyOperator po = (PolicyOperator)pc; List<PolicyComponent> pcs = CastUtils.cast(po.getPolicyComponents(), PolicyComponent.class); for (PolicyComponent child : pcs) { addAssertions(child, includeOptional, assertions); } }