Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/net/ssl/SSLSecurity/ProviderTest.java
38867 views
1
/*
2
* Copyright (c) 2002, 2013, 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
* @test
26
* @bug 4667976
27
* @compile JavaxSSLContextImpl.java ComSSLContextImpl.java
28
* JavaxTrustManagerFactoryImpl.java ComTrustManagerFactoryImpl.java
29
* JavaxKeyManagerFactoryImpl.java ComKeyManagerFactoryImpl.java
30
* @run main/othervm ProviderTest
31
* @summary brokenness in the com.sun.net.ssl.SSLSecurity wrappers
32
*/
33
34
import java.security.*;
35
import com.sun.net.ssl.*;
36
37
public class ProviderTest {
38
39
public static void main(String args[]) throws Exception {
40
SSLContext sslc;
41
TrustManagerFactory tmf;
42
KeyManagerFactory kmf;
43
44
Provider extraProvider = new MyProvider();
45
Security.addProvider(extraProvider);
46
try {
47
System.out.println("getting a javax SSLContext");
48
sslc = SSLContext.getInstance("javax");
49
sslc.init(null, null, null);
50
System.out.println("\ngetting a com SSLContext");
51
sslc = SSLContext.getInstance("com");
52
sslc.init(null, null, null);
53
54
System.out.println("\ngetting a javax TrustManagerFactory");
55
tmf = TrustManagerFactory.getInstance("javax");
56
tmf.init((KeyStore) null);
57
System.out.println("\ngetting a com TrustManagerFactory");
58
tmf = TrustManagerFactory.getInstance("com");
59
tmf.init((KeyStore) null);
60
61
System.out.println("\ngetting a javax KeyManagerFactory");
62
kmf = KeyManagerFactory.getInstance("javax");
63
kmf.init((KeyStore) null, null);
64
System.out.println("\ngetting a com KeyManagerFactory");
65
kmf = KeyManagerFactory.getInstance("com");
66
kmf.init((KeyStore) null, null);
67
} finally {
68
Security.removeProvider(extraProvider.getName());
69
}
70
}
71
}
72
73
class MyProvider extends Provider {
74
75
private static String info = "Brad's provider";
76
77
/**
78
* Installs the JSSE provider.
79
*/
80
public static synchronized void install()
81
{
82
/* nop. Remove this method in the future. */
83
}
84
85
public MyProvider()
86
{
87
super("BRAD", 1.0, info);
88
89
AccessController.doPrivileged(new java.security.PrivilegedAction() {
90
public Object run() {
91
92
put("SSLContext.javax", "JavaxSSLContextImpl");
93
put("SSLContext.com", "ComSSLContextImpl");
94
put("TrustManagerFactory.javax",
95
"JavaxTrustManagerFactoryImpl");
96
put("TrustManagerFactory.com",
97
"ComTrustManagerFactoryImpl");
98
put("KeyManagerFactory.javax",
99
"JavaxKeyManagerFactoryImpl");
100
put("KeyManagerFactory.com",
101
"ComKeyManagerFactoryImpl");
102
103
return null;
104
}
105
});
106
107
}
108
}
109
110