|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.net.Socket
ice.ssl.SSLSocket
This class implements client SSL sockets.
This class implements the following protocols:
It is advised to run the static method init() in the
begining of the client application so that the time-consuming initialization
can be done before to use this class in a low-priority thread.
Note: This implementation uses the algorithms IC2 and IC4. These algorithms are fully compatible with RC2(TM) and RC4(TM) respectively. The names RC2 and RC4 are trademarks of RSA Data Security, Inc.
| Constructor Summary | |
SSLSocket(InetAddress address,
int port)
Creates a stream SSL socket and connects it to the specified port number at the specified IP address. |
|
SSLSocket(InetAddress address,
int port,
InetAddress localAddr,
int localPort)
Creates a SSL socket and connects it to the specified remote address on the specified remote port. |
|
SSLSocket(Socket s,
String target)
Creates a stream SSL socket from the provided plain socket. |
|
SSLSocket(String host,
int port)
Creates a stream SSL socket and connects it to the specified port number on the named host. |
|
SSLSocket(String host,
int port,
InetAddress localAddr,
int localPort)
Creates a SSL socket and connects it to the specified remote host on the specified remote port. |
|
| Method Summary | |
void |
close()
Closes this socket. |
static CertificateListener |
getBlockingCertificateListener()
Deprecated. |
static int |
getCertEvents()
Returns which event family will trigger a CertificateEvent and block the socket flow. |
protected static CertificateCallback |
getCertificateCallback()
Returns the current certificate callback |
CertificateManager |
getCertificateManager()
Return the certificate manager for this SSLSocket connection. |
static int[] |
getCipherSuiteList()
Retrieve the current cipher suite list for SSL version 3. |
static int[] |
getCipherSuiteListV2()
Retrieve the current cipher suite list for SSL version 2. |
static int[] |
getCompressionMethodList()
Gets the compression method list. |
InetAddress |
getInetAddress()
|
InputStream |
getInputStream()
Returns an input stream for this socket. |
OutputStream |
getOutputStream()
Returns an output stream for this socket. |
static int |
getProtocols()
Returns which protocols are supported by all SSLSocket objects. |
static int[] |
getSupportedCipherSuiteList()
Retrieve the list of cipher suites supported in this implementation for SSL version 3. |
static int[] |
getSupportedCipherSuiteListV2()
Retrieve the list of cipher suites supported in this implementation for SSL version 2. |
String |
getTargetHostName()
Get the name of the host this socket is connected to. |
static ServerCertificateList |
getTrustedCACertList()
Gets the current trusted CA's certificate list. |
static ServerCertificateList |
getTrustedSiteCertList()
Gets the current trusted web site certificate list. |
static boolean |
getUseSecureRandom()
Returns wether or not a secure random is currently used. |
static void |
init()
Does some general initialization that are time consuming. |
static void |
removeBlockingCertificateListener(CertificateListener cl)
Deprecated. |
static void |
removeCertificateCallback(CertificateCallback ccb)
Removes the current certificate certificate callback. |
static void |
setBlockingCertificateListener(CertificateListener cl)
Deprecated. |
static void |
setCertEvents(int whenEvents)
Deprecated. |
static void |
setCertificateCallback(CertificateCallback ccb)
Installs a certificate callback implementing the CertificateCallback interface |
void |
setCertificateManager(CertificateManager cm)
Set a sertificate manager for this socket connection |
static void |
setCipherSuiteList(int[] cipherSuites)
Sets the acceptable cipher suite for SSL 3.0. |
static void |
setCipherSuiteListV2(int[] cipherSuites)
Sets the acceptable cipher suite for SSL 2.0. |
static void |
setCompressionMethodList(int[] compressionMethods)
Sets the compression method list. |
static void |
setDataStorage(DataStorage datastore)
|
static void |
setProtocols(int protocols)
Defines which protocols are supported by all SSLSocket objects. |
static void |
setTrustedCACertList(ServerCertificateList scl)
Sets the trusted CA's certificate list and dicards the previous list. |
static void |
setTrustedSiteCertList(ServerCertificateList scl)
Sets the trusted web site certificate list and dicards the previous list. |
static void |
setUseSecureRandom(boolean secure)
Set wether to use or not a secure random. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String VERSION
public static final int SSL_2_0
public static final int SSL_3_0
public static final int ALL_CERTIFICATES
public static final int ERROR_CERTIFICATES
public static final int NO_CERTIFICATES
public static final int SSL3_NULL_WITH_NULL_NULL
public static final int SSL3_RSA_WITH_NULL_MD5
public static final int SSL3_RSA_WITH_NULL_SHA
public static final int SSL3_RSA_EXPORT_WITH_IC4_40_MD5
public static final int SSL3_RSA_WITH_IC4_128_MD5
public static final int SSL3_RSA_WITH_IC4_128_SHA
public static final int SSL3_RSA_EXPORT_WITH_IC2_CBC_40_MD5
public static final int SSL3_RSA_EXPORT_WITH_DES40_CBC_SHA
public static final int SSL3_RSA_WITH_DES_CBC_SHA
public static final int SSL3_RSA_WITH_3DES_EDE_CBC_SHA
public static final int SSL2_IC4_128_WITH_MD5
public static final int SSL2_IC4_128_EXPORT40_WITH_MD5
public static final int SSL2_IC2_128_CBC_WITH_MD5
public static final int SSL2_IC2_128_CBC_EXPORT40_WITH_MD5
public static final int SSL2_DES_64_CBC_WITH_MD5
public static final int SSL2_DES_192_EDE3_CBC_WITH_MD5
public static DataStorage storage
| Constructor Detail |
public SSLSocket(String host,
int port)
throws UnknownHostException,
IOException
If the application has specified a server socket factory, that
factory's createSocketImpl method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
host - the host name.port - the port number.
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.
UnknownHostExceptioninit()
public SSLSocket(InetAddress address,
int port)
throws IOException
If the application has specified a socket factory, that factory's
createSocketImpl method is called to create the
actual socket implementation. Otherwise a "plain" socket is created.
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
address - the IP address.port - the port number.
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.init()
public SSLSocket(String host,
int port,
InetAddress localAddr,
int localPort)
throws IOException
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
host - the name of the remote hostport - the remote portlocalAddr - the local address the socket is bound tolocalPort - the local port the socket is bound to
SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.
IOExceptioninit()
public SSLSocket(InetAddress address,
int port,
InetAddress localAddr,
int localPort)
throws IOException
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
address - the remote addressport - the remote portlocalAddr - the local address the socket is bound tolocalPort - the local port the socket is bound to
SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.
IOExceptioninit()
public SSLSocket(Socket s,
String target)
throws IOException
s - The socket SSLsocket should use.target - name of the target host or null.init()| Method Detail |
public static void init()
It is advised to run this method in the begining of the client application so that the initialization can be done before to use this class in a low-priority thread. This method is anyway called by the constructor and thus is not mandatory.
Among other things, the SecureRandom seeding is made by calling this method.
setUseSecureRandom(boolean)public InetAddress getInetAddress()
public String getTargetHostName()
public InputStream getInputStream()
throws IOException
IOException - if an I/O error occurs when creating the
input stream.
public OutputStream getOutputStream()
throws IOException
IOException - if an I/O error occurs when creating the
output stream.
public void close()
throws IOException
IOException - if an I/O error occurs when closing this socket.
public static void setCipherSuiteList(int[] cipherSuites)
throws IllegalArgumentException
SSL3_NULL_WITH_NULL_NULLSSL3_RSA_WITH_NULL_MD5SSL3_RSA_WITH_NULL_SHASSL3_RSA_EXPORT_WITH_IC4_40_MD5SSL3_RSA_WITH_IC4_128_MD5SSL3_RSA_WITH_IC4_128_SHASSL3_RSA_EXPORT_WITH_IC2_CBC_40_MD5SSL3_RSA_EXPORT_WITH_DES40_CBC_SHASSL3_RSA_WITH_DES_CBC_SHASSL3_RSA_WITH_3DES_EDE_CBC_SHA
IllegalArgumentException - if one of the suite of the list is not supportedpublic static int[] getCipherSuiteList()
public static int[] getSupportedCipherSuiteList()
public static void setCipherSuiteListV2(int[] cipherSuites)
throws IllegalArgumentException
SSL2_IC4_128_WITH_MD5SSL2_IC4_128_EXPORT40_WITH_MD5SSL2_IC2_128_CBC_WITH_MD5SSL2_IC2_128_CBC_EXPORT40_WITH_MD5SSL2_DES_64_CBC_WITH_MD5SSL2_DES_192_EDE3_CBC_WITH_MD5
IllegalArgumentException - if one of the suite of the list is not supportedgetSupportedCipherSuiteListV2()public static int[] getCipherSuiteListV2()
setCipherSuiteListV2(int[])public static int[] getSupportedCipherSuiteListV2()
public static void setCompressionMethodList(int[] compressionMethods)
public static int[] getCompressionMethodList()
setCompressionMethodList(int[])public static void setProtocols(int protocols)
SSL_2_0SSL_3_0SSL_2_0 | SSL_3_0.
public static int getProtocols()
setProtocols(int)public static void setUseSecureRandom(boolean secure)
Setting this method to false makes the connection unsecure.
init()public static void setDataStorage(DataStorage datastore)
public static boolean getUseSecureRandom()
setUseSecureRandom(boolean),
init()public static ServerCertificateList getTrustedCACertList()
public static void setTrustedCACertList(ServerCertificateList scl)
save() and load() of
ServerCertificateList.
scl - the server certificate list or null for removing the current listpublic static ServerCertificateList getTrustedSiteCertList()
public static void setTrustedSiteCertList(ServerCertificateList scl)
save() and restoreList() of
ServerCertificateList.
scl - the server certificate list or null for removing the current listpublic static void setCertificateCallback(CertificateCallback ccb)
protected static CertificateCallback getCertificateCallback()
public static void removeCertificateCallback(CertificateCallback ccb)
public void setCertificateManager(CertificateManager cm)
public CertificateManager getCertificateManager()
public static void setBlockingCertificateListener(CertificateListener cl)
IllegalArgumentException - if a listener is already set.public static void removeBlockingCertificateListener(CertificateListener cl)
getBlockingCertificateListener()public static CertificateListener getBlockingCertificateListener()
setBlockingCertificateListener() or null if no one is set.public static void setCertEvents(int whenEvents)
ALL_CERTIFICATES triggers an event for all received certificates.ERROR_CERTIFICATES triggers an event only for certificates containing errors.NO_CERTIFICATES never triggers an event. An IOException is thrown when an erronous certificates is received.ERROR_CERTIFICATES. If no CertificateListener
is set or if null is set, then an IOException is thrown when an
erronous certificates is received.
public static int getCertEvents()
ALL_CERTIFICATES triggers an event for all received certificates.ERROR_CERTIFICATES triggers an event only for certificates containing errors.NO_CERTIFICATES never triggers an event.ERROR_CERTIFICATES. If no CertificateListener
is set or if null is set, then an IOException is thrown and the connection
is closed when an erronous certificates is received.
If NO_CERTIFICATE is set, an IOException is thrown when an erronous certificates
is received, but the connection is not closed and will continue normally.
You should close it manually if you wish.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||