test/jdk/sun/security/krb5/auto/DupEtypes.java
author ssahoo
Thu, 25 Jan 2018 05:57:22 -0800
changeset 48668 2da4a52715d8
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194486: Several krb5 tests failed in Mac. Summary: Several tests failed due to improper host service Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     1
/*
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     4
 *
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     8
 *
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    13
 * accompanied this code).
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    14
 *
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    18
 *
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    21
 * questions.
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    22
 */
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    23
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    24
/*
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    25
 * @test
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    26
 * @bug 7067974 8194486
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    27
 * @summary multiple ETYPE-INFO-ENTRY with same etype and different salt
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    28
 * @library /test/lib
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    29
 * @compile -XDignore.symbol.file DupEtypes.java
48668
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    30
 * @run main jdk.test.lib.FileInstaller TestHosts TestHosts
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    31
 * @run main/othervm -Djdk.net.hosts.file=TestHosts DupEtypes 1
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    32
 * @run main/othervm -Djdk.net.hosts.file=TestHosts DupEtypes 2
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    33
 * @run main/othervm/fail -Djdk.net.hosts.file=TestHosts DupEtypes 3
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    34
 * @run main/othervm -Djdk.net.hosts.file=TestHosts DupEtypes 4
2da4a52715d8 8194486: Several krb5 tests failed in Mac.
ssahoo
parents: 47216
diff changeset
    35
 * @run main/othervm -Djdk.net.hosts.file=TestHosts DupEtypes 5
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    36
 */
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    37
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    38
import sun.security.jgss.GSSUtil;
17443
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    39
import sun.security.krb5.Config;
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    40
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    41
public class DupEtypes {
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    42
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    44
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    45
        OneKDC kdc = new OneKDC(null);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    46
        kdc.writeJAASConf();
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    47
17443
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    48
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    49
                "default_keytab_name = " + OneKDC.KTAB,
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    50
                "allow_weak_crypto = true");
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    51
        Config.refresh();
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    52
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    53
        // Rewrite to include DES keys
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    54
        kdc.writeKtab(OneKDC.KTAB);
0a7ace07ea11 8012679: Let allow_weak_crypto default to false
weijun
parents: 10432
diff changeset
    55
10432
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    56
        // Different test cases, read KDC.processAsReq for details
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    57
        kdc.setOption(KDC.Option.DUP_ETYPE, Integer.parseInt(args[0]));
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    58
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    59
        Context c, s;
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    60
        c = Context.fromJAAS("client");
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    61
        s = Context.fromJAAS("server");
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    62
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    63
        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    64
        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    65
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    66
        Context.handshake(c, s);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    67
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    68
        Context.transmit("i say high --", c, s);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    69
        Context.transmit("   you say low", s, c);
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    70
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    71
        s.dispose();
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    72
        c.dispose();
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    73
    }
ef33e56c55a9 7067974: multiple ETYPE-INFO-ENTRY with same etype and different salt
weijun
parents:
diff changeset
    74
}