2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2N/A * This code is free software; you can redistribute it and/or modify it 2N/A * under the terms of the GNU General Public License version 2 only, as 2N/A * published by the Free Software Foundation. 2N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2N/A * version 2 for more details (a copy is included in the LICENSE file that 2N/A * accompanied this code). 2N/A * You should have received a copy of the GNU General Public License version 2N/A * 2 along with this work; if not, write to the Free Software Foundation, 2N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2N/A * or visit www.oracle.com if you need additional information or have any 2N/A * @bug 6894643 6913636 2N/A * @summary Test JSSE Kerberos ciphersuite * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_SHA * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_MD5 * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 private static volatile int port;
// Run this after KDC, so our own DNS service can be started // Add 3 versions of keys into keytab // and use the middle one as the real key // JAAS config entry name ssl " com.sun.security.auth.module.Krb5LoginModule required\n" +
" principal=\"host/" +
server +
"\"\n" +
// There's no keytab file when server starts. // Add 3 versions of keys into keytab KeyTab ktab = KeyTab.create(OneKDC.KTAB); PrincipalName service = new PrincipalName( "host/" + server, PrincipalName.KRB_NT_SRV_HST); ktab.addEntry(service, "pass1".toCharArray(), 1); ktab.addEntry(service, "pass2".toCharArray(), 2); ktab.addEntry(service, "pass3".toCharArray(), 3); // and use the middle one as the real key kdc.addPrincipal("host/" + server, "pass2".toCharArray()); // Add another version of key, make sure it can be loaded ktab = KeyTab.create(OneKDC.KTAB); ktab.addEntry(service, "pass5".toCharArray(), 5, false); c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false); c.startAsClient("host/" + server, GSSUtil.GSS_KRB5_MECH_OID); c.doAs(new JsseClientAction(), null); throw new Exception("Should fail this time."); } catch (SSLException e) { // Following codes copied from // Enable only a KRB5 cipher suite. // Should check for exception if enabledSuites is not supported // This line should not be needed. It's the server's duty to //sslSocket.getSession().invalidate(); // Enable only a KRB5 cipher suite. // Should check for exception if enabledSuites is not supported