Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/canonicalize/Test.java
41153 views
1
/*
2
* Copyright (c) 2009, 2021, 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 6682516 8149521
26
* @summary SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
27
* @modules java.security.jgss/sun.security.krb5
28
* @run main/othervm -Djdk.net.hosts.file=${test.src}/TestHosts
29
* -Djava.security.krb5.realm=THIS.REALM
30
* -Djava.security.krb5.kdc=localhost
31
* -Djava.security.krb5.conf=krb5.conf Test
32
*/
33
34
import sun.security.krb5.PrincipalName;
35
36
public class Test {
37
public static void main(String[] args) throws Exception {
38
// add using canonicalized name
39
check("c1", "c1.this.domain");
40
check("c1.this", "c1.this.domain");
41
check("c1.this.domain", "c1.this.domain");
42
check("c1.this.domain.", "c1.this.domain");
43
44
// canonicalized name goes IP, reject
45
check("c2", "c2");
46
check("c2.", "c2");
47
48
// canonicalized name goes strange, reject
49
check("c3", "c3");
50
51
// unsupported
52
check("c4", "c4");
53
}
54
55
static void check(String input, String output) throws Exception {
56
System.out.println(input + " -> " + output);
57
PrincipalName pn = new PrincipalName("host/"+input,
58
PrincipalName.KRB_NT_SRV_HST);
59
if (!pn.getNameStrings()[1].equals(output)) {
60
throw new Exception("Output is " + pn);
61
}
62
}
63
}
64
65