Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/security/auth/module/AllPlatforms.java
41154 views
1
/*
2
* Copyright (c) 2014, 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 8039951
27
* @summary com.sun.security.auth.module missing classes on some platforms
28
* @run main/othervm AllPlatforms
29
*/
30
31
import javax.security.auth.login.Configuration;
32
import javax.security.auth.login.LoginContext;
33
import java.nio.file.Files;
34
import java.nio.file.Paths;
35
36
public class AllPlatforms {
37
public static void main(String[] args) throws Exception {
38
login("cross-platform",
39
"UnixLoginModule", "optional",
40
"NTLoginModule", "optional",
41
"SolarisLoginModule", "optional");
42
try {
43
login("windows", "NTLoginModule", "required");
44
login("unix", "UnixLoginModule", "required");
45
login("solaris", "SolarisLoginModule", "required");
46
} catch (Exception e) {
47
e.printStackTrace(System.out);
48
if (e.toString().contains("UnsatisfiedLinkError")) {
49
throw new Exception("This is ugly");
50
}
51
}
52
}
53
54
static void login(String test, String... conf) throws Exception {
55
System.out.println("Testing " + test + "...");
56
57
StringBuilder sb = new StringBuilder();
58
sb.append("hello {\n");
59
for (int i=0; i<conf.length; i+=2) {
60
sb.append(" com.sun.security.auth.module." + conf[i]
61
+ " " + conf[i+1] + ";\n");
62
}
63
sb.append("};\n");
64
Files.write(Paths.get(test), sb.toString().getBytes());
65
66
// Must be called. Configuration has an internal static field.
67
Configuration.setConfiguration(null);
68
System.setProperty("java.security.auth.login.config", test);
69
70
LoginContext lc = new LoginContext("hello");
71
lc.login();
72
System.out.println(lc.getSubject());
73
}
74
}
75
76