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