Search in sources :

Example 1 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class PolicyUtilsTest method testAssertPolicyNoop.

void testAssertPolicyNoop(boolean isRequestor) {
    PolicyDataEngine pde = new PolicyDataEngineImpl(null);
    Message message = control.createMock(Message.class);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
    control.replay();
    pde.assertMessage(message, null, new ClientPolicyCalculator());
    control.verify();
    control.reset();
    Collection<PolicyAssertion> as = new ArrayList<>();
    AssertionInfoMap aim = new AssertionInfoMap(as);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
    control.replay();
    if (isRequestor) {
        pde.assertMessage(message, null, new ClientPolicyCalculator());
    } else {
        pde.assertMessage(message, null, new ServerPolicyCalculator());
    }
    control.verify();
}
Also used : PolicyAssertion(org.apache.cxf.ws.policy.PolicyAssertion) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) PolicyDataEngineImpl(org.apache.cxf.ws.policy.PolicyDataEngineImpl) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 2 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class AbstractHTTPDestination method calcServerPolicyInternal.

private synchronized HTTPServerPolicy calcServerPolicyInternal(Message m) {
    HTTPServerPolicy sp = serverPolicy;
    if (!serverPolicyCalced) {
        PolicyDataEngine pde = bus.getExtension(PolicyDataEngine.class);
        if (pde != null) {
            sp = pde.getServerEndpointPolicy(m, endpointInfo, this, new ServerPolicyCalculator());
        }
        if (null == sp) {
            sp = endpointInfo.getTraversedExtensor(new HTTPServerPolicy(), HTTPServerPolicy.class);
        }
        serverPolicy = sp;
        serverPolicyCalced = true;
    }
    return sp;
}
Also used : HTTPServerPolicy(org.apache.cxf.transports.http.configuration.HTTPServerPolicy) PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)

Example 3 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class AbstractHTTPDestination method assertMessage.

public void assertMessage(Message message) {
    PolicyDataEngine pde = bus.getExtension(PolicyDataEngine.class);
    pde.assertMessage(message, calcServerPolicy(message), new ServerPolicyCalculator());
}
Also used : PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)

Example 4 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class HTTPConduit method getClient.

public HTTPClientPolicy getClient(Message message) {
    ClientPolicyCalculator cpc = new ClientPolicyCalculator();
    HTTPClientPolicy pol = message.get(HTTPClientPolicy.class);
    updateClientPolicy(message);
    if (pol != null) {
        pol = cpc.intersect(pol, clientSidePolicy);
    } else {
        pol = clientSidePolicy;
    }
    PolicyDataEngine policyDataEngine = bus.getExtension(PolicyDataEngine.class);
    if (policyDataEngine == null) {
        return pol;
    }
    return policyDataEngine.getPolicy(message, pol, cpc);
}
Also used : HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)

Example 5 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class HTTPConduit method updateClientPolicy.

/**
 * updates the HTTPClientPolicy that is compatible with the assertions
 * included in the service, endpoint, operation and message policy subjects
 * if a PolicyDataEngine is installed
 *
 * wsdl extensors are superseded by policies which in
 * turn are superseded by injection
 */
private void updateClientPolicy(Message m) {
    if (!clientSidePolicyCalced) {
        PolicyDataEngine policyEngine = bus.getExtension(PolicyDataEngine.class);
        if (policyEngine != null && endpointInfo.getService() != null) {
            clientSidePolicy = policyEngine.getClientEndpointPolicy(m, endpointInfo, this, new ClientPolicyCalculator());
            if (clientSidePolicy != null) {
                // make sure we aren't added twice
                clientSidePolicy.removePropertyChangeListener(this);
                clientSidePolicy.addPropertyChangeListener(this);
            }
        }
    }
    clientSidePolicyCalced = true;
}
Also used : PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)

Aggregations

PolicyDataEngine (org.apache.cxf.policy.PolicyDataEngine)7 ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)5 ServerPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)3 ArrayList (java.util.ArrayList)2 Message (org.apache.cxf.message.Message)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)2 PolicyAssertion (org.apache.cxf.ws.policy.PolicyAssertion)2 PolicyDataEngineImpl (org.apache.cxf.ws.policy.PolicyDataEngineImpl)2 Exchange (org.apache.cxf.message.Exchange)1 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)1 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)1