jdk/test/sun/security/krb5/auto/KvnoNA.java
author mchung
Thu, 28 May 2015 10:54:48 -0700
changeset 30820 0d4717a011d3
parent 14895 5ad2d7032375
child 31474 7b79555b8073
permissions -rw-r--r--
8081347: Add @modules to jdk_core tests Reviewed-by: alanb, joehw, lancea Contributed-by: alexander.kulyakhtin@oracle.com, alan.bateman@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14895
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     1
/*
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     4
 *
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     8
 *
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    13
 * accompanied this code).
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    14
 *
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    18
 *
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    21
 * questions.
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    22
 */
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    23
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    24
/*
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    25
 * @test
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    26
 * @bug 7197159
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    27
 * @modules java.base/sun.net.spi.nameservice
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    28
 *          java.base/sun.security.util
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    29
 *          java.security.jgss/sun.security.jgss
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    30
 *          java.security.jgss/sun.security.krb5
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    31
 *          java.security.jgss/sun.security.krb5.internal
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    32
 *          java.security.jgss/sun.security.krb5.internal.ccache
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    33
 *          java.security.jgss/sun.security.krb5.internal.crypto
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 14895
diff changeset
    34
 *          java.security.jgss/sun.security.krb5.internal.ktab
14895
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    35
 * @compile -XDignore.symbol.file KvnoNA.java
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    36
 * @run main/othervm KvnoNA
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    37
 * @summary accept different kvno if there no match
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    38
 */
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    39
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    40
import org.ietf.jgss.GSSException;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    41
import sun.security.jgss.GSSUtil;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    42
import sun.security.krb5.KrbException;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    43
import sun.security.krb5.PrincipalName;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    44
import sun.security.krb5.internal.ktab.KeyTab;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    45
import sun.security.krb5.internal.Krb5;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    46
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    47
public class KvnoNA {
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    48
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    49
    public static void main(String[] args)
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    50
            throws Exception {
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    51
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    52
        OneKDC kdc = new OneKDC(null);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    53
        kdc.writeJAASConf();
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    54
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    55
        // In KDC, it's 2
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    56
        char[] pass = "pass2".toCharArray();
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    57
        kdc.addPrincipal(OneKDC.SERVER, pass);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    58
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    59
        // In ktab, kvno is 1 or 3, 3 has the same password
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    60
        KeyTab ktab = KeyTab.create(OneKDC.KTAB);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    61
        PrincipalName p = new PrincipalName(
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    62
            OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    63
        ktab.addEntry(p, "pass1".toCharArray(), 1, true);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    64
        ktab.addEntry(p, "pass2".toCharArray(), 3, true);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    65
        ktab.save();
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    66
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    67
        Context c, s;
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    68
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    69
        c = Context.fromUserPass("dummy", "bogus".toCharArray(), false);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    70
        s = Context.fromJAAS("server");
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    71
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    72
        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    73
        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    74
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    75
        Context.handshake(c, s);
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    76
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    77
        s.dispose();
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    78
        c.dispose();
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    79
    }
5ad2d7032375 7197159: accept different kvno if there no match
weijun
parents:
diff changeset
    80
}