public class SocketFactoryWrapper extends Object implements SecureProtocolSocketFactory
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 and Description |
|---|
SocketFactoryWrapper(SSLSocketFactory socketFactory) |
| Modifier and Type | Method and Description |
|---|---|
Socket |
createSocket(Socket socket,
String host,
int port,
boolean autoClose)
Returns a socket connected to the given host that is layered over an
existing socket.
|
Socket |
createSocket(String host,
int port)
Gets a new socket connection to the given host.
|
Socket |
createSocket(String host,
int port,
InetAddress localAddress,
int localPort)
Gets a new socket connection to the given host.
|
Socket |
createSocket(String host,
int port,
InetAddress localAddress,
int localPort,
HttpConnectionParams params)
Gets a new socket connection to the given host.
|
public SocketFactoryWrapper(SSLSocketFactory socketFactory)
public Socket createSocket(String host, int port) throws IOException, UnknownHostException
ProtocolSocketFactorycreateSocket in interface ProtocolSocketFactoryhost - the host name/IPport - the port on the hostIOException - if an I/O error occurs while creating the socketUnknownHostException - if the IP address of the host cannot be
determinedpublic Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException, UnknownHostException
ProtocolSocketFactorycreateSocket in interface ProtocolSocketFactoryhost - the host name/IPport - the port on the hostlocalAddress - the local host name/IP to bind the socket tolocalPort - the port on the local machineIOException - if an I/O error occurs while creating the socketUnknownHostException - if the IP address of the host cannot be
determinedpublic Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException
ProtocolSocketFactorycreateSocket in interface ProtocolSocketFactoryhost - 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 parametersIOException - 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 limitpublic Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException
SecureProtocolSocketFactorycreateSocket in interface SecureProtocolSocketFactorysocket - the existing sockethost - the host name/IPport - the port on the hostautoClose - a flag for closing the underling socket when the created
socket is closedIOException - if an I/O error occurs while creating the socketUnknownHostException - if the IP address of the host cannot be
determinedCopyright © 2012 Apache Software Foundation. All Rights Reserved.