jdk/src/share/classes/java/security/cert/CertificateRevokedException.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 18551 882a3948c6e6
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
     2
 * Copyright (c) 2007, 2013, 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security.cert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.security.auth.x500.X500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.security.util.ObjectIdentifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.security.x509.InvalidityDateExtension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * An exception that indicates an X.509 certificate is revoked. A
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    42
 * {@code CertificateRevokedException} contains additional information
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * about the revoked certificate, such as the date on which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * certificate was revoked and the reason it was revoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author Sean Mullan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @see CertPathValidatorException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class CertificateRevokedException extends CertificateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static final long serialVersionUID = 7839996631571608627L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @serial the date on which the certificate was revoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private Date revocationDate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @serial the revocation reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private final CRLReason reason;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    63
     * @serial the {@code X500Principal} that represents the name of the
6904
999272510ae3 6988599: CertificateRevokedException specifies name of authority but interacts with authority instance
mullan
parents: 5506
diff changeset
    64
     * authority that signed the certificate's revocation status information
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private final X500Principal authority;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private transient Map<String, Extension> extensions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    71
     * Constructs a {@code CertificateRevokedException} with
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * the specified revocation date, reason code, authority name, and map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * of extensions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param revocationDate the date on which the certificate was revoked. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *    date is copied to protect against subsequent modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param reason the revocation reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param extensions a map of X.509 Extensions. Each key is an OID String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *    that maps to the corresponding Extension. The map is copied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *    prevent subsequent modification.
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    81
     * @param authority the {@code X500Principal} that represents the name
6904
999272510ae3 6988599: CertificateRevokedException specifies name of authority but interacts with authority instance
mullan
parents: 5506
diff changeset
    82
     *    of the authority that signed the certificate's revocation status
999272510ae3 6988599: CertificateRevokedException specifies name of authority but interacts with authority instance
mullan
parents: 5506
diff changeset
    83
     *    information
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    84
     * @throws NullPointerException if {@code revocationDate},
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    85
     *    {@code reason}, {@code authority}, or
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
    86
     *    {@code extensions} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public CertificateRevokedException(Date revocationDate, CRLReason reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        X500Principal authority, Map<String, Extension> extensions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        if (revocationDate == null || reason == null || authority == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            extensions == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this.revocationDate = new Date(revocationDate.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        this.reason = reason;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this.authority = authority;
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 6904
diff changeset
    97
        this.extensions = new HashMap<String, Extension>(extensions);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Returns the date on which the certificate was revoked. A new copy is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * returned each time the method is invoked to protect against subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @return the revocation date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public Date getRevocationDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return (Date) revocationDate.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Returns the reason the certificate was revoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @return the revocation reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public CRLReason getRevocationReason() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return reason;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Returns the name of the authority that signed the certificate's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * revocation status information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   124
     * @return the {@code X500Principal} that represents the name of the
6904
999272510ae3 6988599: CertificateRevokedException specifies name of authority but interacts with authority instance
mullan
parents: 5506
diff changeset
   125
     *     authority that signed the certificate's revocation status information
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public X500Principal getAuthorityName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return authority;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18551
diff changeset
   132
     * Returns the invalidity date, as specified in the Invalidity Date
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   133
     * extension of this {@code CertificateRevokedException}. The
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * invalidity date is the date on which it is known or suspected that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * private key was compromised or that the certificate otherwise became
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   136
     * invalid. This implementation calls {@code getExtensions()} and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * checks the returned map for an entry for the Invalidity Date extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * OID ("2.5.29.24"). If found, it returns the invalidity date in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * extension; otherwise null. A new Date object is returned each time the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * method is invoked to protect against subsequent modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   142
     * @return the invalidity date, or {@code null} if not specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public Date getInvalidityDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        Extension ext = getExtensions().get("2.5.29.24");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        if (ext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            try {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 6904
diff changeset
   150
                Date invalidity = InvalidityDateExtension.toImpl(ext).get("DATE");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                return new Date(invalidity.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Returns a map of X.509 extensions containing additional information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * about the revoked certificate, such as the Invalidity Date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Extension. Each key is an OID String that maps to the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @return an unmodifiable map of X.509 extensions, or an empty map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *    if there are no extensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public Map<String, Extension> getExtensions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        return Collections.unmodifiableMap(extensions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public String getMessage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return "Certificate has been revoked, reason: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
               + reason + ", revocation date: " + revocationDate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
               + ", authority: " + authority + ", extensions: " + extensions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   179
     * Serialize this {@code CertificateRevokedException} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @serialData the size of the extensions map (int), followed by all of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * the extensions in the map, in no particular order. For each extension,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * the following data is emitted: the OID String (Object), the criticality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * flag (boolean), the length of the encoded extension value byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * (int), and the encoded extension value bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    private void writeObject(ObjectOutputStream oos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        // Write out the non-transient fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // (revocationDate, reason, authority)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        oos.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        // Write out the size (number of mappings) of the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        oos.writeInt(extensions.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // For each extension in the map, the following are emitted (in order):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        // the OID String (Object), the criticality flag (boolean), the length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        // of the encoded extension value byte array (int), and the encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        // extension value byte array. The extensions themselves are emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        // in no particular order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        for (Map.Entry<String, Extension> entry : extensions.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            Extension ext = entry.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            oos.writeObject(ext.getId());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            oos.writeBoolean(ext.isCritical());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            byte[] extVal = ext.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            oos.writeInt(extVal.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            oos.write(extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   211
     * Deserialize the {@code CertificateRevokedException} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    private void readObject(ObjectInputStream ois)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        // Read in the non-transient fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        // (revocationDate, reason, authority)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        ois.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        // Defensively copy the revocation date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        revocationDate = new Date(revocationDate.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        // Read in the size (number of mappings) of the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        // and create the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        int size = ois.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (size == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            extensions = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            extensions = new HashMap<String, Extension>(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        // Read in the extensions and put the mappings in the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        for (int i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            String oid = (String) ois.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            boolean critical = ois.readBoolean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            int length = ois.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            byte[] extVal = new byte[length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            ois.readFully(extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            Extension ext = sun.security.x509.Extension.newExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                (new ObjectIdentifier(oid), critical, extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            extensions.put(oid, ext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}