Path: blob/master/test/jdk/sun/security/krb5/ccache/EmptyCC.java
41155 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 715832926* @bug 800120827* @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()28* @library /test/lib29* @modules java.security.jgss/sun.security.krb530* java.security.jgss/sun.security.krb5.internal.ccache31* @compile -XDignore.symbol.file EmptyCC.java32* @run main EmptyCC tmpcc33* @run main EmptyCC FILE:tmpcc34*/35import java.io.File;3637import jdk.test.lib.process.Proc;38import sun.security.krb5.Credentials;39import sun.security.krb5.PrincipalName;40import sun.security.krb5.internal.ccache.CredentialsCache;4142public class EmptyCC {43public static void main(String[] args) throws Exception {44final PrincipalName pn = new PrincipalName("[email protected]");45final String ccache = args[0];4647if (args.length == 1) {48// Main process, write the ccache and launch sub process49CredentialsCache cache = CredentialsCache.create(pn, ccache);50cache.save();51Proc p = Proc.create("EmptyCC").args(ccache, "readcc")52.env("KRB5CCNAME", ccache).start();53p.waitFor();54} else {55// Sub process, read the ccache56String cc = System.getenv("KRB5CCNAME");57if (!cc.equals(ccache)) {58throw new Exception("env not set correctly");59}60// 8001208: Fix for KRB5CCNAME not complete61// Make sure the ccache is created with bare file name62if (CredentialsCache.getInstance() == null) {63throw new Exception("Cache not instantiated");64}65if (!new File("tmpcc").exists()) {66throw new Exception("File not found");67}68Credentials.acquireTGTFromCache(pn, null);69}70}71}727374