Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java
41161 views
1
/*
2
* Copyright (c) 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
/*
25
* @test
26
* @bug 8257860
27
* @summary SCDynamicStoreConfig works
28
* @modules java.security.jgss/sun.security.krb5
29
* @library /test/lib
30
* @run main/manual/native TestDynamicStore
31
* @requires (os.family == "mac")
32
*/
33
34
import jdk.test.lib.Asserts;
35
import sun.security.krb5.Config;
36
37
public class TestDynamicStore {
38
39
native static int actionInternal(char what, char whom);
40
41
// what: 'a' for add, 'r' for remove
42
// whom: 'a' for all, 'r' for realm, 'm' for mapping
43
static int action(char what, char whom) throws Exception {
44
int out = actionInternal(what, whom);
45
System.out.println("Run " + what + whom + " " + out);
46
Thread.sleep(1000); // wait for callback called
47
return out;
48
}
49
50
public static void main(String[] args) throws Exception {
51
52
System.loadLibrary("TestDynamicStore");
53
54
Config cfg = Config.getInstance();
55
if (cfg.exists("libdefaults") || cfg.exists("realms")) {
56
System.out.println("Already have krb5 config. Will not touch");
57
return;
58
}
59
60
try {
61
System.out.println("Fill in dynamic store");
62
action('a', 'a');
63
Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM"));
64
Asserts.assertTrue(Config.getInstance().exists("domain_realm"));
65
66
System.out.println("Remove mapping");
67
action('r', 'm');
68
Asserts.assertTrue(!Config.getInstance().exists("domain_realm"));
69
70
System.out.println("Re-add mapping");
71
action('a', 'm');
72
Asserts.assertTrue(Config.getInstance().exists("domain_realm"));
73
74
System.out.println("Remove realm info");
75
action('r', 'r');
76
// Realm info is not watched, so no change detected
77
Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM"));
78
79
System.out.println("Remove mapping");
80
action('r', 'm');
81
// But mapping is watched, so realm info is not re-read
82
Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("B.COM"));
83
} finally {
84
System.out.println("Remove everything");
85
action('r', 'a');
86
Asserts.assertTrue(!Config.getInstance().exists("libdefault"));
87
}
88
}
89
}
90
91