1/*
2 * Copyright (c) 2005, 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
26package sun.security.x509;
27
28import java.io.IOException;
29import java.io.OutputStream;
30import java.math.BigInteger;
31import java.util.Enumeration;
32
33import sun.security.util.*;
34
35/**
36 * Represents the Delta CRL Indicator Extension.
37 *
38 * <p>
39 * The extension identifies a CRL as being a delta CRL.
40 * Delta CRLs contain updates to revocation information previously distributed,
41 * rather than all the information that would appear in a complete CRL.
42 * The extension contains a CRL number that identifies the CRL, complete for a
43 * given scope, that was used as the starting point in the generation of
44 * this delta CRL.
45 *
46 * <p>
47 * The extension is defined in Section 5.2.4 of
48 * <a href="http://www.ietf.org/rfc/rfc3280.txt">Internet X.509 PKI Certific
49ate and Certificate Revocation List (CRL) Profile</a>.
50 *
51 * <p>
52 * Its ASN.1 definition is as follows:
53 * <pre>
54 *     id-ce-deltaCRLIndicator OBJECT IDENTIFIER ::= { id-ce 27 }
55 *
56 *     BaseCRLNumber ::= CRLNumber
57 *     CRLNumber ::= INTEGER (0..MAX)
58 * </pre>
59 *
60 * @since 1.6
61 */
62public class DeltaCRLIndicatorExtension extends CRLNumberExtension {
63
64    /**
65     * Attribute name.
66     */
67    public static final String NAME = "DeltaCRLIndicator";
68
69    private static final String LABEL = "Base CRL Number";
70
71    /**
72     * Creates a delta CRL indicator extension with the integer value .
73     * The criticality is set to true.
74     *
75     * @param crlNum the value to be set for the extension.
76     */
77    public DeltaCRLIndicatorExtension(int crlNum) throws IOException {
78        super(PKIXExtensions.DeltaCRLIndicator_Id, true,
79            BigInteger.valueOf(crlNum), NAME, LABEL);
80    }
81
82    /**
83     * Creates a delta CRL indictor extension with the BigInteger value .
84     * The criticality is set to true.
85     *
86     * @param crlNum the value to be set for the extension.
87     */
88    public DeltaCRLIndicatorExtension(BigInteger crlNum) throws IOException {
89        super(PKIXExtensions.DeltaCRLIndicator_Id, true, crlNum, NAME, LABEL);
90    }
91
92    /**
93     * Creates the extension from the passed DER encoded value of the same.
94     *
95     * @param critical true if the extension is to be treated as critical.
96     * @param value an array of DER encoded bytes of the actual value.
97     * @exception ClassCastException if value is not an array of bytes
98     * @exception IOException on decoding error.
99     */
100    public DeltaCRLIndicatorExtension(Boolean critical, Object value)
101    throws IOException {
102        super(PKIXExtensions.DeltaCRLIndicator_Id, critical.booleanValue(),
103            value, NAME, LABEL);
104    }
105
106    /**
107     * Writes the extension to the DerOutputStream.
108     *
109     * @param out the DerOutputStream to write the extension to.
110     * @exception IOException on encoding errors.
111     */
112    public void encode(OutputStream out) throws IOException {
113       DerOutputStream  tmp = new DerOutputStream();
114        super.encode(out, PKIXExtensions.DeltaCRLIndicator_Id, true);
115    }
116}
117