jdk/test/sun/security/krb5/auto/AcceptorSubKey.java
author stefank
Mon, 25 Aug 2014 09:10:13 +0200
changeset 26314 f8bc1966fb30
parent 23010 6dadb192ad81
child 30820 0d4717a011d3
permissions -rw-r--r--
8055416: Several vm/gc/heap/summary "After GC" events emitted for the same GC ID Reviewed-by: brutisso, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 18536
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     4
 *
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     8
 *
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    13
 * accompanied this code).
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    14
 *
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    18
 *
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    21
 * questions.
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    22
 */
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    23
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    24
/*
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    25
 * @test
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    26
 * @bug 7077646
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    27
 * @summary gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    28
 * @compile -XDignore.symbol.file AcceptorSubKey.java
18536
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    29
 * @run main/othervm AcceptorSubKey 0
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    30
 * @run main/othervm AcceptorSubKey 4
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    31
 */
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    32
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    33
import sun.security.jgss.GSSUtil;
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    34
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    35
// The basic krb5 test skeleton you can copy from
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    36
public class AcceptorSubKey {
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    37
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    39
18536
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    40
        int expected = Integer.parseInt(args[0]);
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    41
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    42
        new OneKDC(null).writeJAASConf();
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    43
18536
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    44
        if (expected != 0) {
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    45
            System.setProperty("sun.security.krb5.acceptor.subkey", "true");
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    46
        }
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    47
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    48
        Context c, s;
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    49
        c = Context.fromJAAS("client");
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    50
        s = Context.fromJAAS("server");
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    51
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    52
        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    53
        s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    54
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    55
        Context.handshake(c, s);
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    56
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    57
        byte[] msg = "i say high --".getBytes();
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    58
        byte[] wrapped = s.wrap(msg, false);
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    59
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    60
        // FLAG_ACCEPTOR_SUBKEY is 4
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    61
        int flagOn = wrapped[2] & 4;
18536
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    62
        if (flagOn != expected) {
092411ced388 8001326: Improve Kerberos caching
weijun
parents: 10697
diff changeset
    63
            throw new Exception("not expected");
10697
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    64
        }
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    65
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    66
        s.dispose();
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    67
        c.dispose();
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    68
    }
ecee258b7d87 7077646: gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
weijun
parents:
diff changeset
    69
}