Search in sources :

Example 1 with PrimitiveAssertionBuilder

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

the class SHA512PolicyLoader 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, "Basic128RsaSha512");
        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 SHA512AlgorithmSuite(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 2 with PrimitiveAssertionBuilder

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

the class Wsdl11AttachmentPolicyProviderTest method setUp.

@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bus.getExtension(ConfiguredBeanLocator.class);
    EasyMock.expectLastCall().andReturn(null).anyTimes();
    AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
    abr.setIgnoreUnknownAssertions(false);
    PrimitiveAssertionBuilder ab = new PrimitiveAssertionBuilder();
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "A"), ab);
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "B"), ab);
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "C"), ab);
    PolicyBuilderImpl pb = new PolicyBuilderImpl();
    bus.getExtension(PolicyBuilder.class);
    EasyMock.expectLastCall().andReturn(pb).anyTimes();
    bus.getExtension(PolicyEngine.class);
    EasyMock.expectLastCall().andReturn(null).anyTimes();
    pb.setAssertionBuilderRegistry(abr);
    app = new Wsdl11AttachmentPolicyProvider();
    app.setBuilder(pb);
    app.setRegistry(new PolicyRegistryImpl());
    control.replay();
}
Also used : AssertionBuilderRegistry(org.apache.cxf.ws.policy.AssertionBuilderRegistry) Bus(org.apache.cxf.Bus) PolicyBuilderImpl(org.apache.cxf.ws.policy.PolicyBuilderImpl) QName(javax.xml.namespace.QName) PolicyRegistryImpl(org.apache.cxf.ws.policy.PolicyRegistryImpl) PrimitiveAssertionBuilder(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder) AssertionBuilderRegistryImpl(org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl) Before(org.junit.Before)

Example 3 with PrimitiveAssertionBuilder

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

the class PolicyBuilderTest method setUp.

@Before
public void setUp() {
    builder = new PolicyBuilderImpl();
    AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
    builder.setAssertionBuilderRegistry(abr);
    PrimitiveAssertionBuilder ab = new PrimitiveAssertionBuilder();
    abr.registerBuilder(new QName("http://sample.org/Assertions", "A"), ab);
    abr.registerBuilder(new QName("http://sample.org/Assertions", "B"), ab);
    abr.registerBuilder(new QName("http://sample.org/Assertions", "C"), ab);
}
Also used : QName(javax.xml.namespace.QName) PrimitiveAssertionBuilder(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder) Before(org.junit.Before)

Example 4 with PrimitiveAssertionBuilder

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

the class NormalizeTest method createBuilder.

private PolicyBuilderImpl createBuilder(Bus bus) {
    PolicyBuilderImpl builder = new PolicyBuilderImpl();
    builder.setBus(bus);
    AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
    builder.setAssertionBuilderRegistry(abr);
    PrimitiveAssertionBuilder ab = new PrimitiveAssertionBuilder();
    abr.registerBuilder(new QName("http://schemas.xmlsoap.org/ws/2002/12/secext", "SecurityToken"), ab);
    abr.registerBuilder(new QName("http://schemas.xmlsoap.org/ws/2002/12/secext", "SecurityHeader"), ab);
    abr.registerBuilder(new QName("http://schemas.xmlsoap.org/ws/2002/12/secext", "Integrity"), ab);
    abr.registerBuilder(new QName("http://sample.org/Assertions", "A"), ab);
    abr.registerBuilder(new QName("http://sample.org/Assertions", "B"), ab);
    abr.registerBuilder(new QName("http://sample.org/Assertions", "C"), ab);
    return builder;
}
Also used : QName(javax.xml.namespace.QName) PrimitiveAssertionBuilder(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder)

Example 5 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