1 /*
2 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
35 import javax.net.ssl.SSLServerSocketFactory;
36 import javax.net.ssl.SSLSocket;
37 import javax.net.ssl.TrustManager;
38
39 class JSSEServer extends CipherTest.Server {
40
41 SSLServerSocket serverSocket;
42
43 JSSEServer(CipherTest cipherTest) throws Exception {
44 super(cipherTest);
45 SSLContext serverContext = SSLContext.getInstance("TLS");
46 serverContext.init(
47 new KeyManager[] { CipherTest.keyManager },
48 new TrustManager[] { CipherTest.trustManager },
49 CipherTest.secureRandom);
50
51 SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory();
52 serverSocket = (SSLServerSocket)factory.createServerSocket(0);
53 serverSocket.setSoTimeout(CipherTest.TIMEOUT);
54 CipherTest.serverPort = serverSocket.getLocalPort();
55 serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
56 serverSocket.setWantClientAuth(true);
57 }
58
59 @Override
60 public void run() {
61 System.out.println("JSSE Server listening on port " + CipherTest.serverPort);
62 Executor exec = Executors.newFixedThreadPool
63 (CipherTest.THREADS, DaemonThreadFactory.INSTANCE);
64
65 try {
66 if (!CipherTest.clientCondition.await(CipherTest.TIMEOUT,
67 TimeUnit.MILLISECONDS)) {
68 System.out.println(
69 "The client is not the expected one or timeout. "
70 + "Ignore in server side.");
71 return;
72 }
73
74 while (true) {
|
1 /*
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
35 import javax.net.ssl.SSLServerSocketFactory;
36 import javax.net.ssl.SSLSocket;
37 import javax.net.ssl.TrustManager;
38
39 class JSSEServer extends CipherTest.Server {
40
41 SSLServerSocket serverSocket;
42
43 JSSEServer(CipherTest cipherTest) throws Exception {
44 super(cipherTest);
45 SSLContext serverContext = SSLContext.getInstance("TLS");
46 serverContext.init(
47 new KeyManager[] { CipherTest.keyManager },
48 new TrustManager[] { CipherTest.trustManager },
49 CipherTest.secureRandom);
50
51 SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory();
52 serverSocket = (SSLServerSocket)factory.createServerSocket(0);
53 serverSocket.setSoTimeout(CipherTest.TIMEOUT);
54 CipherTest.serverPort = serverSocket.getLocalPort();
55
56 // JDK-8190492: Enable all supported protocols on server side to test SSLv3
57 serverSocket.setEnabledProtocols(serverSocket.getSupportedProtocols());
58
59 serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
60 serverSocket.setWantClientAuth(true);
61 }
62
63 @Override
64 public void run() {
65 System.out.println("JSSE Server listening on port " + CipherTest.serverPort);
66 Executor exec = Executors.newFixedThreadPool
67 (CipherTest.THREADS, DaemonThreadFactory.INSTANCE);
68
69 try {
70 if (!CipherTest.clientCondition.await(CipherTest.TIMEOUT,
71 TimeUnit.MILLISECONDS)) {
72 System.out.println(
73 "The client is not the expected one or timeout. "
74 + "Ignore in server side.");
75 return;
76 }
77
78 while (true) {
|