Class SocketFactoryWrapper
java.lang.Object
edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.contrib.ssl.SocketFactoryWrapper
- All Implemented Interfaces:
ProtocolSocketFactory
,SecureProtocolSocketFactory
Author: Mark Claassen
Uses some code from EasySSLProtocolSocketFactory.java
Wraps a SSLSocketFactory with a SecureProtocolSocketFactory.
This was designed to make HttpClient work in situations where an application is being deployed by Java Web Start. In these cases, SSL connections are negotiated by webstart implementations of the KeyManager and TrustManager. Wrapping the socket factory obtained from HttpsURLConnection.getDefaultSocketFactory allows the use of HttpClient while still leveraging Java Web Start's handling of SSL certificates
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateSocket
(String host, int port) Gets a new socket connection to the given host.createSocket
(String host, int port, InetAddress localAddress, int localPort) Gets a new socket connection to the given host.createSocket
(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) Gets a new socket connection to the given host.createSocket
(Socket socket, String host, int port, boolean autoClose) Returns a socket connected to the given host that is layered over an existing socket.
-
Constructor Details
-
SocketFactoryWrapper
-
-
Method Details
-
createSocket
Description copied from interface:ProtocolSocketFactory
Gets a new socket connection to the given host.- Specified by:
createSocket
in interfaceProtocolSocketFactory
- Parameters:
host
- the host name/IPport
- the port on the host- Returns:
- Socket a new socket
- Throws:
IOException
- if an I/O error occurs while creating the socketUnknownHostException
- if the IP address of the host cannot be determined
-
createSocket
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException, UnknownHostException Description copied from interface:ProtocolSocketFactory
Gets a new socket connection to the given host.- Specified by:
createSocket
in interfaceProtocolSocketFactory
- Parameters:
host
- the host name/IPport
- the port on the hostlocalAddress
- the local host name/IP to bind the socket tolocalPort
- the port on the local machine- Returns:
- Socket a new socket
- Throws:
IOException
- if an I/O error occurs while creating the socketUnknownHostException
- if the IP address of the host cannot be determined
-
createSocket
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException Description copied from interface:ProtocolSocketFactory
Gets a new socket connection to the given host.- Specified by:
createSocket
in interfaceProtocolSocketFactory
- Parameters:
host
- the host name/IPport
- the port on the hostlocalAddress
- the local host name/IP to bind the socket tolocalPort
- the port on the local machineparams
-Http connection parameters
- Returns:
- Socket a new socket
- Throws:
IOException
- if an I/O error occurs while creating the socketUnknownHostException
- if the IP address of the host cannot be determinedConnectTimeoutException
- if socket cannot be connected within the given time limit
-
createSocket
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException Description copied from interface:SecureProtocolSocketFactory
Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.- Specified by:
createSocket
in interfaceSecureProtocolSocketFactory
- Parameters:
socket
- the existing sockethost
- the host name/IPport
- the port on the hostautoClose
- a flag for closing the underling socket when the created socket is closed- Returns:
- Socket a new socket
- Throws:
IOException
- if an I/O error occurs while creating the socketUnknownHostException
- if the IP address of the host cannot be determined
-