Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/auto/MSOID2.java
38854 views
/*1* Copyright (c) 2015, 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 807843926* @summary SPNEGO auth fails if client proposes MS krb5 OID27* @compile -XDignore.symbol.file MSOID2.java28* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock MSOID229*/3031import sun.security.jgss.GSSUtil;3233// The basic krb5 test skeleton you can copy from34public class MSOID2 {3536public static void main(String[] args) throws Exception {3738new OneKDC(null).writeJAASConf();3940Context c, s;41c = Context.fromJAAS("client");42s = Context.fromJAAS("server");4344c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);45s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);4647byte[] t = new byte[0];48boolean first = true;49while (true) {50if (t != null || !c.x().isEstablished()) t = c.take(t);51if (first) {52// Tweak the packet to append an extra OID53int len = t.length;54byte[] nt = new byte[len + 11];55System.arraycopy(t, 0, nt, 0, 0x23);56System.arraycopy(t, 0x18, nt, 0x23, 11); // dup the OID57System.arraycopy(t, 0x23, nt, 0x2e, len-0x23);58nt[0x1d] = (byte)0x82; // change the 1st to MS OID59// Length bytes to be tweaked60for (int pos: new int[] {3, 0xf, 0x13, 0x15, 0x17}) {61nt[pos] = (byte)(nt[pos] + 11);62}63t = nt;64new sun.misc.HexDumpEncoder().encodeBuffer(t, System.out);65}66if (t != null || !s.x().isEstablished()) t = s.take(t);67if (c.x().isEstablished() && s.x().isEstablished()) break;68first = false;69}7071Context.transmit("i say high --", c, s);72Context.transmit(" you say low", s, c);7374s.dispose();75c.dispose();76}77}787980