Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/security/auth/login/ConfigFile/PropertyExpansion.java
38889 views
1
/*
2
* Copyright (c) 2000, 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 4337769
27
* @summary ConfigFile should support system property expansion
28
* @run main/othervm/policy=PropertyExpansion.policy -Djava.security.auth.login.config==file:${test.src}/PropertyExpansion.config PropertyExpansion
29
*/
30
31
import com.sun.security.auth.login.*;
32
import javax.security.auth.login.*;
33
34
public class PropertyExpansion {
35
36
public static void main(String[] args) {
37
38
try {
39
ConfigFile config = new ConfigFile();
40
throw new IllegalStateException("test 1 failed");
41
} catch (SecurityException se) {
42
// good
43
se.printStackTrace();
44
}
45
46
Configuration config = null;
47
try {
48
config = Configuration.getConfiguration();
49
} catch (SecurityException se) {
50
System.out.println("test 2 failed");
51
throw se;
52
}
53
54
AppConfigurationEntry[] entries =
55
config.getAppConfigurationEntry("PropertyExpansion");
56
57
// there are 2 entries
58
if (entries.length != 2)
59
throw new IllegalStateException("test 2 failed");
60
61
for (int i = 0; i < 2; i++) {
62
System.out.println("module " + i + " = " +
63
entries[i].getLoginModuleName());
64
System.out.println("control flag " + i + " = " +
65
entries[i].getControlFlag());
66
java.util.Map map = entries[i].getOptions();
67
System.out.println("option " + i + " = useFile, " +
68
"value = " + map.get("useFile"));
69
System.out.println("option " + i + " = debug, " +
70
"value = " + map.get("debug"));
71
72
if (i == 0 && map.get("useFile") == null ||
73
i == 0 && map.get("debug") != null) {
74
throw new IllegalStateException("test 3 failed");
75
}
76
if (i == 1 && map.get("useFile") != null ||
77
i == 1 && map.get("debug") == null) {
78
throw new IllegalStateException("test 4 failed");
79
}
80
}
81
82
System.out.println("test succeeded");
83
84
}
85
}
86
87