1 /*
2 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.security.cert;
27
28 import java.io.ObjectInputStream;
29 import java.io.ObjectOutputStream;
30 import java.io.IOException;
31 import java.util.Collections;
32 import java.util.Date;
33 import java.util.HashMap;
34 import java.util.Map;
35 import javax.security.auth.x500.X500Principal;
36
37 import sun.security.util.ObjectIdentifier;
38 import sun.security.x509.InvalidityDateExtension;
39
40 /**
41 * An exception that indicates an X.509 certificate is revoked. A
42 * {@code CertificateRevokedException} contains additional information
43 * about the revoked certificate, such as the date on which the
44 * certificate was revoked and the reason it was revoked.
45 *
46 * @author Sean Mullan
47 * @since 1.7
48 * @see CertPathValidatorException
49 */
50 public class CertificateRevokedException extends CertificateException {
51
52 private static final long serialVersionUID = 7839996631571608627L;
53
54 /**
55 * @serial the date on which the certificate was revoked
56 */
211 }
212 }
213
214 /**
215 * Deserialize the {@code CertificateRevokedException} instance.
216 */
217 private void readObject(ObjectInputStream ois)
218 throws IOException, ClassNotFoundException {
219 // Read in the non-transient fields
220 // (revocationDate, reason, authority)
221 ois.defaultReadObject();
222
223 // Defensively copy the revocation date
224 revocationDate = new Date(revocationDate.getTime());
225
226 // Read in the size (number of mappings) of the extensions map
227 // and create the extensions map
228 int size = ois.readInt();
229 if (size == 0) {
230 extensions = Collections.emptyMap();
231 } else {
232 extensions = new HashMap<String, Extension>(size);
233 }
234
235 // Read in the extensions and put the mappings in the extensions map
236 for (int i = 0; i < size; i++) {
237 String oid = (String) ois.readObject();
238 boolean critical = ois.readBoolean();
239 int length = ois.readInt();
240 byte[] extVal = new byte[length];
241 ois.readFully(extVal);
242 Extension ext = sun.security.x509.Extension.newExtension
243 (new ObjectIdentifier(oid), critical, extVal);
244 extensions.put(oid, ext);
245 }
246 }
247 }
|
1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.security.cert;
27
28 import java.io.ObjectInputStream;
29 import java.io.ObjectOutputStream;
30 import java.io.IOException;
31 import java.util.Collections;
32 import java.util.Date;
33 import java.util.HashMap;
34 import java.util.Map;
35 import javax.security.auth.x500.X500Principal;
36
37 import sun.misc.IOUtils;
38 import sun.security.util.ObjectIdentifier;
39 import sun.security.x509.InvalidityDateExtension;
40
41 /**
42 * An exception that indicates an X.509 certificate is revoked. A
43 * {@code CertificateRevokedException} contains additional information
44 * about the revoked certificate, such as the date on which the
45 * certificate was revoked and the reason it was revoked.
46 *
47 * @author Sean Mullan
48 * @since 1.7
49 * @see CertPathValidatorException
50 */
51 public class CertificateRevokedException extends CertificateException {
52
53 private static final long serialVersionUID = 7839996631571608627L;
54
55 /**
56 * @serial the date on which the certificate was revoked
57 */
212 }
213 }
214
215 /**
216 * Deserialize the {@code CertificateRevokedException} instance.
217 */
218 private void readObject(ObjectInputStream ois)
219 throws IOException, ClassNotFoundException {
220 // Read in the non-transient fields
221 // (revocationDate, reason, authority)
222 ois.defaultReadObject();
223
224 // Defensively copy the revocation date
225 revocationDate = new Date(revocationDate.getTime());
226
227 // Read in the size (number of mappings) of the extensions map
228 // and create the extensions map
229 int size = ois.readInt();
230 if (size == 0) {
231 extensions = Collections.emptyMap();
232 } else if (size < 0) {
233 throw new IOException("size cannot be negative");
234 } else {
235 extensions = new HashMap<>(size > 20 ? 20 : size);
236 }
237
238 // Read in the extensions and put the mappings in the extensions map
239 for (int i = 0; i < size; i++) {
240 String oid = (String) ois.readObject();
241 boolean critical = ois.readBoolean();
242 byte[] extVal = IOUtils.readNBytes(ois, ois.readInt());
243 Extension ext = sun.security.x509.Extension.newExtension
244 (new ObjectIdentifier(oid), critical, extVal);
245 extensions.put(oid, ext);
246 }
247 }
248 }
|