6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @test
28 * @bug 4873188
29 * @summary Support TLS 1.1
30 * @run main/othervm ExportableStreamCipher
31 *
32 * SunJSSE does not support dynamic system properties, no way to re-use
33 * system properties in samevm/agentvm mode.
34 *
35 * @author Xuelei Fan
36 */
37
38 import java.io.*;
39 import java.net.*;
40 import javax.net.ssl.*;
41
42 public class ExportableStreamCipher {
43
44 /*
45 * =============================================================
46 * Set the various variables needed for the tests, then
47 * specify what tests to run on each side.
48 */
49
50 /*
51 * Should we run the client or server in a separate thread?
52 * Both sides can throw exceptions, but do you have a preference
53 * as to which side should be the main thread.
54 */
92 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
93 SSLServerSocket sslServerSocket =
94 (SSLServerSocket) sslssf.createServerSocket(serverPort);
95
96 serverPort = sslServerSocket.getLocalPort();
97
98 /*
99 * Signal Client, we're ready for his connect.
100 */
101 serverReady = true;
102
103 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
104 InputStream sslIS = sslSocket.getInputStream();
105 OutputStream sslOS = sslSocket.getOutputStream();
106
107 boolean interrupted = false;
108 try {
109 sslIS.read();
110 sslOS.write('A');
111 sslOS.flush();
112 } catch (SSLException ssle) {
113 // get the expected exception
114 interrupted = true;
115 } finally {
116 sslSocket.close();
117 }
118
119 if (!interrupted) {
120 throw new SSLHandshakeException(
121 "A weak cipher suite is negotiated, " +
122 "TLSv1.1 must not negotiate the exportable cipher suites.");
123 }
124 }
125
126 /*
127 * Define the client side of the test.
128 *
129 * If the server prematurely exits, serverReady will be set to true
130 * to avoid infinite hangs.
131 */
132 void doClientSide() throws Exception {
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 //
27 // SunJSSE does not support dynamic system properties, no way to re-use
28 // system properties in samevm/agentvm mode.
29 //
30
31 /*
32 * @test
33 * @bug 4873188
34 * @summary Support TLS 1.1
35 * @run main/othervm ExportableStreamCipher
36 * @author Xuelei Fan
37 */
38
39 import java.io.*;
40 import java.net.*;
41 import javax.net.ssl.*;
42
43 public class ExportableStreamCipher {
44
45 /*
46 * =============================================================
47 * Set the various variables needed for the tests, then
48 * specify what tests to run on each side.
49 */
50
51 /*
52 * Should we run the client or server in a separate thread?
53 * Both sides can throw exceptions, but do you have a preference
54 * as to which side should be the main thread.
55 */
93 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
94 SSLServerSocket sslServerSocket =
95 (SSLServerSocket) sslssf.createServerSocket(serverPort);
96
97 serverPort = sslServerSocket.getLocalPort();
98
99 /*
100 * Signal Client, we're ready for his connect.
101 */
102 serverReady = true;
103
104 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
105 InputStream sslIS = sslSocket.getInputStream();
106 OutputStream sslOS = sslSocket.getOutputStream();
107
108 boolean interrupted = false;
109 try {
110 sslIS.read();
111 sslOS.write('A');
112 sslOS.flush();
113 } catch (IOException ioe) {
114 // get the expected exception
115 interrupted = true;
116 } finally {
117 sslSocket.close();
118 }
119
120 if (!interrupted) {
121 throw new SSLHandshakeException(
122 "A weak cipher suite is negotiated, " +
123 "TLSv1.1 must not negotiate the exportable cipher suites.");
124 }
125 }
126
127 /*
128 * Define the client side of the test.
129 *
130 * If the server prematurely exits, serverReady will be set to true
131 * to avoid infinite hangs.
132 */
133 void doClientSide() throws Exception {
|