Methods Summary |
---|
private boolean | checkParameters(javax.rmi.ssl.SslRMIServerSocketFactory that)
// needClientAuth flag
//
if (needClientAuth != that.needClientAuth)
return false;
// enabledCipherSuites
//
if ((enabledCipherSuites == null && that.enabledCipherSuites != null) ||
(enabledCipherSuites != null && that.enabledCipherSuites == null))
return false;
if (enabledCipherSuites != null && that.enabledCipherSuites != null) {
List thatEnabledCipherSuitesList =
Arrays.asList((String[]) that.enabledCipherSuites);
if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList))
return false;
}
// enabledProtocols
//
if ((enabledProtocols == null && that.enabledProtocols != null) ||
(enabledProtocols != null && that.enabledProtocols == null))
return false;
if (enabledProtocols != null && that.enabledProtocols != null) {
List thatEnabledProtocolsList =
Arrays.asList((String[]) that.enabledProtocols);
if (!enabledProtocolsList.equals(thatEnabledProtocolsList))
return false;
}
return true;
|
public java.net.ServerSocket | createServerSocket(int port)Creates a server socket that accepts SSL connections
configured according to this factory's SSL socket configuration
parameters.
final SSLSocketFactory sslSocketFactory = getDefaultSSLSocketFactory();
return new ServerSocket(port) {
public Socket accept() throws IOException {
Socket socket = super.accept();
SSLSocket sslSocket = (SSLSocket)
sslSocketFactory.createSocket(
socket, socket.getInetAddress().getHostName(),
socket.getPort(), true);
sslSocket.setUseClientMode(false);
if (enabledCipherSuites != null) {
sslSocket.setEnabledCipherSuites(enabledCipherSuites);
}
if (enabledProtocols != null) {
sslSocket.setEnabledProtocols(enabledProtocols);
}
sslSocket.setNeedClientAuth(needClientAuth);
return sslSocket;
}
};
// If we do not instantiate the server socket class, but
// instead must layer on top of an arbitrary server socket,
// then this implementation would become uglier, like this
// (given "serverSocket" to layer on top of):
//
// return new ForwardingServerSocket(serverSocket) {
// public Socket accept() throws IOException {
// Socket socket = serverSocket.accept();
// SSLSocket sslSocket =
// (SSLSocket) sslSocketFactory.createSocket(
// socket,
// socket.getInetAddress().getHostName(),
// socket.getPort(),
// true);
// sslSocket.setUseClientMode(false);
// if (enabledProtocols != null) {
// sslSocket.setEnabledProtocols(enabledProtocols);
// }
// if (enabledCipherSuites != null) {
// sslSocket.setEnabledCipherSuites(enabledCipherSuites);
// }
// sslSocket.setNeedClientAuth(needClientAuth);
// return sslSocket;
// }
// public ServerSocketChannel getChannel() {
// return null;
// }
// public String toString() {
// return serverSocket.toString();
// }
// };
|
public boolean | equals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.
Two SslRMIServerSocketFactory objects are equal
if they have been constructed with the same SSL socket
configuration parameters.
A subclass should override this method (as well as
{@link #hashCode()}) if it adds instance state that affects
equality.
if (obj == null) return false;
if (obj == this) return true;
if (!(obj instanceof SslRMIServerSocketFactory))
return false;
SslRMIServerSocketFactory that = (SslRMIServerSocketFactory) obj;
return (getClass().equals(that.getClass()) && checkParameters(that));
|
private static synchronized javax.net.ssl.SSLSocketFactory | getDefaultSSLSocketFactory()
if (defaultSSLSocketFactory == null)
defaultSSLSocketFactory =
(SSLSocketFactory) SSLSocketFactory.getDefault();
return defaultSSLSocketFactory;
|
public final java.lang.String[] | getEnabledCipherSuites()Returns the names of the cipher suites enabled on SSL
connections accepted by server sockets created by this factory,
or null if this factory uses the cipher suites
that are enabled by default.
return enabledCipherSuites == null ?
null : (String[]) enabledCipherSuites.clone();
|
public final java.lang.String[] | getEnabledProtocols()Returns the names of the protocol versions enabled on SSL
connections accepted by server sockets created by this factory,
or null if this factory uses the protocol versions
that are enabled by default.
return enabledProtocols == null ?
null : (String[]) enabledProtocols.clone();
|
public final boolean | getNeedClientAuth()Returns true if client authentication is
required on SSL connections accepted by server sockets created
by this factory.
return needClientAuth;
|
public int | hashCode()Returns a hash code value for this
SslRMIServerSocketFactory .
return getClass().hashCode() +
(needClientAuth ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode()) +
(enabledCipherSuites == null ? 0 : enabledCipherSuitesList.hashCode()) +
(enabledProtocols == null ? 0 : enabledProtocolsList.hashCode());
|