jdk/test/sun/security/krb5/TestPAData.java
author stefank
Mon, 04 Apr 2016 09:15:01 +0200
changeset 37241 b9961c99c356
parent 30820 0d4717a011d3
permissions -rw-r--r--
8152538: UL doesn't inline the LogTagSet::is_level check Reviewed-by: mlarsson, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, 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
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 6570062
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Kerberos authentication regression
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 23044
diff changeset
    27
 * @modules java.base/sun.security.util
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 23044
diff changeset
    28
 *          java.security.jgss/sun.security.krb5.internal
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.security.krb5.internal.KRBError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.security.krb5.internal.Krb5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.util.DerValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
23044
14d277dbc8e0 8036104: Rename the PAData.java test
weijun
parents: 5506
diff changeset
    35
public class TestPAData {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        // This is the dump of a KRB-ERROR data, no sensitive info included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        byte[] bytes = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
            (byte)0X7E, (byte)0X71, (byte)0X30, (byte)0X6F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
            (byte)0XA0, (byte)0X03, (byte)0X02, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
            (byte)0X05, (byte)0XA1, (byte)0X03, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
            (byte)0X01, (byte)0X1E, (byte)0XA4, (byte)0X11,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
            (byte)0X18, (byte)0X0F, (byte)0X32, (byte)0X30,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
            (byte)0X30, (byte)0X37, (byte)0X30, (byte)0X36,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
            (byte)0X32, (byte)0X31, (byte)0X32, (byte)0X31,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            (byte)0X30, (byte)0X32, (byte)0X34, (byte)0X33,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            (byte)0X5A, (byte)0XA5, (byte)0X05, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            (byte)0X03, (byte)0X0A, (byte)0XC8, (byte)0XC5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
            (byte)0XA6, (byte)0X03, (byte)0X02, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            (byte)0X12, /* The errorcode at bytes[44] */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                        (byte)0XA9, (byte)0X0A, (byte)0X1B,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            (byte)0X08, (byte)0X4E, (byte)0X33, (byte)0X2E,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            (byte)0X4C, (byte)0X4F, (byte)0X43, (byte)0X41,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            (byte)0X4C, (byte)0XAA, (byte)0X1D, (byte)0X30,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            (byte)0X1B, (byte)0XA0, (byte)0X03, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            (byte)0X01, (byte)0X02, (byte)0XA1, (byte)0X14,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            (byte)0X30, (byte)0X12, (byte)0X1B, (byte)0X06,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            (byte)0X6B, (byte)0X72, (byte)0X62, (byte)0X74,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            (byte)0X67, (byte)0X74, (byte)0X1B, (byte)0X08,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            (byte)0X4E, (byte)0X33, (byte)0X2E, (byte)0X4C,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            (byte)0X4F, (byte)0X43, (byte)0X41, (byte)0X4C,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            (byte)0XAC, (byte)0X19, (byte)0X04, (byte)0X17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            (byte)0X30, (byte)0X15, (byte)0XA1, (byte)0X03,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            (byte)0X02, (byte)0X01, (byte)0X03, (byte)0XA2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            (byte)0X0E, (byte)0X04, (byte)0X0C, (byte)0X72,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            (byte)0X00, (byte)0X00, (byte)0XC0, (byte)0X00,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            (byte)0X00, (byte)0X00, (byte)0X00, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            (byte)0X00, (byte)0X00, (byte)0X00
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        String err = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            new KRBError(new DerValue(bytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            err += "Test 1 fails.\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            bytes[44] = Krb5.KDC_ERR_PREAUTH_REQUIRED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            new KRBError(new DerValue(bytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            err += "Test 2 fails.\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            // correct bahavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        if (err != "") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            throw new Exception(err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}