KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > cert > X509CRLEntry


1 /*
2  * @(#)X509CRLEntry.java 1.16 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.security.cert;
9
10 import java.math.BigInteger JavaDoc;
11 import java.util.Date JavaDoc;
12 import java.util.Set JavaDoc;
13
14 import javax.security.auth.x500.X500Principal JavaDoc;
15
16 /**
17  * <p>Abstract class for a revoked certificate in a CRL (Certificate
18  * Revocation List).
19  *
20  * The ASN.1 definition for <em>revokedCertificates</em> is:
21  * <pre>
22  * revokedCertificates SEQUENCE OF SEQUENCE {
23  * userCertificate CertificateSerialNumber,
24  * revocationDate ChoiceOfTime,
25  * crlEntryExtensions Extensions OPTIONAL
26  * -- if present, must be v2
27  * } OPTIONAL
28  *<p>
29  * CertificateSerialNumber ::= INTEGER
30  *<p>
31  * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
32  *<p>
33  * Extension ::= SEQUENCE {
34  * extnId OBJECT IDENTIFIER,
35  * critical BOOLEAN DEFAULT FALSE,
36  * extnValue OCTET STRING
37  * -- contains a DER encoding of a value
38  * -- of the type registered for use with
39  * -- the extnId object identifier value
40  * }
41  * </pre>
42  *
43  * @see X509CRL
44  * @see X509Extension
45  *
46  * @author Hemma Prafullchandra
47  * @version 1.16 03/12/19
48  */

49
50 public abstract class X509CRLEntry implements X509Extension JavaDoc {
51
52     /**
53      * Compares this CRL entry for equality with the given
54      * object. If the <code>other</code> object is an
55      * <code>instanceof</code> <code>X509CRLEntry</code>, then
56      * its encoded form (the inner SEQUENCE) is retrieved and compared
57      * with the encoded form of this CRL entry.
58      *
59      * @param other the object to test for equality with this CRL entry.
60      * @return true iff the encoded forms of the two CRL entries
61      * match, false otherwise.
62      */

63     public boolean equals(Object JavaDoc other) {
64         if (this == other)
65             return true;
66         if (!(other instanceof X509CRLEntry JavaDoc))
67             return false;
68         try {
69             byte[] thisCRLEntry = this.getEncoded();
70             byte[] otherCRLEntry = ((X509CRLEntry JavaDoc)other).getEncoded();
71
72             if (thisCRLEntry.length != otherCRLEntry.length)
73                 return false;
74             for (int i = 0; i < thisCRLEntry.length; i++)
75                  if (thisCRLEntry[i] != otherCRLEntry[i])
76                      return false;
77         } catch (CRLException JavaDoc ce) {
78             return false;
79         }
80         return true;
81     }
82
83     /**
84      * Returns a hashcode value for this CRL entry from its
85      * encoded form.
86      *
87      * @return the hashcode value.
88      */

89     public int hashCode() {
90         int retval = 0;
91         try {
92             byte[] entryData = this.getEncoded();
93             for (int i = 1; i < entryData.length; i++)
94                  retval += entryData[i] * i;
95
96         } catch (CRLException JavaDoc ce) {
97             return(retval);
98         }
99         return(retval);
100     }
101
102     /**
103      * Returns the ASN.1 DER-encoded form of this CRL Entry,
104      * that is the inner SEQUENCE.
105      *
106      * @return the encoded form of this certificate
107      * @exception CRLException if an encoding error occurs.
108      */

109     public abstract byte[] getEncoded() throws CRLException JavaDoc;
110
111     /**
112      * Gets the serial number from this X509CRLEntry,
113      * the <em>userCertificate</em>.
114      *
115      * @return the serial number.
116      */

117     public abstract BigInteger JavaDoc getSerialNumber();
118
119     /**
120      * Get the issuer of the X509Certificate described by this entry. If
121      * the certificate issuer is also the CRL issuer, this method returns
122      * null.
123      *
124      * <p>This method is used with indirect CRLs. The default implementation
125      * always returns null. Subclasses that wish to support indirect CRLs
126      * should override it.
127      *
128      * @return the issuer of the X509Certificate described by this entry
129      * or null if it is issued by the CRL issuer.
130      *
131      * @since 1.5
132      */

133     public X500Principal JavaDoc getCertificateIssuer() {
134     return null;
135     }
136
137     /**
138      * Gets the revocation date from this X509CRLEntry,
139      * the <em>revocationDate</em>.
140      *
141      * @return the revocation date.
142      */

143     public abstract Date JavaDoc getRevocationDate();
144     
145     /**
146      * Returns true if this CRL entry has extensions.
147      *
148      * @return true if this entry has extensions, false otherwise.
149      */

150     public abstract boolean hasExtensions();
151
152     /**
153      * Returns a string representation of this CRL entry.
154      *
155      * @return a string representation of this CRL entry.
156      */

157     public abstract String JavaDoc toString();
158 }
159
Popular Tags