2110N/A/*
4102N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2110N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2110N/A *
2110N/A * This code is free software; you can redistribute it and/or modify it
2110N/A * under the terms of the GNU General Public License version 2 only, as
2110N/A * published by the Free Software Foundation.
2110N/A *
2110N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2110N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2110N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2110N/A * version 2 for more details (a copy is included in the LICENSE file that
2110N/A * accompanied this code).
2110N/A *
2110N/A * You should have received a copy of the GNU General Public License version
2110N/A * 2 along with this work; if not, write to the Free Software Foundation,
2110N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2110N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2110N/A */
2110N/A/*
2110N/A * @test
2110N/A * @bug 6919610
2110N/A * @summary KeyTabInputStream uses static field for per-instance value
2110N/A */
2110N/Aimport sun.security.krb5.PrincipalName;
2110N/Aimport sun.security.krb5.internal.ktab.KeyTab;
2110N/A
2110N/Apublic class KeyTabIndex {
2110N/A public static void main(String[] args) throws Exception {
2110N/A KeyTab kt = KeyTab.create("ktab");
2110N/A // Two entries with very different length, so that it's easy to
2110N/A // observice the abnormal change of "index" field.
2110N/A kt.addEntry(new PrincipalName(
2110N/A "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@A"),
3043N/A "x".toCharArray(), 1, true);
3043N/A kt.addEntry(new PrincipalName("a@A"), "x".toCharArray(), 1, true);
2110N/A kt.save();
2110N/A Runnable t = new Runnable() {
2110N/A @Override
2110N/A public void run() {
2110N/A KeyTab.getInstance("ktab").getClass();
2110N/A }
2110N/A };
2110N/A for (int i=0; i<10; i++) {
2110N/A new Thread(t).start();
2110N/A }
2110N/A }
2110N/A}