jdk/test/sun/security/krb5/auto/GSSUnbound.java
author weijun
Wed, 08 May 2013 08:25:34 +0800
changeset 17443 0a7ace07ea11
parent 15649 f6bd3d34f844
child 23010 6dadb192ad81
permissions -rw-r--r--
8012679: Let allow_weak_crypto default to false Reviewed-by: valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15649
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     1
/*
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     4
 *
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     8
 *
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    13
 * accompanied this code).
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    14
 *
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    18
 *
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    21
 * questions.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    22
 */
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    23
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    24
/*
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    25
 * @test
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    26
 * @bug 8001104
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    27
 * @summary Unbound SASL service: the GSSAPI/krb5 mech
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    28
 * @compile -XDignore.symbol.file GSSUnbound.java
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    29
 * @run main/othervm GSSUnbound
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    30
 */
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    31
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    32
import java.security.Security;
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    33
import sun.security.jgss.GSSUtil;
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    34
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    35
// Testing JGSS without JAAS
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    36
public class GSSUnbound {
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    37
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    39
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    40
        new OneKDC(null);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    41
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    42
        Context c, s;
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    43
        c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    44
        s = Context.fromThinAir();
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    45
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    46
        // This is the only setting needed for JGSS without JAAS. The default
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    47
        // JAAS config entries are already created by OneKDC.
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    48
        System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    49
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    50
        c.startAsClient(OneKDC.BACKEND, GSSUtil.GSS_KRB5_MECH_OID);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    51
        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    52
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    53
        Context.handshake(c, s);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    54
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    55
        Context.transmit("i say high --", c, s);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    56
        Context.transmit("   you say low", s, c);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    57
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    58
        s.dispose();
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    59
        c.dispose();
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    60
    }
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents:
diff changeset
    61
}