FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / security / cert / X509CRL.java
blob24773987beda8588dc289736a833eacb443c67da
1 /* X509CRL.java --- X.509 Certificate Revocation List
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.security.cert;
40 import java.math.BigInteger;
41 import java.security.Principal;
42 import java.security.PublicKey;
43 import java.security.NoSuchAlgorithmException;
44 import java.security.InvalidKeyException;
45 import java.security.NoSuchProviderException;
46 import java.security.SignatureException;
47 import java.util.Date;
48 import java.util.Set;
50 /**
51 The X509CRL class is the abstract class used to manage
52 X.509 Certificate Revocation Lists. The CRL is a list of
53 time stamped entries which indicate which lists have been
54 revoked. The list is signed by a Certificate Authority (CA)
55 and made publically available in a repository.
57 Each revoked certificate in the CRL is identified by its
58 certificate serial number. When a piece of code uses a
59 certificate, the certificates validity is checked by
60 validating its signature and determing that it is not
61 only a recently acquired CRL. The recently aquired CRL
62 is depends on the local policy in affect. The CA issues
63 a new CRL periodically and entries are removed as the
64 certificate expiration date is reached
67 A description of the X.509 v2 CRL follows below from rfc2459.
69 "The X.509 v2 CRL syntax is as follows. For signature calculation,
70 the data that is to be signed is ASN.1 DER encoded. ASN.1 DER
71 encoding is a tag, length, value encoding system for each element.
73 CertificateList ::= SEQUENCE {
74 tbsCertList TBSCertList,
75 signatureAlgorithm AlgorithmIdentifier,
76 signatureValue BIT STRING }
78 TBSCertList ::= SEQUENCE {
79 version Version OPTIONAL,
80 -- if present, shall be v2
81 signature AlgorithmIdentifier,
82 issuer Name,
83 thisUpdate Time,
84 nextUpdate Time OPTIONAL,
85 revokedCertificates SEQUENCE OF SEQUENCE {
86 userCertificate CertificateSerialNumber,
87 revocationDate Time,
88 crlEntryExtensions Extensions OPTIONAL
89 -- if present, shall be v2
90 } OPTIONAL,
91 crlExtensions [0] EXPLICIT Extensions OPTIONAL
92 -- if present, shall be v2
95 @author Mark Benvenuto
97 @since JDK 1.2
99 public abstract class X509CRL extends CRL implements X509Extension
103 Constructs a new X509CRL.
105 protected X509CRL()
107 super("X.509");
111 Compares this X509CRL to other. It checks if the
112 object if instanceOf X509CRL and then checks if
113 the encoded form matches.
115 @param other An Object to test for equality
117 @return true if equal, false otherwise
119 public boolean equals(Object other)
121 if( other instanceof X509CRL ) {
122 try {
123 X509CRL x = (X509CRL) other;
124 if( getEncoded().length != x.getEncoded().length )
125 return false;
127 byte b1[] = getEncoded();
128 byte b2[] = x.getEncoded();
130 for( int i = 0; i < b1.length; i++ )
131 if( b1[i] != b2[i] )
132 return false;
134 } catch( CRLException crle ) {
135 return false;
137 return true;
139 return false;
143 Returns a hash code for this X509CRL in its encoded
144 form.
146 @return A hash code of this class
148 public int hashCode()
150 return super.hashCode();
154 Gets the DER ASN.1 encoded format for this X.509 CRL.
156 @return byte array containg encoded form
158 @throws CRLException if an error occurs
160 public abstract byte[] getEncoded() throws CRLException;
163 Verifies that this CRL was properly signed with the
164 PublicKey that corresponds to its private key.
166 @param key PublicKey to verify with
168 @throws CRLException encoding error
169 @throws NoSuchAlgorithmException unsupported algorithm
170 @throws InvalidKeyException incorrect key
171 @throws NoSuchProviderException no provider
172 @throws SignatureException signature error
174 public abstract void verify(PublicKey key)
175 throws CRLException,
176 NoSuchAlgorithmException,
177 InvalidKeyException,
178 NoSuchProviderException,
179 SignatureException;
182 Verifies that this CRL was properly signed with the
183 PublicKey that corresponds to its private key and uses
184 the signature engine provided by the provider.
186 @param key PublicKey to verify with
187 @param sigProvider Provider to use for signature algorithm
189 @throws CRLException encoding error
190 @throws NoSuchAlgorithmException unsupported algorithm
191 @throws InvalidKeyException incorrect key
192 @throws NoSuchProviderException incorrect provider
193 @throws SignatureException signature error
195 public abstract void verify(PublicKey key,
196 String sigProvider)
197 throws CRLException,
198 NoSuchAlgorithmException,
199 InvalidKeyException,
200 NoSuchProviderException,
201 SignatureException;
204 Gets the version of this CRL.
206 The ASN.1 encoding is:
208 version Version OPTIONAL,
209 -- if present, shall be v2
211 Version ::= INTEGER { v1(0), v2(1), v3(2) }
213 Consult rfc2459 for more information.
215 @return the version number, Ex: 1 or 2
217 public abstract int getVersion();
220 Returns the issuer (issuer distinguished name) of the CRL.
221 The issuer is the entity who signed and issued the
222 Certificate Revocation List.
224 The ASN.1 DER encoding is:
226 issuer Name,
228 Name ::= CHOICE {
229 RDNSequence }
231 RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
233 RelativeDistinguishedName ::=
234 SET OF AttributeTypeAndValue
236 AttributeTypeAndValue ::= SEQUENCE {
237 type AttributeType,
238 value AttributeValue }
240 AttributeType ::= OBJECT IDENTIFIER
242 AttributeValue ::= ANY DEFINED BY AttributeType
244 DirectoryString ::= CHOICE {
245 teletexString TeletexString (SIZE (1..MAX)),
246 printableString PrintableString (SIZE (1..MAX)),
247 universalString UniversalString (SIZE (1..MAX)),
248 utf8String UTF8String (SIZE (1.. MAX)),
249 bmpString BMPString (SIZE (1..MAX)) }
251 Consult rfc2459 for more information.
253 @return the issuer in the Principal class
255 public abstract Principal getIssuerDN();
258 Returns the thisUpdate date of the CRL.
260 The ASN.1 DER encoding is:
262 thisUpdate Time,
264 Time ::= CHOICE {
265 utcTime UTCTime,
266 generalTime GeneralizedTime }
268 Consult rfc2459 for more information.
270 @return the thisUpdate date
272 public abstract Date getThisUpdate();
275 Gets the nextUpdate field
277 The ASN.1 DER encoding is:
279 nextUpdate Time OPTIONAL,
281 Time ::= CHOICE {
282 utcTime UTCTime,
283 generalTime GeneralizedTime }
285 Consult rfc2459 for more information.
287 @return the nextUpdate date
289 public abstract Date getNextUpdate();
292 Gets the requeste dX509Entry for the specified
293 certificate serial number.
295 @return a X509CRLEntry representing the X.509 CRL entry
297 public abstract X509CRLEntry getRevokedCertificate(BigInteger serialNumber);
300 Returns a Set of revoked certificates.
302 @return a set of revoked certificates.
304 public abstract Set getRevokedCertificates();
307 Returns the DER ASN.1 encoded tbsCertList which is
308 the basic information of the list and associated certificates
309 in the encoded state. See top for more information.
311 The ASN.1 DER encoding is:
313 tbsCertList TBSCertList,
315 Consult rfc2459 for more information.
317 @return byte array representing tbsCertList
319 public abstract byte[] getTBSCertList() throws CRLException;
323 Returns the signature for the CRL.
325 The ASN.1 DER encoding is:
327 signatureValue BIT STRING
329 Consult rfc2459 for more information.
331 public abstract byte[] getSignature();
334 Returns the signature algorithm used to sign the CRL.
335 An examples is "SHA-1/DSA".
337 The ASN.1 DER encoding is:
339 signatureAlgorithm AlgorithmIdentifier,
341 AlgorithmIdentifier ::= SEQUENCE {
342 algorithm OBJECT IDENTIFIER,
343 parameters ANY DEFINED BY algorithm OPTIONAL }
345 Consult rfc2459 for more information.
347 The algorithm name is determined from the OID.
349 @return a string with the signature algorithm name
351 public abstract String getSigAlgName();
354 Returns the OID for the signature algorithm used.
355 Example "1.2.840.10040.4.3" is return for SHA-1 with DSA.\
357 The ASN.1 DER encoding for the example is:
359 id-dsa-with-sha1 ID ::= {
360 iso(1) member-body(2) us(840) x9-57 (10040)
361 x9cm(4) 3 }
363 Consult rfc2459 for more information.
365 @return a string containing the OID.
367 public abstract String getSigAlgOID();
370 Returns the AlgorithmParameters in the encoded form
371 for the signature algorithm used.
373 If access to the parameters is need, create an
374 instance of AlgorithmParameters.
376 @return byte array containing algorithm parameters, null
377 if no parameters are present in CRL
379 public abstract byte[] getSigAlgParams();