Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/ssl/X509KeyManager/CertificateAuthorities.java
41152 views
1
/*
2
* Copyright (c) 2020, 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
*/
23
24
//
25
// SunJSSE does not support dynamic system properties, no way to re-use
26
// system properties in samevm/agentvm mode.
27
//
28
29
/*
30
* @test
31
* @bug 8206925
32
* @summary Support the "certificate_authorities" extension
33
* @library /javax/net/ssl/templates
34
* @run main/othervm CertificateAuthorities
35
* @run main/othervm -Djdk.tls.client.enableCAExtension=false
36
* CertificateAuthorities
37
* @run main/othervm -Djdk.tls.client.enableCAExtension=true
38
* CertificateAuthorities
39
*
40
* @run main/othervm CertificateAuthorities NEED_CLIENT_AUTH
41
* @run main/othervm -Djdk.tls.client.enableCAExtension=false
42
* CertificateAuthorities NEED_CLIENT_AUTH
43
* @run main/othervm -Djdk.tls.client.enableCAExtension=true
44
* CertificateAuthorities NEED_CLIENT_AUTH
45
*
46
* @run main/othervm CertificateAuthorities WANT_CLIENT_AUTH
47
* @run main/othervm -Djdk.tls.client.enableCAExtension=false
48
* CertificateAuthorities WANT_CLIENT_AUTH
49
* @run main/othervm -Djdk.tls.client.enableCAExtension=true
50
* CertificateAuthorities WANT_CLIENT_AUTH
51
*/
52
53
import javax.net.ssl.SSLServerSocket;
54
55
public final class CertificateAuthorities extends SSLSocketTemplate {
56
final ClientAuthMode clientAuthMode;
57
58
/*
59
* Run the test case.
60
*/
61
public static void main(String[] args) throws Exception {
62
CertificateAuthorities testCase;
63
if (args.length != 0) {
64
testCase = new CertificateAuthorities(
65
ClientAuthMode.valueOf(args[0]));
66
} else {
67
testCase = new CertificateAuthorities(
68
ClientAuthMode.NO_CLIENT_AUTH);
69
}
70
71
testCase.run();
72
}
73
74
CertificateAuthorities(ClientAuthMode mode) {
75
this.clientAuthMode = mode;
76
}
77
78
@Override
79
protected void configureServerSocket(SSLServerSocket socket) {
80
if (clientAuthMode == ClientAuthMode.NEED_CLIENT_AUTH) {
81
socket.setNeedClientAuth(true);
82
} else if (clientAuthMode == ClientAuthMode.WANT_CLIENT_AUTH) {
83
socket.setWantClientAuth(true);
84
}
85
}
86
87
private static enum ClientAuthMode {
88
NEED_CLIENT_AUTH,
89
WANT_CLIENT_AUTH,
90
NO_CLIENT_AUTH
91
}
92
}
93
94