use of org.apache.cxf.transport.http.HTTPConduitConfigurer in project cxf by apache.
the class AsyncHttpTransportFactory method getConduit.
@Override
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target, Bus bus) throws IOException {
// need to updated the endpointInfo
endpointInfo.setAddress(getAddress(endpointInfo));
AsyncHTTPConduitFactory fact = bus.getExtension(AsyncHTTPConduitFactory.class);
if (fact == null) {
fact = factory;
}
HTTPConduit conduit = fact.createConduit(bus, endpointInfo, target);
// Spring configure the conduit.
String address = conduit.getAddress();
if (address != null && address.indexOf('?') != -1) {
address = address.substring(0, address.indexOf('?'));
}
HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.class);
if (c1 != null) {
c1.configure(conduit.getBeanName(), address, conduit);
}
configure(bus, conduit, conduit.getBeanName(), address);
conduit.finalizeConfig();
return conduit;
}
use of org.apache.cxf.transport.http.HTTPConduitConfigurer in project cxf by apache.
the class UsernameTokenTest method testPlaintextWSDLOverHTTPSViaCode.
@org.junit.Test
public void testPlaintextWSDLOverHTTPSViaCode() throws Exception {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
final KeyStore ts = KeyStore.getInstance("JKS");
try (InputStream trustStore = ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", UsernameTokenTest.class)) {
ts.load(trustStore, "password".toCharArray());
}
tmf.init(ts);
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setTrustManagers(tmf.getTrustManagers());
tlsParams.setDisableCNCheck(true);
HTTPConduitConfigurer myHttpConduitConfig = new HTTPConduitConfigurer() {
public void configure(String name, String address, HTTPConduit c) {
if ("{http://cxf.apache.org}TransportURIResolver.http-conduit".equals(name)) {
c.setTlsClientParameters(tlsParams);
}
}
};
BusFactory busFactory = BusFactory.newInstance();
bus = busFactory.createBus();
bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = new URL("https://localhost:" + PORT + "/DoubleItUTPlaintext?wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(utPort);
}
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.ws.common.UTPasswordCallback");
Client client = ClientProxy.getClient(utPort);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.setTlsClientParameters(tlsParams);
assertEquals(50, utPort.doubleIt(25));
((java.io.Closeable) utPort).close();
}
use of org.apache.cxf.transport.http.HTTPConduitConfigurer in project cxf by apache.
the class WebSocketTransportFactory method getConduit.
/**
* {@inheritDoc}
*/
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target, Bus bus) throws IOException {
HTTPConduit conduit = new AhcWebSocketConduit(bus, endpointInfo, target);
String address = conduit.getAddress();
if (address != null && address.indexOf('?') != -1) {
address = address.substring(0, address.indexOf('?'));
}
HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.class);
if (c1 != null) {
c1.configure(conduit.getBeanName(), address, conduit);
}
configure(bus, conduit, conduit.getBeanName(), address);
conduit.finalizeConfig();
return conduit;
}
use of org.apache.cxf.transport.http.HTTPConduitConfigurer in project cxf by apache.
the class OAuth2TestUtils method clientHTTPConduitConfigurer.
public static HTTPConduitConfigurer clientHTTPConduitConfigurer() throws IOException, GeneralSecurityException {
final TLSClientParameters tlsCP = new TLSClientParameters();
tlsCP.setDisableCNCheck(true);
try (InputStream is = OAuth2TestUtils.class.getResourceAsStream("/keys/Morpit.jks")) {
final KeyStore keyStore = CryptoUtils.loadKeyStore(is, "password".toCharArray(), null);
final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, "password".toCharArray());
tlsCP.setKeyManagers(kmf.getKeyManagers());
}
try (InputStream is = OAuth2TestUtils.class.getResourceAsStream("/keys/Truststore.jks")) {
final KeyStore keyStore = CryptoUtils.loadKeyStore(is, "password".toCharArray(), null);
final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
tlsCP.setTrustManagers(tmf.getTrustManagers());
}
return new HTTPConduitConfigurer() {
public void configure(String name, String address, HTTPConduit c) {
c.setTlsClientParameters(tlsCP);
// 5 mins for long debug session
// org.apache.cxf.transports.http.configuration.HTTPClientPolicy httpClientPolicy =
// new org.apache.cxf.transports.http.configuration.HTTPClientPolicy();
// httpClientPolicy.setConnectionTimeout(300000L);
// httpClientPolicy.setReceiveTimeout(300000L);
// c.setClient(httpClientPolicy);
}
};
}
use of org.apache.cxf.transport.http.HTTPConduitConfigurer in project cxf by apache.
the class NettyHttpTransportFactory method getConduit.
@Override
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target, Bus bus) throws IOException {
// need to updated the endpointInfo
endpointInfo.setAddress(getAddress(endpointInfo));
HTTPConduit conduit = factory.createConduit(bus, endpointInfo, target);
// Spring configure the conduit.
String address = conduit.getAddress();
if (address != null && address.indexOf('?') != -1) {
address = address.substring(0, address.indexOf('?'));
}
HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.class);
if (c1 != null) {
c1.configure(conduit.getBeanName(), address, conduit);
}
configure(bus, conduit, conduit.getBeanName(), address);
conduit.finalizeConfig();
return conduit;
}
Aggregations