Search in sources :

Example 1 with HTTPConduitConfigurer

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) HTTPConduitConfigurer(org.apache.cxf.transport.http.HTTPConduitConfigurer)

Example 2 with HTTPConduitConfigurer

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();
}
Also used : TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) BusFactory(org.apache.cxf.BusFactory) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) KeyStore(java.security.KeyStore) URL(java.net.URL) HTTPConduitConfigurer(org.apache.cxf.transport.http.HTTPConduitConfigurer) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) Client(org.apache.cxf.endpoint.Client)

Example 3 with HTTPConduitConfigurer

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AhcWebSocketConduit(org.apache.cxf.transport.websocket.ahc.AhcWebSocketConduit) HTTPConduitConfigurer(org.apache.cxf.transport.http.HTTPConduitConfigurer)

Example 4 with HTTPConduitConfigurer

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);
        }
    };
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) InputStream(java.io.InputStream) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) KeyStore(java.security.KeyStore) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) HTTPConduitConfigurer(org.apache.cxf.transport.http.HTTPConduitConfigurer)

Example 5 with HTTPConduitConfigurer

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) HTTPConduitConfigurer(org.apache.cxf.transport.http.HTTPConduitConfigurer)

Aggregations

HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)6 HTTPConduitConfigurer (org.apache.cxf.transport.http.HTTPConduitConfigurer)6 InputStream (java.io.InputStream)2 KeyStore (java.security.KeyStore)2 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)2 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)2 URL (java.net.URL)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 BusFactory (org.apache.cxf.BusFactory)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 Client (org.apache.cxf.endpoint.Client)1 AhcWebSocketConduit (org.apache.cxf.transport.websocket.ahc.AhcWebSocketConduit)1 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)1