use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy 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.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HTTPProxyAuthConduitTest method configureProxy.
public void configureProxy(Client client) {
HTTPConduit cond = (HTTPConduit) client.getConduit();
HTTPClientPolicy pol = cond.getClient();
if (pol == null) {
pol = new HTTPClientPolicy();
cond.setClient(pol);
}
pol.setProxyServer("localhost");
pol.setProxyServerPort(PROXY_PORT);
ProxyAuthorizationPolicy auth = new ProxyAuthorizationPolicy();
auth.setUserName("CXF");
auth.setPassword("password");
cond.setProxyAuthorization(auth);
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class JettyDigestAuthTest method setupClient.
private HTTPConduit setupClient(boolean async) throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
BindingProvider bp = (BindingProvider) greeter;
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(greeter).getConduit();
HTTPClientPolicy client = new HTTPClientPolicy();
cond.setClient(client);
if (async) {
if (cond instanceof AsyncHTTPConduit) {
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
bp.getRequestContext().put(Credentials.class.getName(), creds);
bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
client.setAutoRedirect(true);
} else {
fail("Not an async conduit");
}
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
cond.setAuthSupplier(new DigestAuthSupplier());
}
ClientProxy.getClient(greeter).getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.PRE_STREAM_ENDING) {
public void handleMessage(Message message) throws Fault {
Map<String, ?> headers = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
if (headers.containsKey("Proxy-Authorization")) {
throw new RuntimeException("Should not have Proxy-Authorization");
}
}
});
client.setAllowChunking(false);
return cond;
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HTTPProxyConduitTest method configureProxy.
public void configureProxy(Client client) {
HTTPConduit cond = (HTTPConduit) client.getConduit();
HTTPClientPolicy pol = cond.getClient();
if (pol == null) {
pol = new HTTPClientPolicy();
cond.setClient(pol);
}
pol.setProxyServer("localhost");
pol.setProxyServerPort(PROXY_PORT);
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class SignatureWhitespaceTest method testTrailingWhitespaceInSOAPBody.
@org.junit.Test
public void testTrailingWhitespaceInSOAPBody() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SignatureWhitespaceTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SignatureWhitespaceTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSignaturePort2");
Dispatch<StreamSource> dispatch = service.createDispatch(portQName, StreamSource.class, Service.Mode.MESSAGE);
Client client = ((DispatchImpl<StreamSource>) dispatch).getClient();
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
http.setClient(httpClientPolicy);
// Creating a DOMSource Object for the request
URL requestFile = SignatureWhitespaceTest.class.getResource("request-with-trailing-whitespace.xml");
StreamSource request = new StreamSource(new File(requestFile.getPath()));
updateAddressPort(dispatch, test.getPort());
// Make a successful request
StreamSource response = dispatch.invoke(request);
assertNotNull(response);
Document doc = StaxUtils.read(response.getInputStream());
assertEquals("50", doc.getElementsByTagNameNS(null, "doubledNumber").item(0).getTextContent());
((java.io.Closeable) dispatch).close();
}
Aggregations