EasySSLProtocolSocketFactorypublic class EasySSLProtocolSocketFactory extends Object implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s
that accept self-signed certificates.
This socket factory SHOULD NOT be used for productive systems
due to security reasons, unless it is a concious decision and
you are perfectly aware of security implications of accepting
self-signed certificates
|
Fields Summary |
---|
private static final Log | LOGLog object for this class. | private static com.sun.net.ssl.SSLContext | SSL_CONTEXT_SINGLETON |
Constructors Summary |
---|
public EasySSLProtocolSocketFactory()Constructor for EasySSLProtocolSocketFactory.
Code sample:
Protocol easyhttps = new Protocol(
"https", new EasySSLProtocolSocketFactory(), 443);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("localhost", 443, easyhttps);
super();
|
Methods Summary |
---|
private static com.sun.net.ssl.SSLContext | createEasySSLContext()
try {
SSLContext context = SSLContext.getInstance("SSL");
context.init(
null,
new TrustManager[] {new EasyX509TrustManager(null)},
null);
return context;
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new HttpClientError(e.toString());
}
| public java.net.Socket | createSocket(java.lang.String host, int port, java.net.InetAddress clientHost, int clientPort)
Socket socket = getEasySSLSocketFactory().createSocket(
host,
port,
clientHost,
clientPort
);
return socket;
| public java.net.Socket | createSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, org.apache.commons.httpclient.params.HttpConnectionParams params)Attempts to get a new socket connection to the given host within the given time limit.
This method employs several techniques to circumvent the limitations of older JREs that
do not support connect timeout. When running in JRE 1.4 or above reflection is used to
call Socket#connect(SocketAddress endpoint, int timeout) method. When executing in older
JREs a controller thread is executed. The controller thread attempts to create a new socket
within the given limit of time. If socket constructor does not return until the timeout
expires, the controller terminates and throws an {@link ConnectTimeoutException}
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
int timeout = params.getConnectionTimeout();
if (timeout == 0) {
return createSocket(host, port, localAddress, localPort);
} else {
// To be eventually deprecated when migrated to Java 1.4 or above
Socket socket = ReflectionSocketFactory.createSocket(
"javax.net.ssl.SSLSocketFactory", host, port, localAddress, localPort, timeout);
if (socket == null) {
socket = ControllerThreadSocketFactory.createSocket(
this, host, port, localAddress, localPort, timeout);
}
return socket;
}
| public java.net.Socket | createSocket(java.lang.String host, int port)
return getEasySSLSocketFactory().createSocket(
host,
port
);
| public java.net.Socket | createSocket(java.net.Socket socket, java.lang.String host, int port, boolean autoClose)
return getEasySSLSocketFactory().createSocket(
socket,
host,
port,
autoClose
);
| public boolean | equals(java.lang.Object obj)
return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class));
| private static javax.net.ssl.SSLSocketFactory | getEasySSLSocketFactory()
if (SSL_CONTEXT_SINGLETON == null) {
SSL_CONTEXT_SINGLETON = createEasySSLContext();
}
return SSL_CONTEXT_SINGLETON.getSocketFactory();
| public int | hashCode()
return EasySSLProtocolSocketFactory.class.hashCode();
|
|