001 /* X509CRLEntry.java --- X.509 Certificate Revocation List Entry 002 Copyright (C) 1999 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package java.security.cert; 040 041 import java.math.BigInteger; 042 import java.util.Date; 043 044 /** 045 Abstract class for entries in the CRL (Certificate Revocation 046 List). The ASN.1 definition for <I>revokedCertificates</I> is 047 048 revokedCertificates SEQUENCE OF SEQUENCE { 049 userCertificate CertificateSerialNumber, 050 revocationDate Time, 051 crlEntryExtensions Extensions OPTIONAL 052 -- if present, shall be v2 053 } OPTIONAL, 054 055 CertificateSerialNumber ::= INTEGER 056 057 Time ::= CHOICE { 058 utcTime UTCTime, 059 generalTime GeneralizedTime } 060 061 Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension 062 063 Extension ::= SEQUENCE { 064 extnID OBJECT IDENTIFIER, 065 critical BOOLEAN DEFAULT FALSE, 066 extnValue OCTET STRING } 067 068 For more information consult rfc2459. 069 070 @author Mark Benvenuto 071 072 @since JDK 1.2 073 */ 074 public abstract class X509CRLEntry implements X509Extension 075 { 076 077 /** 078 Creates a new X509CRLEntry 079 */ 080 public X509CRLEntry() 081 {} 082 083 /** 084 Compares this X509CRLEntry to other. It checks if the 085 object if instanceOf X509CRLEntry and then checks if 086 the encoded form( the inner SEQUENCE) matches. 087 088 @param other An Object to test for equality 089 090 @return true if equal, false otherwise 091 */ 092 public boolean equals(Object other) 093 { 094 if( other instanceof X509CRLEntry ) { 095 try { 096 X509CRLEntry xe = (X509CRLEntry) other; 097 if( getEncoded().length != xe.getEncoded().length ) 098 return false; 099 100 byte[] b1 = getEncoded(); 101 byte[] b2 = xe.getEncoded(); 102 103 for( int i = 0; i < b1.length; i++ ) 104 if( b1[i] != b2[i] ) 105 return false; 106 107 } catch( CRLException crle ) { 108 return false; 109 } 110 return true; 111 } 112 return false; 113 } 114 115 /** 116 Returns a hash code for this X509CRLEntry in its encoded 117 form. 118 119 @return A hash code of this class 120 */ 121 public int hashCode() 122 { 123 return super.hashCode(); 124 } 125 126 /** 127 Gets the DER ASN.1 encoded format for this CRL Entry, 128 the inner SEQUENCE. 129 130 @return byte array containg encoded form 131 132 @throws CRLException if an error occurs 133 */ 134 public abstract byte[] getEncoded() throws CRLException; 135 136 /** 137 Gets the serial number for <I>userCertificate</I> in 138 this X509CRLEntry. 139 140 @return the serial number for this X509CRLEntry. 141 */ 142 public abstract BigInteger getSerialNumber(); 143 144 145 /** 146 Gets the revocation date in <I>revocationDate</I> for 147 this X509CRLEntry. 148 149 @return the revocation date for this X509CRLEntry. 150 */ 151 public abstract Date getRevocationDate(); 152 153 154 /** 155 Checks if this X509CRLEntry has extensions. 156 157 @return true if it has extensions, false otherwise 158 */ 159 public abstract boolean hasExtensions(); 160 161 162 /** 163 Returns a string that represents this X509CRLEntry. 164 165 @return a string representing this X509CRLEntry. 166 */ 167 public abstract String toString(); 168 169 }