4590N/A/*
4590N/A * Copyright 2012 Sun Microsystems, Inc. All Rights Reserved.
4590N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4590N/A *
4590N/A * This code is free software; you can redistribute it and/or modify it
4590N/A * under the terms of the GNU General Public License version 2 only, as
4590N/A * published by the Free Software Foundation.
4590N/A *
4590N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4590N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4590N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4590N/A * version 2 for more details (a copy is included in the LICENSE file that
4590N/A * accompanied this code).
4590N/A *
4590N/A * You should have received a copy of the GNU General Public License version
4590N/A * 2 along with this work; if not, write to the Free Software Foundation,
4590N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4590N/A *
4590N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
4590N/A * CA 95054 USA or visit www.sun.com if you need additional information or
4590N/A * have any questions.
4590N/A */
4590N/A
4590N/A/*
4590N/A * @test
4590N/A * @bug 7118809
4590N/A * @run main/othervm ReplayCache
4590N/A * @summary rcache deadlock
4590N/A */
4590N/A
4590N/Aimport org.ietf.jgss.GSSException;
4590N/Aimport sun.security.jgss.GSSUtil;
4590N/Aimport sun.security.krb5.KrbException;
4590N/Aimport sun.security.krb5.internal.Krb5;
4590N/A
4590N/Apublic class ReplayCache {
4590N/A
4590N/A public static void main(String[] args)
4590N/A throws Exception {
4590N/A
4590N/A new OneKDC(null).writeJAASConf();
4590N/A
4590N/A Context c, s;
4590N/A c = Context.fromJAAS("client");
4590N/A s = Context.fromJAAS("server");
4590N/A
4590N/A c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
4590N/A s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
4590N/A
4590N/A byte[] first = c.take(new byte[0]);
4590N/A s.take(first);
4590N/A
4590N/A s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
4590N/A try {
4590N/A s.take(first); // Replay the last token sent
4590N/A throw new Exception("This method should fail");
4590N/A } catch (GSSException gsse) {
4590N/A KrbException ke = (KrbException)gsse.getCause();
4590N/A if (ke.returnCode() != Krb5.KRB_AP_ERR_REPEAT) {
4590N/A throw gsse;
4590N/A }
4590N/A }
4590N/A }
4590N/A}