Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/ccache/EmptyCC.java
38853 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 ../../../../java/security/testlibrary/29* @compile -XDignore.symbol.file EmptyCC.java30* @run main EmptyCC tmpcc31* @run main EmptyCC FILE:tmpcc32*/33import java.io.File;34import sun.security.krb5.Credentials;35import sun.security.krb5.PrincipalName;36import sun.security.krb5.internal.ccache.CredentialsCache;3738public class EmptyCC {39public static void main(String[] args) throws Exception {40final PrincipalName pn = new PrincipalName("[email protected]");41final String ccache = args[0];4243if (args.length == 1) {44// Main process, write the ccache and launch sub process45CredentialsCache cache = CredentialsCache.create(pn, ccache);46cache.save();47Proc p = Proc.create("EmptyCC").args(ccache, "readcc")48.env("KRB5CCNAME", ccache).start();49p.waitFor();50} else {51// Sub process, read the ccache52String cc = System.getenv("KRB5CCNAME");53if (!cc.equals(ccache)) {54throw new Exception("env not set correctly");55}56// 8001208: Fix for KRB5CCNAME not complete57// Make sure the ccache is created with bare file name58if (CredentialsCache.getInstance() == null) {59throw new Exception("Cache not instantiated");60}61if (!new File("tmpcc").exists()) {62throw new Exception("File not found");63}64Credentials.acquireTGTFromCache(pn, null);65}66}67}686970