jdk/src/share/classes/java/security/cert/X509CRL.java
author xuelei
Wed, 20 Jan 2010 21:38:37 +0800
changeset 4807 2521b7dcf505
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6862064: incorrect implementation of PKIXParameters.clone() Reviewed-by: weijun, 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
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.security.NoSuchAlgorithmException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.NoSuchProviderException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.InvalidKeyException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.SignatureException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.PublicKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.security.auth.x500.X500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.security.x509.X509CRLImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Abstract class for an X.509 Certificate Revocation List (CRL).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * A CRL is a time-stamped list identifying revoked certificates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * It is signed by a Certificate Authority (CA) and made freely
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * available in a public repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>Each revoked certificate is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * identified in a CRL by its certificate serial number. When a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * certificate-using system uses a certificate (e.g., for verifying a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * remote user's digital signature), that system not only checks the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * certificate signature and validity but also acquires a suitably-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * recent CRL and checks that the certificate serial number is not on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * that CRL.  The meaning of "suitably-recent" may vary with local
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * policy, but it usually means the most recently-issued CRL.  A CA
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * issues a new CRL on a regular periodic basis (e.g., hourly, daily, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * weekly).  Entries are added to CRLs as revocations occur, and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * entry may be removed when the certificate expiration date is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * The X.509 v2 CRL format is described below in ASN.1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * CertificateList  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *     tbsCertList          TBSCertList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *     signatureAlgorithm   AlgorithmIdentifier,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *     signature            BIT STRING  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * More information can be found in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280: Internet X.509
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * Public Key Infrastructure Certificate and CRL Profile</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * The ASN.1 definition of <code>tbsCertList</code> is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * TBSCertList  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *     version                 Version OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *                             -- if present, must be v2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *     signature               AlgorithmIdentifier,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *     issuer                  Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *     thisUpdate              ChoiceOfTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *     nextUpdate              ChoiceOfTime OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *     revokedCertificates     SEQUENCE OF SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *         userCertificate         CertificateSerialNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *         revocationDate          ChoiceOfTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *         crlEntryExtensions      Extensions OPTIONAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *                                 -- if present, must be v2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *         }  OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *     crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *                                  -- if present, must be v2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * CRLs are instantiated using a certificate factory. The following is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * example of how to instantiate an X.509 CRL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <pre><code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * InputStream inStream = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *     inStream = new FileInputStream("fileName-of-crl");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *     CertificateFactory cf = CertificateFactory.getInstance("X.509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *     X509CRL crl = (X509CRL)cf.generateCRL(inStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *     if (inStream != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *         inStream.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * @author Hemma Prafullchandra
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * @see CRL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @see CertificateFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * @see X509Extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
public abstract class X509CRL extends CRL implements X509Extension {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private transient X500Principal issuerPrincipal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Constructor for X.509 CRLs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    protected X509CRL() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        super("X.509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Compares this CRL for equality with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * object. If the <code>other</code> object is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * <code>instanceof</code> <code>X509CRL</code>, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * its encoded form is retrieved and compared with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * encoded form of this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @param other the object to test for equality with this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @return true iff the encoded forms of the two CRLs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * match, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public boolean equals(Object other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (this == other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (!(other instanceof X509CRL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            byte[] thisCRL = X509CRLImpl.getEncodedInternal(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            byte[] otherCRL = X509CRLImpl.getEncodedInternal((X509CRL)other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            return Arrays.equals(thisCRL, otherCRL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        } catch (CRLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            return false;
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
     * Returns a hashcode value for this CRL from its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * encoded form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @return the hashcode value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        int retval = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            byte[] crlData = X509CRLImpl.getEncodedInternal(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            for (int i = 1; i < crlData.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                 retval += crlData[i] * i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        } catch (CRLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Returns the ASN.1 DER-encoded form of this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @return the encoded form of this certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @exception CRLException if an encoding error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public abstract byte[] getEncoded()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        throws CRLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Verifies that this CRL was signed using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * private key that corresponds to the given public key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param key the PublicKey used to carry out the verification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @exception NoSuchAlgorithmException on unsupported signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @exception InvalidKeyException on incorrect key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @exception NoSuchProviderException if there's no default provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @exception SignatureException on signature errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @exception CRLException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public abstract void verify(PublicKey key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        throws CRLException,  NoSuchAlgorithmException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        InvalidKeyException, NoSuchProviderException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        SignatureException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Verifies that this CRL was signed using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * private key that corresponds to the given public key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * This method uses the signature verification engine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * supplied by the given provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param key the PublicKey used to carry out the verification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param sigProvider the name of the signature provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @exception NoSuchAlgorithmException on unsupported signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @exception InvalidKeyException on incorrect key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @exception NoSuchProviderException on incorrect provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @exception SignatureException on signature errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @exception CRLException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public abstract void verify(PublicKey key, String sigProvider)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        throws CRLException, NoSuchAlgorithmException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        InvalidKeyException, NoSuchProviderException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        SignatureException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Gets the <code>version</code> (version number) value from the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * version    Version OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *             -- if present, must be v2<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * Version  ::=  INTEGER  {  v1(0), v2(1), v3(2)  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *             -- v3 does not apply to CRLs but appears for consistency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *             -- with definition of Version for certs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @return the version number, i.e. 1 or 2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public abstract int getVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * <strong>Denigrated</strong>, replaced by {@linkplain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * #getIssuerX500Principal()}. This method returns the <code>issuer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * as an implementation specific Principal object, which should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * relied upon by portable code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Gets the <code>issuer</code> (issuer distinguished name) value from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * the CRL. The issuer name identifies the entity that signed (and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * issued) the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * <p>The issuer name field contains an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * X.500 distinguished name (DN).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * issuer    Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Name ::= CHOICE { RDNSequence }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * RelativeDistinguishedName ::=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *     SET OF AttributeValueAssertion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * AttributeValueAssertion ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *                               AttributeType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *                               AttributeValue }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * AttributeType ::= OBJECT IDENTIFIER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * AttributeValue ::= ANY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * The <code>Name</code> describes a hierarchical name composed of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * such as country name, and corresponding values, such as US.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * The type of the <code>AttributeValue</code> component is determined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * the <code>AttributeType</code>; in general it will be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <code>directoryString</code>. A <code>directoryString</code> is usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * one of <code>PrintableString</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <code>TeletexString</code> or <code>UniversalString</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @return a Principal whose name is the issuer distinguished name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    public abstract Principal getIssuerDN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Returns the issuer (issuer distinguished name) value from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * CRL as an <code>X500Principal</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * It is recommended that subclasses override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @return an <code>X500Principal</code> representing the issuer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *          distinguished name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public X500Principal getIssuerX500Principal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        if (issuerPrincipal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            issuerPrincipal = X509CRLImpl.getIssuerX500Principal(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return issuerPrincipal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Gets the <code>thisUpdate</code> date from the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * thisUpdate   ChoiceOfTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * ChoiceOfTime ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *     utcTime        UTCTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *     generalTime    GeneralizedTime }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @return the <code>thisUpdate</code> date from the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public abstract Date getThisUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Gets the <code>nextUpdate</code> date from the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @return the <code>nextUpdate</code> date from the CRL, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * not present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    public abstract Date getNextUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Gets the CRL entry, if any, with the given certificate serialNumber.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @param serialNumber the serial number of the certificate for which a CRL entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * is to be looked up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @return the entry with the given serial number, or null if no such entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * exists in this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see X509CRLEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public abstract X509CRLEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        getRevokedCertificate(BigInteger serialNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Get the CRL entry, if any, for the given certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * <p>This method can be used to lookup CRL entries in indirect CRLs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * that means CRLs that contain entries from issuers other than the CRL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * issuer. The default implementation will only return entries for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * certificates issued by the CRL issuer. Subclasses that wish to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * support indirect CRLs should override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @param certificate the certificate for which a CRL entry is to be looked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *   up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @return the entry for the given certificate, or null if no such entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *   exists in this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @exception NullPointerException if certificate is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public X509CRLEntry getRevokedCertificate(X509Certificate certificate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        X500Principal certIssuer = certificate.getIssuerX500Principal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        X500Principal crlIssuer = getIssuerX500Principal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        if (certIssuer.equals(crlIssuer) == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        return getRevokedCertificate(certificate.getSerialNumber());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Gets all the entries from this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * This returns a Set of X509CRLEntry objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @return all the entries or null if there are none present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @see X509CRLEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public abstract Set<? extends X509CRLEntry> getRevokedCertificates();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * Gets the DER-encoded CRL information, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * <code>tbsCertList</code> from this CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * This can be used to verify the signature independently.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @return the DER-encoded CRL information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @exception CRLException if an encoding error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public abstract byte[] getTBSCertList() throws CRLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Gets the <code>signature</code> value (the raw signature bits) from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * signature     BIT STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @return the signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    public abstract byte[] getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * Gets the signature algorithm name for the CRL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * signature algorithm. An example is the string "SHA-1/DSA".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * signatureAlgorithm   AlgorithmIdentifier<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * AlgorithmIdentifier  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *     algorithm               OBJECT IDENTIFIER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *     parameters              ANY DEFINED BY algorithm OPTIONAL  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *                             -- contains a value of the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *                             -- registered for use with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *                             -- algorithm object identifier value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * <p>The algorithm name is determined from the <code>algorithm</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * OID string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @return the signature algorithm name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public abstract String getSigAlgName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Gets the signature algorithm OID string from the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * An OID is represented by a set of nonnegative whole numbers separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * by periods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * For example, the string "1.2.840.10040.4.3" identifies the SHA-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * with DSA signature algorithm defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * <a href="http://www.ietf.org/rfc/rfc3279.txt">RFC 3279: Algorithms and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * Identifiers for the Internet X.509 Public Key Infrastructure Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * and CRL Profile</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <p>See {@link #getSigAlgName() getSigAlgName} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * relevant ASN.1 definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @return the signature algorithm OID string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public abstract String getSigAlgOID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * Gets the DER-encoded signature algorithm parameters from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * CRL's signature algorithm. In most cases, the signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * algorithm parameters are null; the parameters are usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * supplied with the public key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * If access to individual parameter values is needed then use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * {@link java.security.AlgorithmParameters AlgorithmParameters}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * and instantiate with the name returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * {@link #getSigAlgName() getSigAlgName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <p>See {@link #getSigAlgName() getSigAlgName} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * relevant ASN.1 definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @return the DER-encoded signature algorithm parameters, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *         null if no parameters are present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    public abstract byte[] getSigAlgParams();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
}