3982N/A/*
3982N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3982N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3982N/A *
3982N/A * This code is free software; you can redistribute it and/or modify it
3982N/A * under the terms of the GNU General Public License version 2 only, as
3982N/A * published by the Free Software Foundation.
3982N/A *
3982N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3982N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3982N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3982N/A * version 2 for more details (a copy is included in the LICENSE file that
3982N/A * accompanied this code).
3982N/A *
3982N/A * You should have received a copy of the GNU General Public License version
3982N/A * 2 along with this work; if not, write to the Free Software Foundation,
3982N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3982N/A *
3982N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3982N/A * or visit www.oracle.com if you need additional information or have any
3982N/A * questions.
3982N/A */
3982N/A
3982N/A/*
3982N/A * @test
3982N/A * @bug 7032354
3982N/A * @run main/othervm NoAddresses 1
3982N/A * @run main/othervm NoAddresses 2
3982N/A * @run main/othervm/fail NoAddresses 3
3982N/A * @summary no-addresses should not be used on acceptor side
3982N/A */
3982N/A
3982N/Aimport java.net.InetAddress;
3982N/Aimport org.ietf.jgss.ChannelBinding;
3982N/Aimport sun.security.jgss.GSSUtil;
3982N/Aimport sun.security.krb5.Config;
3982N/A
3982N/Apublic class NoAddresses {
3982N/A
3982N/A public static void main(String[] args)
3982N/A throws Exception {
3982N/A
3982N/A OneKDC kdc = new OneKDC(null);
3982N/A kdc.writeJAASConf();
3982N/A KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
3982N/A "noaddresses = false",
3982N/A "default_keytab_name = " + OneKDC.KTAB);
3982N/A Config.refresh();
3982N/A
3982N/A Context c = Context.fromJAAS("client");
3982N/A Context s = Context.fromJAAS("server");
3982N/A
3982N/A c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
3982N/A s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
3982N/A
3982N/A InetAddress initiator = InetAddress.getLocalHost();
3982N/A InetAddress acceptor = InetAddress.getLocalHost();
3982N/A switch (args[0]) {
3982N/A case "1":
3982N/A // no initiator host address available, should be OK
3982N/A break;
3982N/A case "2":
3982N/A // correct initiator host address, still fine
3982N/A c.x().setChannelBinding(
3982N/A new ChannelBinding(initiator, acceptor, null));
3982N/A s.x().setChannelBinding(
3982N/A new ChannelBinding(initiator, acceptor, null));
3982N/A break;
3982N/A case "3":
3982N/A // incorrect initiator host address, fail
3982N/A initiator = InetAddress.getByAddress(new byte[]{1,1,1,1});
3982N/A c.x().setChannelBinding(
3982N/A new ChannelBinding(initiator, acceptor, null));
3982N/A s.x().setChannelBinding(
3982N/A new ChannelBinding(initiator, acceptor, null));
3982N/A break;
3982N/A }
3982N/A
3982N/A Context.handshake(c, s);
3982N/A }
3982N/A}