jdk/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java
author darcy
Thu, 23 Apr 2015 18:51:18 -0700
changeset 30033 b9c86c17164a
parent 27073 fc35bdd9a8eb
permissions -rw-r--r--
8078468: Update security libraries to use diamond with anonymous classes Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
27073
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
     2
 * Copyright (c) 2007, 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
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}
27073
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
    87
     * @throws ClassCastException if {@code extensions} contains an incorrectly
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
    88
     *    typed key or value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public CertificateRevokedException(Date revocationDate, CRLReason reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        X500Principal authority, Map<String, Extension> extensions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (revocationDate == null || reason == null || authority == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            extensions == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this.revocationDate = new Date(revocationDate.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.reason = reason;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.authority = authority;
27073
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
    99
        // make sure Map only contains correct types
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
   100
        this.extensions = Collections.checkedMap(new HashMap<>(),
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
   101
                                                 String.class, Extension.class);
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
   102
        this.extensions.putAll(extensions);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns the date on which the certificate was revoked. A new copy is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * returned each time the method is invoked to protect against subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @return the revocation date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public Date getRevocationDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return (Date) revocationDate.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Returns the reason the certificate was revoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @return the revocation reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public CRLReason getRevocationReason() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return reason;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Returns the name of the authority that signed the certificate's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * revocation status information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   129
     * @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
   130
     *     authority that signed the certificate's revocation status information
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public X500Principal getAuthorityName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return authority;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18551
diff changeset
   137
     * 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
   138
     * extension of this {@code CertificateRevokedException}. The
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * invalidity date is the date on which it is known or suspected that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * 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
   141
     * invalid. This implementation calls {@code getExtensions()} and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * checks the returned map for an entry for the Invalidity Date extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * OID ("2.5.29.24"). If found, it returns the invalidity date in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * extension; otherwise null. A new Date object is returned each time the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * method is invoked to protect against subsequent modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   147
     * @return the invalidity date, or {@code null} if not specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public Date getInvalidityDate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        Extension ext = getExtensions().get("2.5.29.24");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (ext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            try {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 6904
diff changeset
   155
                Date invalidity = InvalidityDateExtension.toImpl(ext).get("DATE");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                return new Date(invalidity.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Returns a map of X.509 extensions containing additional information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * about the revoked certificate, such as the Invalidity Date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Extension. Each key is an OID String that maps to the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return an unmodifiable map of X.509 extensions, or an empty map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *    if there are no extensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public Map<String, Extension> getExtensions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return Collections.unmodifiableMap(extensions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public String getMessage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return "Certificate has been revoked, reason: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
               + reason + ", revocation date: " + revocationDate
27073
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
   180
               + ", authority: " + authority + ", extension OIDs: "
fc35bdd9a8eb 8038364: Use certificate exceptions correctly
mullan
parents: 25859
diff changeset
   181
               + extensions.keySet();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   185
     * Serialize this {@code CertificateRevokedException} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @serialData the size of the extensions map (int), followed by all of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * the extensions in the map, in no particular order. For each extension,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * the following data is emitted: the OID String (Object), the criticality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * flag (boolean), the length of the encoded extension value byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * (int), and the encoded extension value bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    private void writeObject(ObjectOutputStream oos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        // Write out the non-transient fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // (revocationDate, reason, authority)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        oos.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        // Write out the size (number of mappings) of the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        oos.writeInt(extensions.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // For each extension in the map, the following are emitted (in order):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        // the OID String (Object), the criticality flag (boolean), the length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        // of the encoded extension value byte array (int), and the encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // extension value byte array. The extensions themselves are emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // in no particular order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        for (Map.Entry<String, Extension> entry : extensions.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            Extension ext = entry.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            oos.writeObject(ext.getId());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            oos.writeBoolean(ext.isCritical());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            byte[] extVal = ext.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            oos.writeInt(extVal.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            oos.write(extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 10336
diff changeset
   217
     * Deserialize the {@code CertificateRevokedException} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    private void readObject(ObjectInputStream ois)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        // Read in the non-transient fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        // (revocationDate, reason, authority)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        ois.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        // Defensively copy the revocation date
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        revocationDate = new Date(revocationDate.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        // Read in the size (number of mappings) of the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        // and create the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        int size = ois.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if (size == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            extensions = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        } else {
30033
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 27073
diff changeset
   234
            extensions = new HashMap<>(size);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        // Read in the extensions and put the mappings in the extensions map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        for (int i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            String oid = (String) ois.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            boolean critical = ois.readBoolean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            int length = ois.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            byte[] extVal = new byte[length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            ois.readFully(extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            Extension ext = sun.security.x509.Extension.newExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                (new ObjectIdentifier(oid), critical, extVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            extensions.put(oid, ext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}