com.xebialabs.deployit.cli.ssl
Class SelfSignedCertificateAcceptingSocketFactory
java.lang.Object
com.xebialabs.deployit.cli.ssl.SelfSignedCertificateAcceptingSocketFactory
- All Implemented Interfaces:
- org.apache.commons.httpclient.protocol.ProtocolSocketFactory, org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
public class SelfSignedCertificateAcceptingSocketFactory
- extends java.lang.Object
- implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
jvanerp: Copied into Deployit CLI to support self-signed certificates, and renamed to SelfSignedCertificateAcceptingSocketFactory.
Original documentation below:
EasySSLProtocolSocketFactory can be used to creats SSL Sockets
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
Example of using custom protocol socket factory for a specific host:
Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
URI uri = new URI("https://localhost/", true);
// use relative url only
GetMethod httpget = new GetMethod(uri.getPathQuery());
HostConfiguration hc = new HostConfiguration();
hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
HttpClient client = new HttpClient();
client.executeMethod(hc, httpget);
Example of using custom protocol socket factory per default instead of the standard one:
Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
Protocol.registerProtocol("https", easyhttps);
HttpClient client = new HttpClient();
GetMethod httpget = new GetMethod("https://localhost/");
client.executeMethod(httpget);
|
Method Summary |
java.net.Socket |
createSocket(java.net.Socket socket,
java.lang.String host,
int port,
boolean autoClose)
|
java.net.Socket |
createSocket(java.lang.String host,
int port)
|
java.net.Socket |
createSocket(java.lang.String host,
int port,
java.net.InetAddress localHost,
int localPort)
|
java.net.Socket |
createSocket(java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
org.apache.commons.httpclient.params.HttpConnectionParams params)
|
boolean |
equals(java.lang.Object obj)
|
int |
hashCode()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
SelfSignedCertificateAcceptingSocketFactory
public SelfSignedCertificateAcceptingSocketFactory()
createSocket
public java.net.Socket createSocket(java.lang.String host,
int port,
java.net.InetAddress localHost,
int localPort)
throws java.io.IOException
- Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
- Throws:
java.io.IOException
createSocket
public java.net.Socket createSocket(java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
org.apache.commons.httpclient.params.HttpConnectionParams params)
throws java.io.IOException
- Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
- Throws:
java.io.IOException
createSocket
public java.net.Socket createSocket(java.lang.String host,
int port)
throws java.io.IOException
- Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
- Throws:
java.io.IOException
createSocket
public java.net.Socket createSocket(java.net.Socket socket,
java.lang.String host,
int port,
boolean autoClose)
throws java.io.IOException
- Specified by:
createSocket in interface org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory
- Throws:
java.io.IOException
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals in class java.lang.Object
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object