Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/auto/Addresses.java
41152 views
1
/*
2
* Copyright (c) 2012, 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
/*
25
* @test
26
* @bug 8031111 8194486
27
* @summary fix krb5 caddr
28
* @library /test/lib
29
* @compile -XDignore.symbol.file Addresses.java
30
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
31
* @run main/othervm -Djdk.net.hosts.file=TestHosts Addresses
32
*/
33
34
import sun.security.krb5.Config;
35
36
import javax.security.auth.kerberos.KerberosTicket;
37
import java.net.Inet4Address;
38
import java.net.InetAddress;
39
40
public class Addresses {
41
42
public static void main(String[] args) throws Exception {
43
44
KDC.saveConfig(OneKDC.KRB5_CONF, new OneKDC(null),
45
"noaddresses = false",
46
"extra_addresses = 10.0.0.10, 10.0.0.11 10.0.0.12");
47
Config.refresh();
48
49
KerberosTicket ticket =
50
Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false)
51
.s().getPrivateCredentials(KerberosTicket.class)
52
.iterator().next();
53
54
InetAddress loopback = InetAddress.getLoopbackAddress();
55
InetAddress extra1 = InetAddress.getByName("10.0.0.10");
56
InetAddress extra2 = InetAddress.getByName("10.0.0.11");
57
InetAddress extra3 = InetAddress.getByName("10.0.0.12");
58
59
boolean loopbackFound = false;
60
boolean extra1Found = false;
61
boolean extra2Found = false;
62
boolean extra3Found = false;
63
boolean networkFound = false;
64
65
for (InetAddress ia: ticket.getClientAddresses()) {
66
System.out.println(ia);
67
if (ia.equals(loopback)) {
68
loopbackFound = true;
69
System.out.println(" loopback found");
70
} else if (ia.equals(extra1)) {
71
extra1Found = true;
72
System.out.println(" extra1 found");
73
} else if (ia.equals(extra2)) {
74
extra2Found = true;
75
System.out.println(" extra2 found");
76
} else if (ia.equals(extra3)) {
77
extra3Found = true;
78
System.out.println(" extra3 found");
79
} else if (ia instanceof Inet4Address) {
80
networkFound = true;
81
System.out.println(" another address (" + ia +
82
"), assumed real network");
83
}
84
}
85
86
if (!loopbackFound || !networkFound
87
|| !extra1Found || !extra2Found || !extra3Found ) {
88
throw new Exception();
89
}
90
}
91
}
92
93