Search in sources :

Example 6 with PrimitiveAssertionBuilder

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

the class DefaultAlgorithmSuiteLoader 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, "Basic128GCM");
        assertions.put(qName, new PrimitiveAssertion(qName));
        qName = new QName(ns, "Basic192GCM");
        assertions.put(qName, new PrimitiveAssertion(qName));
        qName = new QName(ns, "Basic256GCM");
        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)

Example 7 with PrimitiveAssertionBuilder

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

QName (javax.xml.namespace.QName)7 PrimitiveAssertionBuilder (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder)7 AssertionBuilderRegistry (org.apache.cxf.ws.policy.AssertionBuilderRegistry)5 HashMap (java.util.HashMap)4 PrimitiveAssertion (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion)4 Assertion (org.apache.neethi.Assertion)4 AssertionBuilderFactory (org.apache.neethi.AssertionBuilderFactory)4 XMLPrimitiveAssertionBuilder (org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)4 Element (org.w3c.dom.Element)4 AbstractSecurityAssertion (org.apache.wss4j.policy.model.AbstractSecurityAssertion)3 Before (org.junit.Before)2 Bus (org.apache.cxf.Bus)1 AssertionBuilderRegistryImpl (org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl)1 PolicyBuilderImpl (org.apache.cxf.ws.policy.PolicyBuilderImpl)1 PolicyRegistryImpl (org.apache.cxf.ws.policy.PolicyRegistryImpl)1 AlgorithmSuiteBuilder (org.apache.cxf.ws.security.policy.custom.AlgorithmSuiteBuilder)1 AsymmetricBindingBuilder (org.apache.wss4j.policy.builders.AsymmetricBindingBuilder)1 BootstrapPolicyBuilder (org.apache.wss4j.policy.builders.BootstrapPolicyBuilder)1 ContentEncryptedElementsBuilder (org.apache.wss4j.policy.builders.ContentEncryptedElementsBuilder)1 EncryptedElementsBuilder (org.apache.wss4j.policy.builders.EncryptedElementsBuilder)1