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();
}
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;
}
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());
}
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);
}
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;
}
Aggregations