Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/auto/DnsCanonicalizeHostname.java
41152 views
1
/*
2
* Copyright (c) 2018, 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
import jdk.test.lib.Asserts;
25
import sun.security.krb5.PrincipalName;
26
27
import java.nio.file.Files;
28
import java.nio.file.Path;
29
import java.util.List;
30
31
/*
32
* @test
33
* @bug 8210821
34
* @summary Support dns_canonicalize_hostname in krb5.conf
35
* @library /test/lib
36
* @compile -XDignore.symbol.file DnsCanonicalizeHostname.java
37
* @run main jdk.test.lib.FileInstaller dns_canonicalize_hostname.hosts hosts
38
* @run main/othervm -Djdk.net.hosts.file=hosts DnsCanonicalizeHostname none
39
* @run main/othervm -Djdk.net.hosts.file=hosts DnsCanonicalizeHostname true
40
* @run main/othervm -Djdk.net.hosts.file=hosts DnsCanonicalizeHostname false
41
*/
42
public class DnsCanonicalizeHostname {
43
44
// In dns_canonicalize_hostname.hosts, all "dummy.example.com", "dummy",
45
// and "bogus" are resolved to 127.0.0.1. Since "dummy.example.com" is on
46
// the first line, it is returned at the reverse lookup.
47
48
public static void main(String[] args) throws Exception {
49
50
Files.write(Path.of("krb5.conf"), List.of(
51
"[libdefaults]",
52
"default_realm = R",
53
args[0].equals("none")
54
? "# empty line"
55
: "dns_canonicalize_hostname = " + args[0],
56
"",
57
"[realms]",
58
"R = {",
59
" kdc = 127.0.0.1",
60
"}"
61
));
62
System.setProperty("java.security.krb5.conf", "krb5.conf");
63
64
String n1 = new PrincipalName("host/dummy", PrincipalName.KRB_NT_SRV_HST)
65
.getNameStrings()[1];
66
String n2 = new PrincipalName("host/bogus", PrincipalName.KRB_NT_SRV_HST)
67
.getNameStrings()[1];
68
69
switch (args[0]) {
70
case "none":
71
case "true":
72
Asserts.assertEQ(n1, "dummy.example.com");
73
Asserts.assertEQ(n2, "bogus");
74
break;
75
case "false":
76
Asserts.assertEQ(n1, "dummy");
77
Asserts.assertEQ(n2, "bogus");
78
break;
79
}
80
}
81
}
82
83