Test5653.java revision 2036
2036N/A/*
2036N/A * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
2036N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2036N/A *
2036N/A * This code is free software; you can redistribute it and/or modify it
2036N/A * under the terms of the GNU General Public License version 2 only, as
2036N/A * published by the Free Software Foundation.
2036N/A *
2036N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2036N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2036N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2036N/A * version 2 for more details (a copy is included in the LICENSE file that
2036N/A * accompanied this code).
2036N/A *
2036N/A * You should have received a copy of the GNU General Public License version
2036N/A * 2 along with this work; if not, write to the Free Software Foundation,
2036N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2036N/A *
2036N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
2036N/A * CA 95054 USA or visit www.sun.com if you need additional information or
2036N/A * have any questions.
2036N/A */
2036N/A
2036N/A/*
2036N/A * @test
2036N/A * @bug 6895424
2036N/A * @summary RFC 5653
2036N/A */
2036N/A
2036N/Aimport org.ietf.jgss.GSSContext;
2036N/Aimport org.ietf.jgss.GSSManager;
2036N/Aimport org.ietf.jgss.GSSName;
2036N/Aimport org.ietf.jgss.Oid;
2036N/Aimport sun.security.jgss.GSSUtil;
2036N/A
2036N/Apublic class Test5653 {
2036N/A
2036N/A public static void main(String[] args)
2036N/A throws Exception {
2036N/A
2036N/A Oid oldOid = new Oid("1.3.6.1.5.6.2");
2036N/A new OneKDC(null).writeJAASConf();
2036N/A
2036N/A System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
2036N/A GSSManager m = GSSManager.getInstance();
2036N/A boolean found = false;
2036N/A
2036N/A // Test 1: the getMechsForName() method accepts it.
2036N/A for (Oid tmp: m.getMechsForName(oldOid)) {
2036N/A if (tmp.equals(GSSUtil.GSS_KRB5_MECH_OID)) {
2036N/A found = true;
2036N/A break;
2036N/A }
2036N/A }
2036N/A if (!found) {
2036N/A throw new Exception("Cannot found krb5 mech for old name type");
2036N/A }
2036N/A
2036N/A // Test 2: the createName() method accepts it.
2036N/A GSSName name = m.createName("server@host.rabbit.hole", oldOid);
2036N/A
2036N/A // Test 3: its getStringNameType() output is correct
2036N/A if (!name.getStringNameType().equals(GSSName.NT_HOSTBASED_SERVICE)) {
2036N/A throw new Exception("GSSName not correct name type");
2036N/A }
2036N/A
2036N/A // Test 4: everything still works.
2036N/A GSSContext c1 = m.createContext(
2036N/A name,
2036N/A GSSUtil.GSS_KRB5_MECH_OID,
2036N/A null,
2036N/A GSSContext.DEFAULT_LIFETIME);
2036N/A byte[] token = c1.initSecContext(new byte[0], 0, 0);
2036N/A
2036N/A Context s;
2036N/A s = Context.fromJAAS("server");
2036N/A s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
2036N/A s.x().acceptSecContext(token, 0, token.length);
2036N/A }
2036N/A}