Search in sources :

Example 31 with Policy

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

/**
 * The effective policy for a specific WSDL message (input or output) is calculated
 * in relation to a specific port, and includes the element policy of the wsdl:message
 * element that defines the message's type merged with the element policy of the
 * wsdl11:binding and wsdl11:portType message definitions that describe the message.
 * For example, the effective policy of a specific input message for a specific port
 * would be the (element policies of the) wsdl11:message element defining the message type,
 * the wsdl11:portType/wsdl11:operation/wsdl11:input element and the corresponding
 * wsdl11:binding/wsdl11:operation/wsdl11:input element for that message.
 *
 * @param bmi the BindingMessageInfo identifiying the message
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) {
    ServiceInfo si = bmi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bmi, false, di);
    MessageInfo mi = bmi.getMessageInfo();
    p = mergePolicies(p, getElementPolicy(mi, true, di));
    Extensible ex = getMessageTypeInfo(mi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 32 with Policy

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

the class Wsdl11AttachmentPolicyProvider method resolveReference.

Policy resolveReference(PolicyReference ref, DescriptionInfo di) {
    Policy p = null;
    if (isExternal(ref)) {
        String uri = di.getBaseURI();
        if (uri == null) {
            uri = Integer.toString(di.hashCode());
        }
        p = resolveExternal(ref, uri);
    } else {
        p = resolveLocal(ref, di);
    }
    checkResolved(ref, p);
    return p;
}
Also used : Policy(org.apache.neethi.Policy)

Example 33 with Policy

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

/**
 * The effective policy for a WSDL operation policy subject is calculated in relation to a
 * specific port, and includes the element policy of the wsdl11:portType/wsdl11:operation
 * element that defines the operation merged with that of the corresponding
 * wsdl11:binding/wsdl11:operation element.
 *
 * @param bi the BindingOperationInfo identifying the operation in relation to a port
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingOperationInfo bi, Message m) {
    DescriptionInfo di = bi.getBinding().getDescription();
    Policy p = getElementPolicy(bi, false, di);
    p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di));
    return p;
}
Also used : Policy(org.apache.neethi.Policy) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 34 with Policy

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
    ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bfi, false, di);
    FaultInfo fi = bfi.getFaultInfo();
    p = mergePolicies(p, getElementPolicy(fi, true, di));
    Extensible ex = getMessageTypeInfo(fi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 35 with Policy

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

the class AssertionInfoMapTest method testCheckEffectivePolicy.

@Test
public void testCheckEffectivePolicy() {
    Policy p = new Policy();
    QName aqn = new QName("http://x.y.z", "a");
    Assertion a = new PrimitiveAssertion(aqn);
    QName bqn = new QName("http://x.y.z", "b");
    Assertion b = new PrimitiveAssertion(bqn);
    QName cqn = new QName("http://x.y.z", "c");
    Assertion c = new PrimitiveAssertion(cqn);
    All alt1 = new All();
    alt1.addAssertion(a);
    alt1.addAssertion(b);
    All alt2 = new All();
    alt2.addAssertion(c);
    ExactlyOne ea = new ExactlyOne();
    ea.addPolicyComponent(alt1);
    ea.addPolicyComponent(alt2);
    p.addPolicyComponent(ea);
    AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class));
    AssertionInfo ai = new AssertionInfo(a);
    AssertionInfo bi = new AssertionInfo(b);
    AssertionInfo ci = new AssertionInfo(c);
    aim.put(aqn, Collections.singleton(ai));
    aim.put(bqn, Collections.singleton(bi));
    aim.put(cqn, Collections.singleton(ci));
    try {
        aim.checkEffectivePolicy(p);
        fail("Expected PolicyException not thrown.");
    } catch (PolicyException ex) {
    // expected
    }
    ai.setAsserted(true);
    ci.setAsserted(true);
    aim.checkEffectivePolicy(p);
}
Also used : Policy(org.apache.neethi.Policy) All(org.apache.neethi.All) QName(javax.xml.namespace.QName) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Assertion(org.apache.neethi.Assertion) ExactlyOne(org.apache.neethi.ExactlyOne) Test(org.junit.Test)

Aggregations

Policy (org.apache.neethi.Policy)122 Test (org.junit.Test)47 Assertion (org.apache.neethi.Assertion)27 QName (javax.xml.namespace.QName)23 ArrayList (java.util.ArrayList)21 All (org.apache.neethi.All)18 ExactlyOne (org.apache.neethi.ExactlyOne)18 Message (org.apache.cxf.message.Message)15 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)14 Element (org.w3c.dom.Element)13 Bus (org.apache.cxf.Bus)12 PrimitiveAssertion (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion)12 List (java.util.List)9 Interceptor (org.apache.cxf.interceptor.Interceptor)9 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)9 HashMap (java.util.HashMap)7 OMElement (org.apache.axiom.om.OMElement)7 MessageImpl (org.apache.cxf.message.MessageImpl)7 ReferenceResolver (org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver)6 InputStream (java.io.InputStream)5