Search in sources :

Example 1 with PolicyOperator

use of org.apache.neethi.PolicyOperator in project cxf by apache.

the class PolicyEngineImpl method addAssertions.

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);
    }
}
Also used : PolicyComponent(org.apache.neethi.PolicyComponent) PolicyOperator(org.apache.neethi.PolicyOperator) Assertion(org.apache.neethi.Assertion) PolicyReference(org.apache.neethi.PolicyReference)

Example 2 with PolicyOperator

use of org.apache.neethi.PolicyOperator in project cxf by apache.

the class EndpointPolicyImplTest method testUpdatePolicyWithEmptyExactlyOneAndAll.

@Test
public void testUpdatePolicyWithEmptyExactlyOneAndAll() {
    Policy emptyPolicy = new Policy();
    PolicyOperator exactlyOne = new ExactlyOne();
    exactlyOne.addPolicyComponent(new All());
    exactlyOne.addPolicyComponent(new All());
    emptyPolicy.addPolicyComponent(exactlyOne);
    emptyPolicy.addPolicyComponent(new All());
    emptyPolicy.addPolicyComponent(new All());
    doTestUpdateWithEmptyPolicy(emptyPolicy);
}
Also used : Policy(org.apache.neethi.Policy) All(org.apache.neethi.All) PolicyOperator(org.apache.neethi.PolicyOperator) ExactlyOne(org.apache.neethi.ExactlyOne) Test(org.junit.Test)

Aggregations

PolicyOperator (org.apache.neethi.PolicyOperator)2 All (org.apache.neethi.All)1 Assertion (org.apache.neethi.Assertion)1 ExactlyOne (org.apache.neethi.ExactlyOne)1 Policy (org.apache.neethi.Policy)1 PolicyComponent (org.apache.neethi.PolicyComponent)1 PolicyReference (org.apache.neethi.PolicyReference)1 Test (org.junit.Test)1