Example usage for org.apache.commons.httpclient.protocol ProtocolSocketFactory ProtocolSocketFactory

List of usage examples for org.apache.commons.httpclient.protocol ProtocolSocketFactory ProtocolSocketFactory

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.protocol ProtocolSocketFactory ProtocolSocketFactory.

Prototype

ProtocolSocketFactory

Source Link

Usage

From source file:org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransportTests.java

private ProtocolSocketFactory getSocketFactory() throws Exception {
    final SSLSocketFactory delegate = SSLContext.getDefault().getSocketFactory();
    return new ProtocolSocketFactory() {

        @Override/*from  www  .j  a v a 2  s  .com*/
        public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
                throws IOException, UnknownHostException {
            return delegate.createSocket(host, port, localAddress, localPort);
        }

        @Override
        public Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
                HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
            return this.createSocket(host, port, localAddress, localPort);
        }

        @Override
        public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
            return delegate.createSocket(host, port);
        }
    };
}

From source file:org.mule.module.cxf.AbstractHttpSecurityTestCase.java

private static ProtocolSocketFactory getSocketFactory(final SSLSocketFactory factory) {
    return new ProtocolSocketFactory() {
        private SSLSocketFactory socketFactory = factory;

        public Socket createSocket(String host, int port) throws IOException {
            return socketFactory.createSocket(host, port);
        }//from   ww  w . j  a  va2s.com

        public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
                throws IOException {
            return socketFactory.createSocket(host, port, localAddress, localPort);
        }

        public Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
                HttpConnectionParams params) throws IOException {
            return createSocket(host, port, localAddress, localPort);
        }

    };
}