Search in sources :

Example 1 with AssertionBuilderRegistry

use of org.apache.cxf.ws.policy.AssertionBuilderRegistry in project OpenAM by OpenRock.

the class SoapSTSConsumer method addAMSessionTokenSupport.

/**
     * This method registers the AMSessionToken AssertionBuilder and InterceptorProvider required to consume a sts instance
     * protected by a SecurityPolicy binding specifying OpenAMToken Assertions.
     */
private void addAMSessionTokenSupport() {
    PolicyInterceptorProviderRegistry pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class);
    pipr.register(new OpenAMSessionTokenClientInterceptorProvider());
    AssertionBuilderRegistry abr = bus.getExtension(AssertionBuilderRegistry.class);
    abr.setIgnoreUnknownAssertions(false);
    abr.registerBuilder(AMSTSConstants.AM_SESSION_TOKEN_ASSERTION_QNAME, new OpenAMSessionTokenClientAssertionBuilder(callbackHander));
}
Also used : AssertionBuilderRegistry(org.apache.cxf.ws.policy.AssertionBuilderRegistry) PolicyInterceptorProviderRegistry(org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry) OpenAMSessionTokenClientInterceptorProvider(org.forgerock.openam.sts.soap.policy.am.OpenAMSessionTokenClientInterceptorProvider) OpenAMSessionTokenClientAssertionBuilder(org.forgerock.openam.sts.soap.policy.am.OpenAMSessionTokenClientAssertionBuilder)

Example 2 with AssertionBuilderRegistry

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

use of org.apache.cxf.ws.policy.AssertionBuilderRegistry in project cxf by apache.

the class WSRMP12PolicyLoader method registerBuilders.

public void registerBuilders() {
    AssertionBuilderRegistry reg = bus.getExtension(AssertionBuilderRegistry.class);
    if (reg == null) {
        return;
    }
    reg.registerBuilder(new RM12AssertionBuilder());
}
Also used : AssertionBuilderRegistry(org.apache.cxf.ws.policy.AssertionBuilderRegistry)

Example 4 with AssertionBuilderRegistry

use of org.apache.cxf.ws.policy.AssertionBuilderRegistry 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 5 with AssertionBuilderRegistry

use of org.apache.cxf.ws.policy.AssertionBuilderRegistry in project OpenAM by OpenRock.

the class SoapSTSLifecycleImpl method registerCustomPolicyInterceptors.

/*
    This method will register the OpenAMSessionToken AssertionBuilder and InterceptorProvider instances with the cxf
    Bus, so that any OpenAMSessionToken SecurityPolicy bindings in any of the published soap-sts instances can be
    supported. Note that this registration is global to all soap-sts instances published in this realm, as the AssertionBuilderRegistry
    and the PolicyInterceptorProviderRegistry are global to a cxf Bus, and thus to a cxf deployment. This does not cause
    problems however, as the OpenAM session validation which is consumed as part of realizing this interceptor context
    is specific only to a realm, and each soap-sts deployment is realm specific (as it corresponds to a soap-sts-agent,
    which is also realm-specific.) Note, however, if we wanted to support OpenID Connect ID tokens, then a global
    interceptor would have to be registered which would ultimately consult sts-instance-specific state corresponding to the
    authN context which would validate this OIDC id token, and the key used to look-up this instance-specific
    state from the global interceptor would be the last url constituent of the soap-sts invocation (including any realm
    elements), as this is the soap-sts-instance identifier.
     */
private void registerCustomPolicyInterceptors() {
    final boolean createIfNecessary = false;
    final Bus bus = BusFactory.getDefaultBus(createIfNecessary);
    final PolicyInterceptorProviderRegistry policyInterceptorProviderRegistry = bus.getExtension(PolicyInterceptorProviderRegistry.class);
    policyInterceptorProviderRegistry.register(openAMSessionTokenServerInterceptorProvider);
    AssertionBuilderRegistry assertionBuilderRegistry = bus.getExtension(AssertionBuilderRegistry.class);
    assertionBuilderRegistry.registerBuilder(AMSTSConstants.AM_SESSION_TOKEN_ASSERTION_QNAME, new OpenAMSessionTokenServerAssertionBuilder());
}
Also used : AssertionBuilderRegistry(org.apache.cxf.ws.policy.AssertionBuilderRegistry) Bus(org.apache.cxf.Bus) OpenAMSessionTokenServerAssertionBuilder(org.forgerock.openam.sts.soap.policy.am.OpenAMSessionTokenServerAssertionBuilder) PolicyInterceptorProviderRegistry(org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry)

Aggregations

AssertionBuilderRegistry (org.apache.cxf.ws.policy.AssertionBuilderRegistry)10 QName (javax.xml.namespace.QName)5 PrimitiveAssertionBuilder (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder)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 Bus (org.apache.cxf.Bus)2 PolicyInterceptorProviderRegistry (org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry)2 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