use of org.apache.cxf.transport.http.HTTPConduit in project cxf by apache.
the class JAXRSClientFactoryBeanTest method testGetConduit.
@Test
public void testGetConduit() throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress("http://bar");
bean.setResourceClass(BookStore.class);
BookStore store = bean.create(BookStore.class);
Conduit conduit = WebClient.getConfig(store).getConduit();
assertTrue(conduit instanceof HTTPConduit);
}
use of org.apache.cxf.transport.http.HTTPConduit in project cxf by apache.
the class ClientNonSpring method setupTLS.
private static void setupTLS(Greeter port) throws IOException, GeneralSecurityException {
final TLSClientParameters tlsCP = new TLSClientParameters();
tlsCP.setDisableCNCheck(true);
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
try (InputStream is = new FileInputStream("src/main/config/clientKeystore.jks")) {
keyStore.load(is, "cspass".toCharArray());
}
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, "ckpass".toCharArray());
tlsCP.setKeyManagers(kmf.getKeyManagers());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
tlsCP.setTrustManagers(tmf.getTrustManagers());
((HTTPConduit) ClientProxy.getClient(port).getConduit()).setTlsClientParameters(tlsCP);
}
use of org.apache.cxf.transport.http.HTTPConduit in project cxf by apache.
the class AbstractSTSClient method createClient.
protected void createClient() throws BusException, EndpointException {
if (client != null) {
return;
}
if (wsdlLocation != null) {
WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
SourceDataBinding dataBinding = new SourceDataBinding();
factory.setDataBinding(dataBinding);
Service service = factory.create();
service.setDataBinding(dataBinding);
EndpointInfo ei = service.getEndpointInfo(endpointName);
Endpoint endpoint = new EndpointImpl(bus, service, ei);
client = new ClientImpl(bus, endpoint);
} else if (location != null) {
Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion, policy, endpointName);
client = new ClientImpl(bus, endpoint);
} else {
throw new TrustException(LOG, "NO_LOCATION");
}
client.getInFaultInterceptors().addAll(inFault);
client.getInInterceptors().addAll(in);
client.getOutInterceptors().addAll(out);
client.getOutFaultInterceptors().addAll(outFault);
if (tlsClientParameters != null) {
HTTPConduit http = (HTTPConduit) client.getConduit();
http.setTlsClientParameters(tlsClientParameters);
}
in = null;
out = null;
inFault = null;
outFault = null;
if (features != null) {
for (Feature f : features) {
f.initialize(client, bus);
}
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project cxf by apache.
the class CXF6655Test method testConnectionWithProxy.
@Test
public void testConnectionWithProxy() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService");
HelloService service = new HelloService(null, serviceName);
assertNotNull(service);
Hello hello = service.getHelloPort();
Client client = ClientProxy.getClient(hello);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(0);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
httpClientPolicy.setProxyServer("localhost");
httpClientPolicy.setProxyServerPort(PROXY_PORT);
http.setClient(httpClientPolicy);
((BindingProvider) hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello");
assertEquals("getSayHi", hello.sayHi("SayHi"));
}
use of org.apache.cxf.transport.http.HTTPConduit in project cxf by apache.
the class InterceptorFaultTest method setupGreeter.
private void setupGreeter(String cfgResource, boolean useDecoupledEndpoint) throws NumberFormatException, MalformedURLException {
SpringBusFactory bf = new SpringBusFactory();
controlBus = bf.createBus();
BusFactory.setDefaultBus(controlBus);
ControlService cs = new ControlService();
control = cs.getControlPort();
updateAddressPort(control, PORT);
assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
greeterBus = bf.createBus(cfgResource);
BusFactory.setDefaultBus(greeterBus);
LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
if (null == comparator) {
comparator = new PhaseComparator();
}
if (null == inPhases) {
inPhases = new ArrayList<>();
inPhases.addAll(greeterBus.getExtension(PhaseManager.class).getInPhases());
Collections.sort(inPhases, comparator);
}
if (null == postUnMarshalPhase) {
postUnMarshalPhase = getPhase(Phase.POST_UNMARSHAL);
}
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
if (!useDecoupledEndpoint) {
return;
}
// programatically configure decoupled endpoint that is guaranteed to
// be unique across all test cases
decoupledEndpointPort++;
decoupledEndpoint = "http://localhost:" + allocatePort("decoupled-" + decoupledEndpointPort) + "/decoupled_endpoint";
Client c = ClientProxy.getClient(greeter);
HTTPConduit hc = (HTTPConduit) (c.getConduit());
HTTPClientPolicy cp = hc.getClient();
cp.setDecoupledEndpoint(decoupledEndpoint);
LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
}
Aggregations