Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/security/auth/kerberos/DelegationPermissionInit.java
41152 views
1
/*
2
* Copyright (c) 2019, 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 javax.security.auth.kerberos.DelegationPermission;
25
import java.util.List;
26
27
/*
28
* @test
29
* @bug 8231196 8234267
30
* @summary DelegationPermission input check
31
*/
32
public class DelegationPermissionInit {
33
public static void main(String[] args) throws Exception {
34
var goodOnes = List.of(
35
"\"aaa\" \"bbb\"",
36
"\"aaa\" \"bbb\""
37
);
38
var badOnes = List.of(
39
"\"user@REALM\"",
40
"\"\"\" \"bbb\"",
41
"\"aaa\" \"\"\"",
42
"\"\"\" \"\"\"",
43
"\"aaa\" \"bbb",
44
"\"\"aaa\"\" \"\"bbb\"\"",
45
"\"aaa\" \"bbb\"\"\"",
46
"\"aaa\"-\"bbb\"",
47
"\"aaa\" - \"bbb\"",
48
"\"aaa\"- \"bbb\"",
49
"\"aaa\" \"bbb\" ",
50
"aaa\" \"bbb\" "
51
);
52
boolean failed = false;
53
for (var good : goodOnes) {
54
System.out.println(">>> " + good);
55
try {
56
new DelegationPermission(good);
57
} catch (Exception e) {
58
e.printStackTrace(System.out);
59
System.out.println("Failed");
60
failed = true;
61
}
62
}
63
for (var bad : badOnes) {
64
System.out.println(">>> " + bad);
65
try {
66
new DelegationPermission(bad);
67
System.out.println("Failed");
68
failed = true;
69
} catch (IllegalArgumentException e) {
70
e.printStackTrace(System.out);
71
} catch (Exception e) {
72
e.printStackTrace(System.out);
73
System.out.println("Failed");
74
failed = true;
75
}
76
}
77
if (failed) {
78
throw new Exception("Failed");
79
}
80
}
81
}
82
83