2362N/A * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>An <code>SslRMIServerSocketFactory</code> instance is used by the RMI 0N/A * runtime in order to obtain server sockets for RMI calls via SSL.</p> 0N/A * <p>This class implements <code>RMIServerSocketFactory</code> over 0N/A * the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) 0N/A * <p>This class creates SSL sockets using the default 0N/A * <code>SSLSocketFactory</code> (see {@link 0N/A * SSLSocketFactory#getDefault}) or the default 0N/A * <code>SSLServerSocketFactory</code> (see {@link 0N/A * SSLServerSocketFactory#getDefault}) unless the 0N/A * constructor taking an <code>SSLContext</code> is 0N/A * used in which case the SSL sockets are created using 0N/A * the <code>SSLSocketFactory</code> returned by 0N/A * {@link SSLContext#getSocketFactory} or the 0N/A * <code>SSLServerSocketFactory</code> returned by 0N/A * {@link SSLContext#getServerSocketFactory}. 0N/A * When an <code>SSLContext</code> is not supplied all the instances of this 0N/A * class share the same keystore, and the same truststore (when client 0N/A * authentication is required by the server). This behavior can be modified 0N/A * by supplying an already initialized <code>SSLContext</code> instance. 0N/A * @see javax.net.ssl.SSLSocketFactory 0N/A * @see javax.net.ssl.SSLServerSocketFactory 0N/A * @see javax.rmi.ssl.SslRMIClientSocketFactory 0N/A * <p>Creates a new <code>SslRMIServerSocketFactory</code> with 0N/A * the default SSL socket configuration.</p> 0N/A * <p>SSL connections accepted by server sockets created by this 0N/A * factory have the default cipher suites and protocol versions 0N/A * enabled and do not require client authentication.</p> 0N/A * <p>Creates a new <code>SslRMIServerSocketFactory</code> with 0N/A * the specified SSL socket configuration.</p> 0N/A * @param enabledCipherSuites names of all the cipher suites to 0N/A * enable on SSL connections accepted by server sockets created by 0N/A * this factory, or <code>null</code> to use the cipher suites 0N/A * that are enabled by default 0N/A * @param enabledProtocols names of all the protocol versions to 0N/A * enable on SSL connections accepted by server sockets created by 0N/A * this factory, or <code>null</code> to use the protocol versions 0N/A * that are enabled by default 0N/A * @param needClientAuth <code>true</code> to require client 0N/A * authentication on SSL connections accepted by server sockets 0N/A * created by this factory; <code>false</code> to not require 0N/A * client authentication 0N/A * @exception IllegalArgumentException when one or more of the cipher 0N/A * suites named by the <code>enabledCipherSuites</code> parameter is 0N/A * not supported, when one or more of the protocols named by the 0N/A * <code>enabledProtocols</code> parameter is not supported or when 0N/A * a problem is encountered while trying to check if the supplied 0N/A * cipher suites and protocols to be enabled are supported. 0N/A * @see SSLSocket#setEnabledCipherSuites 0N/A * @see SSLSocket#setEnabledProtocols 0N/A * @see SSLSocket#setNeedClientAuth 0N/A * <p>Creates a new <code>SslRMIServerSocketFactory</code> with the 0N/A * specified <code>SSLContext</code> and SSL socket configuration.</p> 0N/A * @param context the SSL context to be used for creating SSL sockets. 0N/A * If <code>context</code> is null the default <code>SSLSocketFactory</code> 0N/A * or the default <code>SSLServerSocketFactory</code> will be used to 0N/A * create SSL sockets. Otherwise, the socket factory returned by 0N/A * <code>SSLContext.getSocketFactory()</code> or 0N/A * <code>SSLContext.getServerSocketFactory()</code> will be used instead. 0N/A * @param enabledCipherSuites names of all the cipher suites to 0N/A * enable on SSL connections accepted by server sockets created by 0N/A * this factory, or <code>null</code> to use the cipher suites 0N/A * that are enabled by default 0N/A * @param enabledProtocols names of all the protocol versions to 0N/A * enable on SSL connections accepted by server sockets created by 0N/A * this factory, or <code>null</code> to use the protocol versions 0N/A * that are enabled by default 0N/A * @param needClientAuth <code>true</code> to require client 0N/A * authentication on SSL connections accepted by server sockets 0N/A * created by this factory; <code>false</code> to not require 0N/A * client authentication 0N/A * @exception IllegalArgumentException when one or more of the cipher 0N/A * suites named by the <code>enabledCipherSuites</code> parameter is 0N/A * not supported, when one or more of the protocols named by the 0N/A * <code>enabledProtocols</code> parameter is not supported or when 0N/A * a problem is encountered while trying to check if the supplied 0N/A * cipher suites and protocols to be enabled are supported. 0N/A * @see SSLSocket#setEnabledCipherSuites 0N/A * @see SSLSocket#setEnabledProtocols 0N/A * @see SSLSocket#setNeedClientAuth 0N/A // Initialize the configuration parameters. 0N/A // Force the initialization of the default at construction time, 0N/A // rather than delaying it to the first time createServerSocket() 0N/A final String msg =
"Unable to check if the cipher suites " +
0N/A "and protocols to enable are supported";
0N/A // Check if all the cipher suites and protocol versions to enable 0N/A // are supported by the underlying SSL/TLS implementation and if 0N/A // true create lists from arrays. 0N/A * <p>Returns the names of the cipher suites enabled on SSL 0N/A * connections accepted by server sockets created by this factory, 0N/A * or <code>null</code> if this factory uses the cipher suites 0N/A * that are enabled by default.</p> 0N/A * @return an array of cipher suites enabled, or <code>null</code> 0N/A * @see SSLSocket#setEnabledCipherSuites 0N/A * <p>Returns the names of the protocol versions enabled on SSL 0N/A * connections accepted by server sockets created by this factory, 0N/A * or <code>null</code> if this factory uses the protocol versions 0N/A * that are enabled by default.</p> 0N/A * @return an array of protocol versions enabled, or 0N/A * @see SSLSocket#setEnabledProtocols 0N/A * <p>Returns <code>true</code> if client authentication is 0N/A * required on SSL connections accepted by server sockets created 0N/A * by this factory.</p> 0N/A * @return <code>true</code> if client authentication is required 0N/A * @see SSLSocket#setNeedClientAuth 0N/A * <p>Creates a server socket that accepts SSL connections 0N/A * configured according to this factory's SSL socket configuration 0N/A * <p>Indicates whether some other object is "equal to" this one.</p> 0N/A * <p>Two <code>SslRMIServerSocketFactory</code> objects are equal 0N/A * if they have been constructed with the same SSL context and 0N/A * SSL socket configuration parameters.</p> 0N/A * <p>A subclass should override this method (as well as 0N/A * {@link #hashCode()}) if it adds instance state that affects 0N/A // needClientAuth flag 0N/A // enabledCipherSuites 0N/A * <p>Returns a hash code value for this 0N/A * <code>SslRMIServerSocketFactory</code>.</p> 0N/A * @return a hash code value for this 0N/A * <code>SslRMIServerSocketFactory</code>. 0N/A // We use a static field because: 0N/A // SSLSocketFactory.getDefault() always returns the same object 0N/A // (at least on Sun's implementation), and we want to make sure 0N/A // that the Javadoc & the implementation stay in sync. 0N/A // If someone needs to have different SslRMIServerSocketFactory 0N/A // factories with different underlying SSLSocketFactory objects 0N/A // using different keystores and truststores, he/she can always 0N/A // use the constructor that takes an SSLContext as input.