test/jdk/javax/security/auth/kerberos/KerberosHashEqualsTest.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23357
7225e28e91dd 8033271: Manual security tests have @ignore rather than @run main/manual
wetmore
parents: 5506
diff changeset
     2
 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4641821
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary hashCode() and equals() for KerberosKey and KerberosTicket
23357
7225e28e91dd 8033271: Manual security tests have @ignore rather than @run main/manual
wetmore
parents: 5506
diff changeset
    28
 */
7225e28e91dd 8033271: Manual security tests have @ignore rather than @run main/manual
wetmore
parents: 5506
diff changeset
    29
7225e28e91dd 8033271: Manual security tests have @ignore rather than @run main/manual
wetmore
parents: 5506
diff changeset
    30
/*
7225e28e91dd 8033271: Manual security tests have @ignore rather than @run main/manual
wetmore
parents: 5506
diff changeset
    31
 * Must setup KDC and Kerberos configuration file
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.net.InetAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Date;
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    36
import javax.security.auth.kerberos.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class KerberosHashEqualsTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        new KerberosHashEqualsTest().check();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    void checkSame(Object o1, Object o2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        if(!o1.equals(o2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
            throw new RuntimeException("equals() fails");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        if(o1.hashCode() != o2.hashCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            throw new RuntimeException("hashCode() not same");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    void checkNotSame(Object o1, Object o2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        if(o1.equals(o2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            throw new RuntimeException("equals() succeeds");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    void check() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        KerberosKey k1, k2;
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    60
        k1 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    61
        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        checkSame(k1, k1);  // me to me
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        checkSame(k1, k2);  // same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        k2.destroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        checkNotSame(k1, k2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        checkNotSame(k2, k1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        checkSame(k2, k2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    70
        k1.destroy();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    71
        checkNotSame(k1, k2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    72
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    73
        // Destroyed key has string and hashCode
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    74
        k1.toString(); k1.hashCode();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    75
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        // a little different
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    77
        k1 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    78
        k2 = new KerberosKey(newKP("B"), "pass".getBytes(), 1, 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        checkNotSame(k1, k2);
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    80
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    81
        k2 = new KerberosKey(newKP("A"), "ssap".getBytes(), 1, 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        checkNotSame(k1, k2);
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    83
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    84
        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 2, 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        checkNotSame(k1, k2);
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    86
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
    87
        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        checkNotSame(k1, k2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    90
        // Null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        k1 = new KerberosKey(null, "pass".getBytes(), 1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        checkNotSame(k1, k2); // null to non-null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        k2 = new KerberosKey(null, "pass".getBytes(), 1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        checkSame(k1, k2);    // null to null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    96
        // Even key with null principal has a string and hashCode
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    97
        k1.toString(); k1.hashCode();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
    98
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        checkNotSame(k1, "Another Object");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   101
        EncryptionKey e1, e2;
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   102
        e1 = new EncryptionKey("pass".getBytes(), 1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   103
        e2 = new EncryptionKey("pass".getBytes(), 1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   104
        checkSame(e1, e1);  // me to me
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   105
        checkSame(e1, e2);  // same
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   106
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   107
        e2.destroy();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   108
        checkNotSame(e1, e2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   109
        checkNotSame(e2, e1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   110
        checkSame(e2, e2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   111
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   112
        e1.destroy();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   113
        checkNotSame(e1, e2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   114
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   115
        // Destroyed key has string and hashCode
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   116
        e1.toString(); e1.hashCode();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   117
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   118
        // a little different
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   119
        e1 = new EncryptionKey("pass".getBytes(), 1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   120
        e2 = new EncryptionKey("ssap".getBytes(), 1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   121
        checkNotSame(e1, e2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   122
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   123
        e2 = new EncryptionKey("pass".getBytes(), 2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   124
        checkNotSame(e1, e2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   125
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   126
        checkNotSame(e1, "Another Object");
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   127
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        KerberosTicket t1, t2;
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   129
        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   130
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        checkSame(t1, t1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        checkSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   133
        t2 = new KerberosTicket("asn11".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   135
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client1"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   137
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server1"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   139
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass1".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   141
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 2, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   143
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {false, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   145
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(1), new Date(0), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   147
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(1), new Date(0), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   149
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(1), new Date(0), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        checkNotSame(t1, t2);
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   151
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), new InetAddress[2]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        checkNotSame(t1, t2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   154
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   155
        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        checkSame(t1, t2);  // renewtill is useless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        t2.destroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        checkNotSame(t1, t2);
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   160
        t2.hashCode(); t2.toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        // destroyed tickets doesn't equal to each other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        checkNotSame(t2, t1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        checkSame(t2, t2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   166
        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   167
        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        checkNotSame(t1, t2);  // renewtill is useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        checkNotSame(t1, "Another Object");
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   171
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   172
        KerberosCredMessage m1, m2;
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   173
        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   174
        m2 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   175
        checkSame(m1, m1);  // me to me
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   176
        checkSame(m1, m2);  // same
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   177
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   178
        m2.destroy();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   179
        checkNotSame(m1, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   180
        checkNotSame(m2, m1);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   181
        checkSame(m2, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   182
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   183
        m1.destroy();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   184
        checkNotSame(m1, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   185
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   186
        // Destroyed message has string and hashCode
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   187
        m1.toString(); m1.hashCode();
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   188
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   189
        // a little different
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   190
        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   191
        m2 = new KerberosCredMessage(newKP("A"), newKP("S"), "message".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   192
        checkNotSame(m1, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   193
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   194
        m2 = new KerberosCredMessage(newKP("C"), newKP("B"), "message".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   195
        checkNotSame(m1, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   196
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   197
        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "hello".getBytes());
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   198
        checkNotSame(m1, m2);
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   199
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   200
        checkNotSame(m1, "Another Object");
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23735
diff changeset
   201
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        System.out.println("Good!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
23735
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   204
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   205
    KerberosPrincipal newKP(String s) {
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   206
        return new KerberosPrincipal(s + "@JLABS.SFBAY.SUN.COM");
34d83df87817 8039575: liberate two manual kerberos tests
weijun
parents: 23357
diff changeset
   207
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
}