jdk/test/sun/security/krb5/auto/NonMutualSpnego.java
author weijun
Thu, 18 Mar 2010 18:26:37 +0800
changeset 5154 07af3c279166
parent 1574 7aad9fe14378
child 5506 202f599c92aa
permissions -rw-r--r--
6829283: HTTP/Negotiate: Autheticator triggered again when user cancels the first one Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1574
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     1
/*
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     2
 * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     4
 *
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     8
 *
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    13
 * accompanied this code).
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    14
 *
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    18
 *
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    21
 * have any questions.
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    22
 */
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    23
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    24
/*
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    25
 * @test
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    26
 * @bug 6733095
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    27
 * @summary Failure when SPNEGO request non-Mutual
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    28
 */
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    29
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    30
import sun.security.jgss.GSSUtil;
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    31
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    32
public class NonMutualSpnego {
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    33
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    34
    public static void main(String[] args)
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    35
            throws Exception {
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    36
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    37
        // Create and start the KDC
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    38
        new OneKDC(null).writeJAASConf();
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    39
        new NonMutualSpnego().go();
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    40
    }
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    41
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    42
    void go() throws Exception {
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    43
        Context c = Context.fromJAAS("client");
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    44
        Context s = Context.fromJAAS("server");
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    45
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    46
        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    47
        c.x().requestMutualAuth(false);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    48
        s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    49
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    50
        Context.handshake(c, s);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    51
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    52
        Context.transmit("i say high --", c, s);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    53
        Context.transmit("   you say low", s, c);
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    54
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    55
        c.dispose();
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    56
        s.dispose();
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    57
    }
7aad9fe14378 6733095: Failure when SPNEGO request non-Mutual
weijun
parents:
diff changeset
    58
}