Search in sources :

Example 21 with PrimitiveAssertion

use of org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion 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)

Example 22 with PrimitiveAssertion

use of org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion in project cxf by apache.

the class MGF256AlgorithmSuiteLoader method getAlgorithmSuite.

public AlgorithmSuite getAlgorithmSuite(Bus bus, SPConstants.SPVersion version, Policy nestedPolicy) {
    AssertionBuilderRegistry reg = bus.getExtension(AssertionBuilderRegistry.class);
    if (reg != null) {
        String ns = "http://cxf.apache.org/custom/security-policy";
        final Map<QName, Assertion> assertions = new HashMap<>();
        QName qName = new QName(ns, "Basic256GCMMGFSHA256");
        assertions.put(qName, new PrimitiveAssertion(qName));
        reg.registerBuilder(new PrimitiveAssertionBuilder(assertions.keySet()) {

            public Assertion build(Element element, AssertionBuilderFactory fact) {
                if (XMLPrimitiveAssertionBuilder.isOptional(element) || XMLPrimitiveAssertionBuilder.isIgnorable(element)) {
                    return super.build(element, fact);
                }
                QName q = new QName(element.getNamespaceURI(), element.getLocalName());
                return assertions.get(q);
            }
        });
    }
    return new GCMAlgorithmSuite(version, nestedPolicy);
}
Also used : AssertionBuilderRegistry(org.apache.cxf.ws.policy.AssertionBuilderRegistry) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Element(org.w3c.dom.Element) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) Assertion(org.apache.neethi.Assertion) AbstractSecurityAssertion(org.apache.wss4j.policy.model.AbstractSecurityAssertion) AssertionBuilderFactory(org.apache.neethi.AssertionBuilderFactory) PrimitiveAssertionBuilder(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder) XMLPrimitiveAssertionBuilder(org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)

Aggregations

PrimitiveAssertion (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion)22 QName (javax.xml.namespace.QName)15 Assertion (org.apache.neethi.Assertion)15 Policy (org.apache.neethi.Policy)10 All (org.apache.neethi.All)6 ExactlyOne (org.apache.neethi.ExactlyOne)6 XMLPrimitiveAssertionBuilder (org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)6 Element (org.w3c.dom.Element)6 PolicyContainingPrimitiveAssertion (org.apache.neethi.builders.PolicyContainingPrimitiveAssertion)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 AssertionBuilderRegistry (org.apache.cxf.ws.policy.AssertionBuilderRegistry)4 PrimitiveAssertionBuilder (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder)4 AssertionBuilderFactory (org.apache.neethi.AssertionBuilderFactory)4 ArrayList (java.util.ArrayList)3 AbstractSecurityAssertion (org.apache.wss4j.policy.model.AbstractSecurityAssertion)3 DefaultSymmetricBinding (org.apache.cxf.ws.security.trust.DefaultSymmetricBinding)2 ProtectionToken (org.apache.wss4j.policy.model.ProtectionToken)2 SignedParts (org.apache.wss4j.policy.model.SignedParts)2 URL (java.net.URL)1