/* * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javax.rmi.ssl; import java.io.IOException; import java.io.Serializable; import java.net.Socket; import java.rmi.server.RMIClientSocketFactory; import java.util.StringTokenizer; import javax.net.SocketFactory; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; /** *
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 {@link
* 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 {@link #createSocket(String,int)}
* method; in that case, {@link #equals(Object) equals} and {@link
* #hashCode() hashCode} may also need to be overridden.
If the system property
* javax.rmi.ssl.client.enabledCipherSuites
is specified,
* the {@link #createSocket(String,int)} method will call {@link
* 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 {@link #createSocket(String,int)} method will call {@link
* 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.
Creates a new SslRMIClientSocketFactory
.
Creates an SSL socket.
* *If the system property
* javax.rmi.ssl.client.enabledCipherSuites
is
* specified, this method will call {@link
* 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 {@link
* 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.
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 {@link #hashCode()}) if its instances are not all * functionally equivalent.
*/ public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; return this.getClass().equals(obj.getClass()); } /** *Returns a hash code value for this
* SslRMIClientSocketFactory
.
SslRMIClientSocketFactory
.
*/
public int hashCode() {
return this.getClass().hashCode();
}
// We use a static field because:
//
// SSLSocketFactory.getDefault() always returns the same object
// (at least on Sun's implementation), and we want to make sure
// that the Javadoc & the implementation stay in sync.
//
// If someone needs to have different SslRMIClientSocketFactory factories
// with different underlying SSLSocketFactory objects using different key
// and trust stores, he can always do so by subclassing this class and
// overriding createSocket(String host, int port).
//
private static SocketFactory defaultSocketFactory = null;
private static synchronized SocketFactory getDefaultClientSocketFactory() {
if (defaultSocketFactory == null)
defaultSocketFactory = SSLSocketFactory.getDefault();
return defaultSocketFactory;
}
private static final long serialVersionUID = -8310631444933958385L;
}