Package org.htmlunit.httpclient
Class HtmlUnitSSLConnectionSocketFactory
- java.lang.Object
-
- org.apache.http.conn.ssl.SSLConnectionSocketFactory
-
- org.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory
-
- All Implemented Interfaces:
org.apache.http.conn.socket.ConnectionSocketFactory,org.apache.http.conn.socket.LayeredConnectionSocketFactory
public final class HtmlUnitSSLConnectionSocketFactory extends org.apache.http.conn.ssl.SSLConnectionSocketFactorySocket factory offering facilities for insecure SSL and for SOCKS proxy support. This looks rather like a hack than like clean code but at the time of the writing it seems to be the easiest way to provide SOCKS proxy support for HTTPS.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringSSL3ONLYprivate booleanuseInsecureSSL_
-
Constructor Summary
Constructors Modifier Constructor Description privateHtmlUnitSSLConnectionSocketFactory(java.security.KeyStore keystore, char[] keystorePassword, java.security.KeyStore truststore, boolean useInsecureSSL, java.lang.String[] supportedProtocols, java.lang.String[] supportedCipherSuites)privateHtmlUnitSSLConnectionSocketFactory(javax.net.ssl.SSLContext sslContext, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean useInsecureSSL, java.lang.String[] supportedProtocols, java.lang.String[] supportedCipherSuites)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.http.conn.ssl.SSLConnectionSocketFactorybuildSSLSocketFactory(WebClientOptions options)Factory method that builds a new SSLConnectionSocketFactory.private static voidconfigureSocket(javax.net.ssl.SSLSocket sslSocket, org.apache.http.protocol.HttpContext context)java.net.SocketconnectSocket(int connectTimeout, java.net.Socket socket, org.apache.http.HttpHost host, java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, org.apache.http.protocol.HttpContext context)Connect via socket.private static javax.net.ssl.KeyManager[]getKeyManagers(WebClientOptions options)private javax.net.ssl.SSLSocketFactorygetSSLSocketFactory()(package private) static booleanisUseSSL3Only(org.apache.http.protocol.HttpContext context)private static voidsetEmptyHostname(org.apache.http.HttpHost host)static voidsetUseSSL3Only(org.apache.http.protocol.HttpContext httpContext, boolean ssl3Only)Enables/Disables the exclusive usage of SSL3.
-
-
-
Field Detail
-
SSL3ONLY
private static final java.lang.String SSL3ONLY
- See Also:
- Constant Field Values
-
useInsecureSSL_
private final boolean useInsecureSSL_
-
-
Constructor Detail
-
HtmlUnitSSLConnectionSocketFactory
private HtmlUnitSSLConnectionSocketFactory(javax.net.ssl.SSLContext sslContext, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean useInsecureSSL, java.lang.String[] supportedProtocols, java.lang.String[] supportedCipherSuites)
-
HtmlUnitSSLConnectionSocketFactory
private HtmlUnitSSLConnectionSocketFactory(java.security.KeyStore keystore, char[] keystorePassword, java.security.KeyStore truststore, boolean useInsecureSSL, java.lang.String[] supportedProtocols, java.lang.String[] supportedCipherSuites) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException, java.security.KeyStoreException, java.security.UnrecoverableKeyException- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyException
-
-
Method Detail
-
setUseSSL3Only
public static void setUseSSL3Only(org.apache.http.protocol.HttpContext httpContext, boolean ssl3Only)Enables/Disables the exclusive usage of SSL3.- Parameters:
httpContext- the http contextssl3Only- true or false
-
isUseSSL3Only
static boolean isUseSSL3Only(org.apache.http.protocol.HttpContext context)
-
buildSSLSocketFactory
public static org.apache.http.conn.ssl.SSLConnectionSocketFactory buildSSLSocketFactory(WebClientOptions options)
Factory method that builds a new SSLConnectionSocketFactory.- Parameters:
options- the current WebClientOptions- Returns:
- the SSLConnectionSocketFactory
-
configureSocket
private static void configureSocket(javax.net.ssl.SSLSocket sslSocket, org.apache.http.protocol.HttpContext context)
-
connectSocket
public java.net.Socket connectSocket(int connectTimeout, java.net.Socket socket, org.apache.http.HttpHost host, java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress, org.apache.http.protocol.HttpContext context) throws java.io.IOExceptionConnect via socket.- Specified by:
connectSocketin interfaceorg.apache.http.conn.socket.ConnectionSocketFactory- Overrides:
connectSocketin classorg.apache.http.conn.ssl.SSLConnectionSocketFactory- Parameters:
connectTimeout- the timeoutsocket- the sockethost- the hostremoteAddress- the remote addresslocalAddress- the local addresscontext- the context- Returns:
- the created/connected socket
- Throws:
java.io.IOException- in case of problems
-
setEmptyHostname
private static void setEmptyHostname(org.apache.http.HttpHost host)
-
getSSLSocketFactory
private javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
-
getKeyManagers
private static javax.net.ssl.KeyManager[] getKeyManagers(WebClientOptions options)
-
-