jdk/test/sun/security/krb5/PAData.java
author weijun
Wed, 08 May 2013 08:25:34 +0800
changeset 17443 0a7ace07ea11
parent 5506 202f599c92aa
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:
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.security.krb5.internal.KRBError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.security.krb5.internal.Krb5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.security.util.DerValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
public class PAData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
        // This is the dump of a KRB-ERROR data, no sensitive info included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
        byte[] bytes = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
            (byte)0X7E, (byte)0X71, (byte)0X30, (byte)0X6F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
            (byte)0XA0, (byte)0X03, (byte)0X02, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
            (byte)0X05, (byte)0XA1, (byte)0X03, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
            (byte)0X01, (byte)0X1E, (byte)0XA4, (byte)0X11,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
            (byte)0X18, (byte)0X0F, (byte)0X32, (byte)0X30,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
            (byte)0X30, (byte)0X37, (byte)0X30, (byte)0X36,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
            (byte)0X32, (byte)0X31, (byte)0X32, (byte)0X31,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
            (byte)0X30, (byte)0X32, (byte)0X34, (byte)0X33,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
            (byte)0X5A, (byte)0XA5, (byte)0X05, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            (byte)0X03, (byte)0X0A, (byte)0XC8, (byte)0XC5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            (byte)0XA6, (byte)0X03, (byte)0X02, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            (byte)0X12, /* The errorcode at bytes[44] */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                        (byte)0XA9, (byte)0X0A, (byte)0X1B,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            (byte)0X08, (byte)0X4E, (byte)0X33, (byte)0X2E,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            (byte)0X4C, (byte)0X4F, (byte)0X43, (byte)0X41,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            (byte)0X4C, (byte)0XAA, (byte)0X1D, (byte)0X30,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            (byte)0X1B, (byte)0XA0, (byte)0X03, (byte)0X02,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            (byte)0X01, (byte)0X02, (byte)0XA1, (byte)0X14,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            (byte)0X30, (byte)0X12, (byte)0X1B, (byte)0X06,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            (byte)0X6B, (byte)0X72, (byte)0X62, (byte)0X74,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            (byte)0X67, (byte)0X74, (byte)0X1B, (byte)0X08,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            (byte)0X4E, (byte)0X33, (byte)0X2E, (byte)0X4C,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            (byte)0X4F, (byte)0X43, (byte)0X41, (byte)0X4C,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            (byte)0XAC, (byte)0X19, (byte)0X04, (byte)0X17,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            (byte)0X30, (byte)0X15, (byte)0XA1, (byte)0X03,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            (byte)0X02, (byte)0X01, (byte)0X03, (byte)0XA2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            (byte)0X0E, (byte)0X04, (byte)0X0C, (byte)0X72,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            (byte)0X00, (byte)0X00, (byte)0XC0, (byte)0X00,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            (byte)0X00, (byte)0X00, (byte)0X00, (byte)0X01,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            (byte)0X00, (byte)0X00, (byte)0X00
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        String err = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            new KRBError(new DerValue(bytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            err += "Test 1 fails.\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            bytes[44] = Krb5.KDC_ERR_PREAUTH_REQUIRED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            new KRBError(new DerValue(bytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            err += "Test 2 fails.\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            // correct bahavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (err != "") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            throw new Exception(err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}