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 * @modules java.security.jgss/sun.security.krb5 31 * java.security.jgss/sun.security.krb5.internal.ccache 32 * @compile -XDignore.symbol.file EmptyCC.java 33 * @run main EmptyCC tmpcc 34 * @run main EmptyCC FILE:tmpcc 35 */ 36 import java.io.File; 37 import sun.security.krb5.Credentials; 38 import sun.security.krb5.PrincipalName; 39 import sun.security.krb5.internal.ccache.CredentialsCache; 40 41 public class EmptyCC { 42 public static void main(String[] args) throws Exception { 43 final PrincipalName pn = new PrincipalName("dummy@FOO.COM"); 44 final String ccache = args[0]; 45 46 if (args.length == 1) { 47 // Main process, write the ccache and launch sub process 48 CredentialsCache cache = CredentialsCache.create(pn, ccache); 49 cache.save(); 50 Proc p = Proc.create("EmptyCC").args(ccache, "readcc") 51 .env("KRB5CCNAME", ccache).start(); 52 p.waitFor(); 53 } else { 54 // Sub process, read the ccache 55 String cc = System.getenv("KRB5CCNAME"); 56 if (!cc.equals(ccache)) { 57 throw new Exception("env not set correctly"); 58 } 59 // 8001208: Fix for KRB5CCNAME not complete 60 // Make sure the ccache is created with bare file name 61 if (CredentialsCache.getInstance() == null) { 62 throw new Exception("Cache not instantiated"); 63 } 64 if (!new File("tmpcc").exists()) { 65 throw new Exception("File not found"); 66 } 67 Credentials.acquireTGTFromCache(pn, null); 68 } 69 } 70 }