Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/config/ParseCAPaths.java
41155 views
1
/*
2
* Copyright (c) 2009, 2011, 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
* @test
25
* @bug 6789935 8012615
26
* @modules java.security.jgss/sun.security.krb5
27
* @run main/othervm ParseCAPaths
28
* @summary cross-realm capath search error
29
*/
30
31
import java.util.Arrays;
32
import sun.security.krb5.Realm;
33
34
public class ParseCAPaths {
35
static Exception failed = null;
36
public static void main(String[] args) throws Exception {
37
System.setProperty("java.security.krb5.conf",
38
System.getProperty("test.src", ".") +"/krb5-capaths.conf");
39
40
// MIT
41
check("ANL.GOV", "TEST.ANL.GOV", "ANL.GOV");
42
check("ANL.GOV", "ES.NET", "ANL.GOV");
43
check("ANL.GOV", "PNL.GOV", "ANL.GOV", "ES.NET");
44
check("ANL.GOV", "NERSC.GOV", "ANL.GOV", "ES.NET");
45
check("NERSC.GOV", "TEST.ANL.GOV", "NERSC.GOV", "ES.NET", "ANL.GOV");
46
47
// RedHat
48
// 3.6.2.1. Configuring a Shared Hierarchy of Names
49
check("AA.EXAMPLE.COM", "BB.EXAMPLE.COM",
50
"AA.EXAMPLE.COM", "EXAMPLE.COM");
51
check("SITE1.SALES.EXAMPLE.COM", "EVERYWHERE.EXAMPLE.COM",
52
"SITE1.SALES.EXAMPLE.COM", "SALES.EXAMPLE.COM",
53
"EXAMPLE.COM");
54
check("DEVEL.EXAMPLE.COM", "PROD.EXAMPLE.ORG",
55
"DEVEL.EXAMPLE.COM", "EXAMPLE.COM", "COM",
56
"ORG", "EXAMPLE.ORG");
57
// 3.6.2.2. Configuring Paths in krb5.conf
58
check("A.EXAMPLE.COM", "B.EXAMPLE.COM", "A.EXAMPLE.COM");
59
check("A.EXAMPLE.COM", "C.EXAMPLE.COM",
60
"A.EXAMPLE.COM", "B.EXAMPLE.COM");
61
check("A.EXAMPLE.COM", "D.EXAMPLE.COM",
62
"A.EXAMPLE.COM", "B.EXAMPLE.COM", "C.EXAMPLE.COM");
63
64
// The original JDK example
65
check("TIVOLI.COM", "IBM.COM", "TIVOLI.COM", "LDAPCENTRAL.NET",
66
"IBM_LDAPCENTRAL.COM", "MOONLITE.ORG");
67
68
// Hierachical
69
check("N1.N.COM", "N2.N.COM", "N1.N.COM", "N.COM");
70
check("N1.N.COM", "N2.N3.COM", "N1.N.COM", "N.COM",
71
"COM", "N3.COM");
72
check("N1.COM", "N2.COM", "N1.COM", "COM");
73
check("N1", "N2", "N1");
74
check("N1.COM", "N2.ORG", "N1.COM", "COM", "ORG");
75
check("N1.N.COM", "N.COM", "N1.N.COM");
76
check("X.N1.N.COM", "N.COM", "X.N1.N.COM", "N1.N.COM");
77
check("N.COM", "N1.N.COM", "N.COM");
78
check("N.COM", "X.N1.N.COM", "N.COM", "N1.N.COM");
79
check("A.B.C", "D.E.F", "A.B.C", "B.C", "C", "F", "E.F");
80
81
// Full path
82
check("A1.COM", "A2.COM", "A1.COM");
83
check("A1.COM", "A3.COM", "A1.COM", "A2.COM");
84
check("A1.COM", "A4.COM", "A1.COM", "A2.COM", "A3.COM");
85
86
// Shortest path
87
check("B1.COM", "B2.COM", "B1.COM");
88
check("B1.COM", "B3.COM", "B1.COM", "B2.COM");
89
check("B1.COM", "B4.COM", "B1.COM", "B2.COM", "B3.COM");
90
91
// Missing is "."
92
check("C1.COM", "C2.COM", "C1.COM", "COM");
93
check("C1.COM", "C3.COM", "C1.COM", "C2.COM");
94
95
// cRealm = .
96
check("D1.COM", "D2.COM", "D1.COM");
97
98
// Bad cases
99
check("E1.COM", "E2.COM", "E1.COM");
100
check("E1.COM", "E3.COM", "E1.COM", "E4.COM");
101
check("G1.COM", "G3.COM", "G1.COM", "G2.COM");
102
check("I1.COM", "I4.COM", "I1.COM", "I5.COM");
103
104
// 7019384
105
check("A9.PRAGUE.XXX.CZ", "SERVIS.XXX.CZ",
106
"A9.PRAGUE.XXX.CZ", "PRAGUE.XXX.CZ", "ROOT.XXX.CZ");
107
108
if (failed != null) {
109
throw failed;
110
}
111
}
112
113
static void check(String from, String to, String... paths) {
114
try {
115
check2(from, to, paths);
116
} catch (Exception e) {
117
System.out.println(" " + e.getMessage());
118
failed = e;
119
}
120
}
121
122
static void check2(String from, String to, String... paths)
123
throws Exception {
124
System.out.println(from + " -> " + to);
125
System.out.println(" expected: " + Arrays.toString(paths));
126
String[] result = Realm.getRealmsList(from, to);
127
if (result == null || result.length == 0) {
128
throw new Exception("There is always a valid path.");
129
} else if(result.length != paths.length) {
130
throw new Exception("Length of path not correct");
131
} else {
132
for (int i=0; i<result.length; i++) {
133
if (!result[i].equals(paths[i])) {
134
System.out.println(" result: " + Arrays.toString(result));
135
throw new Exception("Path not same");
136
}
137
}
138
}
139
}
140
}
141
142