Search in sources :

Example 1 with XMLPrimitiveAssertionBuilder

use of org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder in project cxf by apache.

the class AssertionBuilderRegistryImpl method handleNoRegisteredBuilder.

protected AssertionBuilder<?> handleNoRegisteredBuilder(QName qname) {
    if (ignoreUnknownAssertions) {
        boolean alreadyWarned = ignored.contains(qname);
        if (!alreadyWarned) {
            ignored.add(qname);
            Message m = new Message("NO_ASSERTIONBUILDER_EXC", BUNDLE, qname.toString());
            LOG.warning(m.toString());
        }
        return new XMLPrimitiveAssertionBuilder();
    }
    Message m = new Message("NO_ASSERTIONBUILDER_EXC", BUNDLE, qname.toString());
    throw new PolicyException(m);
}
Also used : Message(org.apache.cxf.common.i18n.Message) XMLPrimitiveAssertionBuilder(org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)

Example 2 with XMLPrimitiveAssertionBuilder

use of org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder in project cxf by apache.

the class AddressingAssertionBuilder method build.

public Assertion build(Element elem, AssertionBuilderFactory factory) {
    String localName = elem.getLocalName();
    QName qn = new QName(elem.getNamespaceURI(), localName);
    boolean optional = false;
    Attr attribute = PolicyConstants.findOptionalAttribute(elem);
    if (attribute != null) {
        optional = Boolean.valueOf(attribute.getValue());
    }
    if (MetadataConstants.ADDRESSING_ASSERTION_QNAME.equals(qn) || MetadataConstants.ADDRESSING_ASSERTION_QNAME_0705.equals(qn)) {
        Assertion nap = new XMLPrimitiveAssertionBuilder() {

            public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
                return new PrimitiveAssertion(MetadataConstants.ADDRESSING_ASSERTION_QNAME, isOptional(element), isIgnorable(element), mp);
            }

            public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
                return new PolicyContainingPrimitiveAssertion(MetadataConstants.ADDRESSING_ASSERTION_QNAME, isOptional(element), isIgnorable(element), mp, policy);
            }
        }.build(elem, factory);
        if (!(nap instanceof PolicyContainingPrimitiveAssertion || nap instanceof org.apache.neethi.builders.PrimitiveAssertion)) {
            // this happens when neethi fails to recognize the specified addressing policy element
            LOG.warning("Unable to recognize the addressing policy");
        }
        return nap;
    } else if (MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME.equals(qn) || MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME_0705.equals(qn)) {
        return new PrimitiveAssertion(MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME, optional);
    } else if (MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME.getLocalPart().equals(localName) || MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME_0705.getLocalPart().equals(localName)) {
        return new PrimitiveAssertion(MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME, optional);
    }
    return null;
}
Also used : Policy(org.apache.neethi.Policy) QName(javax.xml.namespace.QName) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Element(org.w3c.dom.Element) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Assertion(org.apache.neethi.Assertion) Attr(org.w3c.dom.Attr) XMLPrimitiveAssertionBuilder(org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion)

Example 3 with XMLPrimitiveAssertionBuilder

use of org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder in project cxf by apache.

the class RM12AssertionBuilder method build.

/**
 * @see org.apache.neethi.builders.AssertionBuilder#build(org.w3c.dom.Element,
 *  org.apache.neethi.AssertionBuilderFactory)
 */
public Assertion build(Element elem, AssertionBuilderFactory factory) throws IllegalArgumentException {
    Assertion assertion = null;
    if (RM11Constants.WSRMP_NAMESPACE_URI.equals(elem.getNamespaceURI())) {
        boolean optional = XMLPrimitiveAssertionBuilder.isOptional(elem);
        String lname = elem.getLocalName();
        if (RMConstants.RMASSERTION_NAME.equals(lname)) {
            // top-level RMAssertion, with nested policy
            XMLPrimitiveAssertionBuilder nesting = new XMLPrimitiveAssertionBuilder() {

                public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
                    return new PrimitiveAssertion(RM11Constants.WSRMP_RMASSERTION_QNAME, isOptional(element), isIgnorable(element), mp);
                }

                public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
                    return new PolicyContainingPrimitiveAssertion(RM11Constants.WSRMP_RMASSERTION_QNAME, isOptional(element), isIgnorable(element), mp, policy);
                }
            };
            assertion = nesting.build(elem, factory);
        } else if (SEQUENCESTR_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(SEQSTR_QNAME, optional);
        } else if (SEQUENCETRANSEC_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(SEQTRANSSEC_QNAME, optional);
        } else if (DELIVERYASSURANCE_NAME.equals(lname)) {
            // DeliveryAssurance, with nested policy
            XMLPrimitiveAssertionBuilder nesting = new XMLPrimitiveAssertionBuilder() {

                public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
                    return new PrimitiveAssertion(DELIVERYASSURANCE_QNAME, isOptional(element), isIgnorable(element), mp);
                }

                public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
                    return new PolicyContainingPrimitiveAssertion(DELIVERYASSURANCE_QNAME, isOptional(element), isIgnorable(element), mp, policy);
                }
            };
            assertion = nesting.build(elem, factory);
        } else if (EXACTLYONCE_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(EXACTLYONCE_QNAME, optional);
        } else if (ATLEASTONCE_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(ATLEASTONCE_QNAME, optional);
        } else if (ATMOSTONCE_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(ATMOSTONCE_QNAME, optional);
        } else if (INORDER_NAME.equals(lname)) {
            assertion = new PrimitiveAssertion(INORDER_QNAME, optional);
        }
    }
    return assertion;
}
Also used : Policy(org.apache.neethi.Policy) XMLPrimitiveAssertionBuilder(org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PolicyContainingPrimitiveAssertion(org.apache.neethi.builders.PolicyContainingPrimitiveAssertion) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Assertion(org.apache.neethi.Assertion) Map(java.util.Map)

Aggregations

XMLPrimitiveAssertionBuilder (org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)3 QName (javax.xml.namespace.QName)2 PrimitiveAssertion (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion)2 Assertion (org.apache.neethi.Assertion)2 Policy (org.apache.neethi.Policy)2 PolicyContainingPrimitiveAssertion (org.apache.neethi.builders.PolicyContainingPrimitiveAssertion)2 Element (org.w3c.dom.Element)2 Map (java.util.Map)1 Message (org.apache.cxf.common.i18n.Message)1 Attr (org.w3c.dom.Attr)1