List of usage examples for javax.net.ssl SSLSocket bind
public void bind(SocketAddress bindpoint) throws IOException
From source file:com.hp.mercury.ci.jenkins.plugins.oo.ssl.FakeSocketFactory.java
@Override public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { // we need to bind explicitly sslsock.bind(localAddress); }/* www .j a v a 2 s .co m*/ sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:com.sos.VirtualFileSystem.HTTP.EasySSLSocketFactory.java
@Override public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { // we need to bind explicitly sslsock.bind(localAddress); }/*from ww w. ja v a 2s. co m*/ sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:securitytools.common.http.TrustingSSLConnectionSocketFactory.java
@Override public Socket connectSocket(int connectTimeout, Socket sock, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException { if (sock == null) { sock = createSocket(context);/*www. j a v a2 s . c o m*/ } SSLSocket sslSocket = null; if (sock instanceof SSLSocket) { sslSocket = (SSLSocket) sock; } else { throw new AssertionError("Unexpected type: " + sock); } if (localAddress != null) { sslSocket.bind(localAddress); } sslSocket.connect(remoteAddress, connectTimeout); return sslSocket; }
From source file:com.lolay.android.security.OpenSSLSocketFactory.java
@Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;// ww w. java2 s .c o m } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:org.thoughtcrime.ssl.pinning.PinningSSLSocketFactory.java
@Override public Socket connectSocket(final Socket sock, final String host, final int port, final InetAddress localAddress, int localPort, final HttpParams params) throws IOException { final SSLSocket sslSock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;//from w w w . j a v a 2s . c om } sslSock.bind(new InetSocketAddress(localAddress, localPort)); } final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); sslSock.connect(remoteAddress, connTimeout); sslSock.setSoTimeout(soTimeout); try { SSLSocketFactory.STRICT_HOSTNAME_VERIFIER.verify(host, sslSock); } catch (IOException iox) { try { sslSock.close(); } catch (Exception ignored) { } throw iox; } return sslSock; }
From source file:com.dvdprime.android.app.http.CustomSSLSocketFactory.java
@Override public Socket connectSocket(Socket socket, String reqHost, int reqPort, InetAddress arg3, int arg4, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(reqHost, reqPort); SSLSocket sslSocket = null; if (socket != null) { sslSocket = (SSLSocket) socket; } else {/*w ww . j a v a2 s . c o m*/ sslSocket = (SSLSocket) createSocket(); } InetSocketAddress inetSocketAddress = new InetSocketAddress(arg3, arg4); sslSocket.bind(inetSocketAddress); sslSocket.connect(remoteAddress, connTimeout); sslSocket.setSoTimeout(soTimeout); return sslSocket; }
From source file:com.manning.androidhacks.hack023.net.SimpleSSLSocketFactory.java
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;//from w ww. j av a2 s .co m } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:pt.hive.cameo.ssl.SSLSocketFactory.java
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslSocket = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;/* w w w .j a v a2 s. c om*/ } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslSocket.bind(isa); } sslSocket.connect(remoteAddress, connTimeout); sslSocket.setSoTimeout(soTimeout); return sslSocket; }
From source file:ucar.httpservices.CustomSSLProtocolSocketFactory.java
public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsocket = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { sslsocket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sslsocket.bind(localAddress); }//from w w w. j a v a 2 s .c o m try { sslsocket.setSoTimeout(soTimeout); sslsocket.connect(remoteAddress, connTimeout); } catch (SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sslsocket; }
From source file:org.akita.io._FakeSSLSocketFactory.java
@Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { if (host == null) { throw new IllegalArgumentException("Target host may not be null."); }/*from ww w . j av a 2 s . co m*/ if (params == null) { throw new IllegalArgumentException("Parameters may not be null."); } SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0; } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress; remoteAddress = new InetSocketAddress(host, port); sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }