javax.rmi.ssl
public class: SslRMIClientSocketFactory [javadoc |
source]
java.lang.Object
javax.rmi.ssl.SslRMIClientSocketFactory
All Implemented Interfaces:
RMIClientSocketFactory, Serializable
An SslRMIClientSocketFactory instance is used by the RMI
runtime in order to obtain client sockets for RMI calls via SSL.
This class implements RMIClientSocketFactory over
the Secure Sockets Layer (SSL) or Transport Layer Security (TLS)
protocols.
This class creates SSL sockets using the default
SSLSocketFactory (see SSLSocketFactory#getDefault ). All instances of this class are
functionally equivalent. In particular, they all share the same
truststore, and the same keystore when client authentication is
required by the server. This behavior can be modified in
subclasses by overriding the #createSocket(String,int)
method; in that case, equals and hashCode may also need to be overridden.
If the system property
javax.rmi.ssl.client.enabledCipherSuites is specified,
the #createSocket(String,int) method will call SSLSocket#setEnabledCipherSuites(String[]) before returning the
socket. The value of this system property is a string that is a
comma-separated list of SSL/TLS cipher suites to enable.
If the system property
javax.rmi.ssl.client.enabledProtocols is specified,
the #createSocket(String,int) method will call SSLSocket#setEnabledProtocols(String[]) before returning the
socket. The value of this system property is a string that is a
comma-separated list of SSL/TLS protocol versions to enable.
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.rmi.ssl.SslRMIClientSocketFactory Detail: |
public Socket createSocket(String host,
int port) throws IOException {
// Retrieve the SSLSocketFactory
//
final SocketFactory sslSocketFactory = getDefaultClientSocketFactory();
// Create the SSLSocket
//
final SSLSocket sslSocket = (SSLSocket)
sslSocketFactory.createSocket(host, port);
// Set the SSLSocket Enabled Cipher Suites
//
final String enabledCipherSuites =
System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
if (enabledCipherSuites != null) {
StringTokenizer st = new StringTokenizer(enabledCipherSuites, ",");
int tokens = st.countTokens();
String enabledCipherSuitesList[] = new String[tokens];
for (int i = 0 ; i < tokens; i++) {
enabledCipherSuitesList[i] = st.nextToken();
}
try {
sslSocket.setEnabledCipherSuites(enabledCipherSuitesList);
} catch (IllegalArgumentException e) {
throw (IOException)
new IOException(e.getMessage()).initCause(e);
}
}
// Set the SSLSocket Enabled Protocols
//
final String enabledProtocols =
System.getProperty("javax.rmi.ssl.client.enabledProtocols");
if (enabledProtocols != null) {
StringTokenizer st = new StringTokenizer(enabledProtocols, ",");
int tokens = st.countTokens();
String enabledProtocolsList[] = new String[tokens];
for (int i = 0 ; i < tokens; i++) {
enabledProtocolsList[i] = st.nextToken();
}
try {
sslSocket.setEnabledProtocols(enabledProtocolsList);
} catch (IllegalArgumentException e) {
throw (IOException)
new IOException(e.getMessage()).initCause(e);
}
}
// Return the preconfigured SSLSocket
//
return sslSocket;
}
Creates an SSL socket.
If the system property
javax.rmi.ssl.client.enabledCipherSuites is
specified, this method will call SSLSocket#setEnabledCipherSuites(String[]) before returning
the socket. The value of this system property is a string that
is a comma-separated list of SSL/TLS cipher suites to
enable.
If the system property
javax.rmi.ssl.client.enabledProtocols is
specified, this method will call SSLSocket#setEnabledProtocols(String[]) before returning the
socket. The value of this system property is a string that is a
comma-separated list of SSL/TLS protocol versions to
enable.
|
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj == this) return true;
return this.getClass().equals(obj.getClass());
}
Indicates whether some other object is "equal to" this one.
Because all instances of this class are functionally equivalent
(they all use the default
SSLSocketFactory), this method simply returns
this.getClass().equals(obj.getClass()).
A subclass should override this method (as well
as #hashCode() ) if its instances are not all
functionally equivalent.
|
public int hashCode() {
return this.getClass().hashCode();
}
|