|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.glite.slcs.httpclient.ssl.ExtendedProtocolSocketFactory
public class ExtendedProtocolSocketFactory
ExtendedProtocolSocketFactory extends the default system TrustManager with your custom truststore (KeyStore of trusted CA).
Use JDK keytool utility to import a trusted certificate and generate a truststore file:
keytool -import -alias "my server cert" -file server.crt -keystore my.truststore
Example of using custom protocol socket factory for a specific host:
Protocol https = new Protocol("https", new ExtendedProtocolSocketFactory( "my.truststore.jks"), 443); HttpClient client = new HttpClient(); client.getHostConfiguration().setHost("localhost", 443, https); // use relative url only GetMethod httpget = new GetMethod("/"); client.executeMethod(httpget);
Example of using custom protocol socket factory per default instead of the standard one:
Protocol https = new Protocol("https", new ExtendedProtocolSocketFactory( "my.truststore.jks"), 443); Protocol.registerProtocol("https", https); HttpClient client = new HttpClient(); GetMethod httpget = new GetMethod("https://localhost/"); client.executeMethod(httpget);
Constructor Summary | |
---|---|
ExtendedProtocolSocketFactory(java.security.KeyStore keystore,
java.lang.String keystorePassword,
java.security.KeyStore truststore)
Creates a ExtendedProtocolSocketFactory with the given keystore
and keystore password, and the truststore. |
|
ExtendedProtocolSocketFactory(java.lang.String truststorePath)
Extends the trust capabilities of the ProtocolSocketFactory with the given TrustStore. |
|
ExtendedProtocolSocketFactory(java.lang.String keystorePath,
java.lang.String keystorePassword,
java.lang.String truststorePath)
Extends the trust and client authentication of the ProtocolSocketFactory with the given KeyStore and TrustStore. |
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 clientHost,
int clientPort)
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExtendedProtocolSocketFactory(java.lang.String truststorePath) throws java.io.IOException, java.security.GeneralSecurityException
truststorePath
- Path of the truststore file (JKS).
java.io.IOException
- If an error occurs while loading the truststore.
java.security.GeneralSecurityException
- If an error occurs while initializing the SSLContext
.public ExtendedProtocolSocketFactory(java.lang.String keystorePath, java.lang.String keystorePassword, java.lang.String truststorePath) throws java.io.IOException, java.security.GeneralSecurityException
keystorePath
- Path of the keystore file (JKS).keystorePassword
- Password of the keystore.truststorePath
- Path of the truststore file (JKS).
java.io.IOException
- If an error occurs while loading the keystore or the
truststore.
java.security.GeneralSecurityException
- If an error occurs while initializing the SSLContext
.public ExtendedProtocolSocketFactory(java.security.KeyStore keystore, java.lang.String keystorePassword, java.security.KeyStore truststore) throws java.io.IOException, java.security.GeneralSecurityException
ExtendedProtocolSocketFactory
with the given keystore
and keystore password, and the truststore.
keystore
- The already loaded keystore objectkeystorePassword
- The password of the keystore.truststore
- The already loaded truststore object
java.io.IOException
- Should never occurs in this context
java.security.GeneralSecurityException
- If an error occurs while initializing the SSLContext
.Method Detail |
---|
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, java.net.UnknownHostException, org.apache.commons.httpclient.ConnectTimeoutException
To circumvent the limitations of older JREs that do not support connect
timeout 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 ConnectTimeoutException
createSocket
in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
host
- the host name/IPport
- the port on the hostclientHost
- the local host name/IP to bind the socket toclientPort
- the port on the local machineparams
- Http connection parameters
java.io.IOException
- if an I/O error occurs while creating the socket
java.net.UnknownHostException
- if the IP address of the host cannot be determined
org.apache.commons.httpclient.ConnectTimeoutException
public java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress clientHost, int clientPort) throws java.io.IOException, java.net.UnknownHostException
createSocket
in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
java.io.IOException
java.net.UnknownHostException
ProtocolSocketFactory.createSocket(java.lang.String,int,java.net.InetAddress,int)
public java.net.Socket createSocket(java.lang.String host, int port) throws java.io.IOException, java.net.UnknownHostException
createSocket
in interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory
java.io.IOException
java.net.UnknownHostException
ProtocolSocketFactory.createSocket(java.lang.String,int)
public java.net.Socket createSocket(java.net.Socket socket, java.lang.String host, int port, boolean autoClose) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
ProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |