jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/EncKDCRepPart.java
author avstepan
Fri, 31 Jul 2015 15:07:18 +0300
changeset 32003 acb12269398a
parent 25859 3317bb8137f4
permissions -rw-r--r--
8132130: some docs cleanup Summary: some docs cleanup Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 73
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 73
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 73
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 73
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 73
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *  (C) Copyright IBM Corp. 1999 All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *  Copyright 1997 The Open Group Research Institute.  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
package sun.security.krb5.internal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.krb5.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.security.krb5.EncryptionKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.math.BigInteger;
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    39
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Implements the ASN.1 EncKDCRepPart type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
32003
acb12269398a 8132130: some docs cleanup
avstepan
parents: 25859
diff changeset
    43
 * <pre>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * EncKDCRepPart        ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      key             [0] EncryptionKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      last-req        [1] LastReq,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      nonce           [2] UInt32,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      key-expiration  [3] KerberosTime OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      flags           [4] TicketFlags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      authtime        [5] KerberosTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      starttime       [6] KerberosTime OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      endtime         [7] KerberosTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      renew-till      [8] KerberosTime OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      srealm          [9] Realm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      sname           [10] PrincipalName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      caddr           [11] HostAddresses OPTIONAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * }
32003
acb12269398a 8132130: some docs cleanup
avstepan
parents: 25859
diff changeset
    58
 * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * This definition reflects the Network Working Group RFC 4120
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * specification available at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <a href="http://www.ietf.org/rfc/rfc4120.txt">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * http://www.ietf.org/rfc/rfc4120.txt</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
public class EncKDCRepPart {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    67
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    68
    public EncryptionKey key;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    69
    public LastReq lastReq;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    70
    public int nonce;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    71
    public KerberosTime keyExpiration; //optional
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    72
    public TicketFlags flags;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    73
    public KerberosTime authtime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    74
    public KerberosTime starttime; //optional
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    75
    public KerberosTime endtime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    76
    public KerberosTime renewTill; //optional
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    77
    public PrincipalName sname;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    78
    public HostAddresses caddr; //optional
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    79
    public int msgType; //not included in sequence
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    81
    public EncKDCRepPart(
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    82
            EncryptionKey new_key,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    83
            LastReq new_lastReq,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    84
            int new_nonce,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    85
            KerberosTime new_keyExpiration,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    86
            TicketFlags new_flags,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    87
            KerberosTime new_authtime,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    88
            KerberosTime new_starttime,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    89
            KerberosTime new_endtime,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    90
            KerberosTime new_renewTill,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    91
            PrincipalName new_sname,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    92
            HostAddresses new_caddr,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    93
            int new_msgType) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    94
        key = new_key;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    95
        lastReq = new_lastReq;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    96
        nonce = new_nonce;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    97
        keyExpiration = new_keyExpiration;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    98
        flags = new_flags;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    99
        authtime = new_authtime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   100
        starttime = new_starttime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   101
        endtime = new_endtime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   102
        renewTill = new_renewTill;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   103
        sname = new_sname;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   104
        caddr = new_caddr;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   105
        msgType = new_msgType;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   106
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   108
    public EncKDCRepPart() {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   109
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   111
    public EncKDCRepPart(byte[] data, int rep_type)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   112
            throws Asn1Exception, IOException, RealmException {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   113
        init(new DerValue(data), rep_type);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   114
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   115
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   116
    public EncKDCRepPart(DerValue encoding, int rep_type)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   117
            throws Asn1Exception, IOException, RealmException {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   118
        init(encoding, rep_type);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   119
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   121
    /**
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   122
     * Initializes an EncKDCRepPart object.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   123
     *
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   124
     * @param encoding a single DER-encoded value.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   125
     * @param rep_type type of the encrypted reply message.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   126
     * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   127
     * @exception IOException if an I/O error occurs while reading encoded data.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   128
     * @exception RealmException if an error occurs while decoding an Realm object.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   129
     */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   130
    protected void init(DerValue encoding, int rep_type)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   131
            throws Asn1Exception, IOException, RealmException {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   132
        DerValue der, subDer;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   133
        //implementations return the incorrect tag value, so
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   134
        //we don't use the above line; instead we use the following
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   135
        msgType = (encoding.getTag() & (byte) 0x1F);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   136
        if (msgType != Krb5.KRB_ENC_AS_REP_PART &&
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   137
                msgType != Krb5.KRB_ENC_TGS_REP_PART) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   138
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   140
        der = encoding.getData().getDerValue();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   141
        if (der.getTag() != DerValue.tag_Sequence) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   143
        }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   144
        key = EncryptionKey.parse(der.getData(), (byte) 0x00, false);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   145
        lastReq = LastReq.parse(der.getData(), (byte) 0x01, false);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   146
        subDer = der.getData().getDerValue();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   147
        if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x02) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   148
            nonce = subDer.getData().getBigInteger().intValue();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   149
        } else {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   150
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   152
        keyExpiration = KerberosTime.parse(der.getData(), (byte) 0x03, true);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   153
        flags = TicketFlags.parse(der.getData(), (byte) 0x04, false);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   154
        authtime = KerberosTime.parse(der.getData(), (byte) 0x05, false);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   155
        starttime = KerberosTime.parse(der.getData(), (byte) 0x06, true);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   156
        endtime = KerberosTime.parse(der.getData(), (byte) 0x07, false);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   157
        renewTill = KerberosTime.parse(der.getData(), (byte) 0x08, true);
13247
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 5506
diff changeset
   158
        Realm srealm = Realm.parse(der.getData(), (byte) 0x09, false);
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 5506
diff changeset
   159
        sname = PrincipalName.parse(der.getData(), (byte) 0x0A, false, srealm);
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   160
        if (der.getData().available() > 0) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   161
            caddr = HostAddresses.parse(der.getData(), (byte) 0x0B, true);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   162
        }
14413
e954df027393 6355584: Introduce constrained Kerberos delegation
weijun
parents: 13247
diff changeset
   163
        // We observe extra data from MSAD
e954df027393 6355584: Introduce constrained Kerberos delegation
weijun
parents: 13247
diff changeset
   164
        /*if (der.getData().available() > 0) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   165
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
14413
e954df027393 6355584: Introduce constrained Kerberos delegation
weijun
parents: 13247
diff changeset
   166
        }*/
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   167
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   169
    /**
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   170
     * Encodes an EncKDCRepPart object.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   171
     * @param rep_type type of encrypted reply message.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   172
     * @return byte array of encoded EncKDCRepPart object.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   173
     * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   174
     * @exception IOException if an I/O error occurs while reading encoded data.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   175
     */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   176
    public byte[] asn1Encode(int rep_type) throws Asn1Exception,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   177
            IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        DerOutputStream temp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        DerOutputStream bytes = new DerOutputStream();
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   180
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   181
                true, (byte) 0x00), key.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   182
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   183
                true, (byte) 0x01), lastReq.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   184
        temp.putInteger(BigInteger.valueOf(nonce));
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   185
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   186
                true, (byte) 0x02), temp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   188
        if (keyExpiration != null) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   189
            bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   190
                    true, (byte) 0x03), keyExpiration.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   191
        }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   192
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   193
                true, (byte) 0x04), flags.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   194
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   195
                true, (byte) 0x05), authtime.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   196
        if (starttime != null) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   197
            bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   198
                    true, (byte) 0x06), starttime.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   199
        }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   200
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   201
                true, (byte) 0x07), endtime.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   202
        if (renewTill != null) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   203
            bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   204
                    true, (byte) 0x08), renewTill.asn1Encode());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   206
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
13247
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 5506
diff changeset
   207
                true, (byte) 0x09), sname.getRealm().asn1Encode());
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   208
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   209
                true, (byte) 0x0A), sname.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   210
        if (caddr != null) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   211
            bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   212
                    true, (byte) 0x0B), caddr.asn1Encode());
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   213
        }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   214
        //should use the rep_type to build the encoding
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   215
        //but other implementations do not; it is ignored and
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   216
        //the cached msgType is used instead
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   217
        temp = new DerOutputStream();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   218
        temp.write(DerValue.tag_Sequence, bytes);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   219
        bytes = new DerOutputStream();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   220
        bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   221
                true, (byte) msgType), temp);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   222
        return bytes.toByteArray();
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   223
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
}