Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/auto/KeyTabCompat.java
38853 views
/*1* Copyright (c) 2011, 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 689407226* @bug 800448827* @compile -XDignore.symbol.file KeyTabCompat.java28* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock KeyTabCompat29* @summary always refresh keytab30*/3132import javax.security.auth.kerberos.KerberosKey;33import sun.security.jgss.GSSUtil;3435/*36* There are 2 compat issues to check:37*38* 1. If there is only KerberosKeys in private credential set and no39* KerberosPrincipal. JAAS login should go on.40* 2. If KeyTab is used, user won't get KerberosKeys from41* private credentials set.42*/43public class KeyTabCompat {4445public static void main(String[] args)46throws Exception {47OneKDC kdc = new OneKDC("aes128-cts");48kdc.writeJAASConf();49kdc.addPrincipal(OneKDC.SERVER, "pass1".toCharArray());50kdc.writeKtab(OneKDC.KTAB);5152Context c, s;5354// Part 155c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);56s = Context.fromUserPass(OneKDC.USER2, OneKDC.PASS2, true);5758s.s().getPrincipals().clear();5960c.startAsClient(OneKDC.USER2, GSSUtil.GSS_KRB5_MECH_OID);61s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);6263Context.handshake(c, s);6465// Part 266c = Context.fromJAAS("client");67s = Context.fromJAAS("server");6869c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);70s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);71s.status();7273if (s.s().getPrivateCredentials(KerberosKey.class).size() != 0) {74throw new Exception("There should be no KerberosKey");75}76}77}787980