Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/ssl/X509KeyManager/NullCases.java
41152 views
1
/*
2
* Copyright (c) 2005, 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 6302126 6302321 6302271 6302304
27
* @summary KeyManagerFactory.init method throws unspecified exception
28
* for NewSunX509 algorithm
29
* X509KeyManager implementation for NewSunX509 throws unspecified
30
* ProviderException
31
* X509KeyManager implementation for NewSunX509 algorithm returns empty
32
* arrays instead of null
33
* X509KeyManager implementation for NewSunX509 throws unspecified
34
* NullPointerException
35
*/
36
import java.io.*;
37
import java.net.*;
38
import java.security.*;
39
import javax.net.ssl.*;
40
import java.security.cert.X509Certificate;
41
42
import java.util.*;
43
44
45
public class NullCases {
46
public static void main(String[] args) throws Exception {
47
KeyManagerFactory kmf;
48
X509KeyManager km;
49
char [] password = {' '};
50
51
// check for bug 6302126
52
kmf = KeyManagerFactory.getInstance("NewSunX509");
53
kmf.init((KeyStore)null, password);
54
55
// check for 6302321
56
km = (X509KeyManager) kmf.getKeyManagers()[0];
57
X509Certificate[] certs = km.getCertificateChain("doesnotexist");
58
PrivateKey priv = km.getPrivateKey("doesnotexist");
59
if (certs != null || priv != null) {
60
throw new Exception("Should return null if the alias can't be found");
61
}
62
63
// check for 6302271
64
String[] clis = km.getClientAliases("doesnotexist", null);
65
if (clis != null && clis.length == 0) {
66
throw new Exception("Should return null instead of empty array");
67
}
68
String[] srvs = km.getServerAliases("doesnotexist", null);
69
if (srvs != null && srvs.length == 0) {
70
throw new Exception("Should return null instead of empty array");
71
}
72
73
// check for 6302304
74
km.getServerAliases(null, null);
75
km.getClientAliases(null, null);
76
km.getCertificateChain(null);
77
km.getPrivateKey(null);
78
km.chooseServerAlias(null, null, null);
79
km.chooseClientAlias(null, null, null);
80
}
81
}
82
83