| 1 | /* X509CRLEntry.java --- X.509 Certificate Revocation List Entry
|
|---|
| 2 | Copyright (C) 1999 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 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.
|
|---|
| 10 |
|
|---|
| 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.
|
|---|
| 15 |
|
|---|
| 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.
|
|---|
| 20 |
|
|---|
| 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.
|
|---|
| 25 |
|
|---|
| 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. */
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | package java.security.cert;
|
|---|
| 40 | import java.math.BigInteger;
|
|---|
| 41 | import java.util.Date;
|
|---|
| 42 |
|
|---|
| 43 | /**
|
|---|
| 44 | Abstract class for entries in the CRL (Certificate Revocation
|
|---|
| 45 | List). The ASN.1 definition for <I>revokedCertificates</I> is
|
|---|
| 46 |
|
|---|
| 47 | revokedCertificates SEQUENCE OF SEQUENCE {
|
|---|
| 48 | userCertificate CertificateSerialNumber,
|
|---|
| 49 | revocationDate Time,
|
|---|
| 50 | crlEntryExtensions Extensions OPTIONAL
|
|---|
| 51 | -- if present, shall be v2
|
|---|
| 52 | } OPTIONAL,
|
|---|
| 53 |
|
|---|
| 54 | CertificateSerialNumber ::= INTEGER
|
|---|
| 55 |
|
|---|
| 56 | Time ::= CHOICE {
|
|---|
| 57 | utcTime UTCTime,
|
|---|
| 58 | generalTime GeneralizedTime }
|
|---|
| 59 |
|
|---|
| 60 | Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
|
|---|
| 61 |
|
|---|
| 62 | Extension ::= SEQUENCE {
|
|---|
| 63 | extnID OBJECT IDENTIFIER,
|
|---|
| 64 | critical BOOLEAN DEFAULT FALSE,
|
|---|
| 65 | extnValue OCTET STRING }
|
|---|
| 66 |
|
|---|
| 67 | For more information consult rfc2459.
|
|---|
| 68 |
|
|---|
| 69 | @author Mark Benvenuto
|
|---|
| 70 |
|
|---|
| 71 | @since JDK 1.2
|
|---|
| 72 | */
|
|---|
| 73 | public abstract class X509CRLEntry implements X509Extension
|
|---|
| 74 | {
|
|---|
| 75 |
|
|---|
| 76 | /**
|
|---|
| 77 | Creates a new X509CRLEntry
|
|---|
| 78 | */
|
|---|
| 79 | public X509CRLEntry()
|
|---|
| 80 | {}
|
|---|
| 81 |
|
|---|
| 82 | /**
|
|---|
| 83 | Compares this X509CRLEntry to other. It checks if the
|
|---|
| 84 | object if instanceOf X509CRLEntry and then checks if
|
|---|
| 85 | the encoded form( the inner SEQUENCE) matches.
|
|---|
| 86 |
|
|---|
| 87 | @param other An Object to test for equality
|
|---|
| 88 |
|
|---|
| 89 | @return true if equal, false otherwise
|
|---|
| 90 | */
|
|---|
| 91 | public boolean equals(Object other)
|
|---|
| 92 | {
|
|---|
| 93 | if( other instanceof X509CRLEntry ) {
|
|---|
| 94 | try {
|
|---|
| 95 | X509CRLEntry xe = (X509CRLEntry) other;
|
|---|
| 96 | if( getEncoded().length != xe.getEncoded().length )
|
|---|
| 97 | return false;
|
|---|
| 98 |
|
|---|
| 99 | byte b1[] = getEncoded();
|
|---|
| 100 | byte b2[] = xe.getEncoded();
|
|---|
| 101 |
|
|---|
| 102 | for( int i = 0; i < b1.length; i++ )
|
|---|
| 103 | if( b1[i] != b2[i] )
|
|---|
| 104 | return false;
|
|---|
| 105 |
|
|---|
| 106 | } catch( CRLException crle ) {
|
|---|
| 107 | return false;
|
|---|
| 108 | }
|
|---|
| 109 | return true;
|
|---|
| 110 | }
|
|---|
| 111 | return false;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | /**
|
|---|
| 115 | Returns a hash code for this X509CRLEntry in its encoded
|
|---|
| 116 | form.
|
|---|
| 117 |
|
|---|
| 118 | @return A hash code of this class
|
|---|
| 119 | */
|
|---|
| 120 | public int hashCode()
|
|---|
| 121 | {
|
|---|
| 122 | return super.hashCode();
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /**
|
|---|
| 126 | Gets the DER ASN.1 encoded format for this CRL Entry,
|
|---|
| 127 | the inner SEQUENCE.
|
|---|
| 128 |
|
|---|
| 129 | @return byte array containg encoded form
|
|---|
| 130 |
|
|---|
| 131 | @throws CRLException if an error occurs
|
|---|
| 132 | */
|
|---|
| 133 | public abstract byte[] getEncoded() throws CRLException;
|
|---|
| 134 |
|
|---|
| 135 | /**
|
|---|
| 136 | Gets the serial number for <I>userCertificate</I> in
|
|---|
| 137 | this X509CRLEntry.
|
|---|
| 138 |
|
|---|
| 139 | @return the serial number for this X509CRLEntry.
|
|---|
| 140 | */
|
|---|
| 141 | public abstract BigInteger getSerialNumber();
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | /**
|
|---|
| 145 | Gets the revocation date in <I>revocationDate</I> for
|
|---|
| 146 | this X509CRLEntry.
|
|---|
| 147 |
|
|---|
| 148 | @return the revocation date for this X509CRLEntry.
|
|---|
| 149 | */
|
|---|
| 150 | public abstract Date getRevocationDate();
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | /**
|
|---|
| 154 | Checks if this X509CRLEntry has extensions.
|
|---|
| 155 |
|
|---|
| 156 | @return true if it has extensions, false otherwise
|
|---|
| 157 | */
|
|---|
| 158 | public abstract boolean hasExtensions();
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | /**
|
|---|
| 162 | Returns a string that represents this X509CRLEntry.
|
|---|
| 163 |
|
|---|
| 164 | @return a string representing this X509CRLEntry.
|
|---|
| 165 | */
|
|---|
| 166 | public abstract String toString();
|
|---|
| 167 |
|
|---|
| 168 | }
|
|---|