Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/ccache/EmptyCC.java
38853 views
1
/*
2
* Copyright (c) 2012, 2013, 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 7158329
27
* @bug 8001208
28
* @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()
29
* @library ../../../../java/security/testlibrary/
30
* @compile -XDignore.symbol.file EmptyCC.java
31
* @run main EmptyCC tmpcc
32
* @run main EmptyCC FILE:tmpcc
33
*/
34
import java.io.File;
35
import sun.security.krb5.Credentials;
36
import sun.security.krb5.PrincipalName;
37
import sun.security.krb5.internal.ccache.CredentialsCache;
38
39
public class EmptyCC {
40
public static void main(String[] args) throws Exception {
41
final PrincipalName pn = new PrincipalName("[email protected]");
42
final String ccache = args[0];
43
44
if (args.length == 1) {
45
// Main process, write the ccache and launch sub process
46
CredentialsCache cache = CredentialsCache.create(pn, ccache);
47
cache.save();
48
Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
49
.env("KRB5CCNAME", ccache).start();
50
p.waitFor();
51
} else {
52
// Sub process, read the ccache
53
String cc = System.getenv("KRB5CCNAME");
54
if (!cc.equals(ccache)) {
55
throw new Exception("env not set correctly");
56
}
57
// 8001208: Fix for KRB5CCNAME not complete
58
// Make sure the ccache is created with bare file name
59
if (CredentialsCache.getInstance() == null) {
60
throw new Exception("Cache not instantiated");
61
}
62
if (!new File("tmpcc").exists()) {
63
throw new Exception("File not found");
64
}
65
Credentials.acquireTGTFromCache(pn, null);
66
}
67
}
68
}
69
70