X509CRLEntry.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* X509CRLEntry.java --- X.509 Certificate Revocation List Entry
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.security.cert;
  32. import java.math.BigInteger;
  33. import java.util.Date;
  34. /**
  35. Abstract class for entries in the CRL (Certificate Revocation
  36. List). The ASN.1 definition for <I>revokedCertificates</I> is
  37. revokedCertificates SEQUENCE OF SEQUENCE {
  38. userCertificate CertificateSerialNumber,
  39. revocationDate Time,
  40. crlEntryExtensions Extensions OPTIONAL
  41. -- if present, shall be v2
  42. } OPTIONAL,
  43. CertificateSerialNumber ::= INTEGER
  44. Time ::= CHOICE {
  45. utcTime UTCTime,
  46. generalTime GeneralizedTime }
  47. Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
  48. Extension ::= SEQUENCE {
  49. extnID OBJECT IDENTIFIER,
  50. critical BOOLEAN DEFAULT FALSE,
  51. extnValue OCTET STRING }
  52. For more information consult rfc2459.
  53. @author Mark Benvenuto
  54. @since JDK 1.2
  55. */
  56. public abstract class X509CRLEntry implements X509Extension
  57. {
  58. /**
  59. Creates a new X509CRLEntry
  60. */
  61. public X509CRLEntry()
  62. {}
  63. /**
  64. Compares this X509CRLEntry to other. It checks if the
  65. object if instanceOf X509CRLEntry and then checks if
  66. the encoded form( the inner SEQUENCE) matches.
  67. @param other An Object to test for equality
  68. @return true if equal, false otherwise
  69. */
  70. public boolean equals(Object other)
  71. {
  72. if( other instanceof X509CRLEntry ) {
  73. try {
  74. X509CRLEntry xe = (X509CRLEntry) other;
  75. if( getEncoded().length != xe.getEncoded().length )
  76. return false;
  77. byte b1[] = getEncoded();
  78. byte b2[] = xe.getEncoded();
  79. for( int i = 0; i < b1.length; i++ )
  80. if( b1[i] != b2[i] )
  81. return false;
  82. } catch( CRLException crle ) {
  83. return false;
  84. }
  85. return true;
  86. }
  87. return false;
  88. }
  89. /**
  90. Returns a hash code for this X509CRLEntry in its encoded
  91. form.
  92. @return A hash code of this class
  93. */
  94. public int hashCode()
  95. {
  96. return super.hashCode();
  97. }
  98. /**
  99. Gets the DER ASN.1 encoded format for this CRL Entry,
  100. the inner SEQUENCE.
  101. @return byte array containg encoded form
  102. @throws CRLException if an error occurs
  103. */
  104. public abstract byte[] getEncoded() throws CRLException;
  105. /**
  106. Gets the serial number for <I>userCertificate</I> in
  107. this X509CRLEntry.
  108. @return the serial number for this X509CRLEntry.
  109. */
  110. public abstract BigInteger getSerialNumber();
  111. /**
  112. Gets the revocation date in <I>revocationDate</I> for
  113. this X509CRLEntry.
  114. @return the revocation date for this X509CRLEntry.
  115. */
  116. public abstract Date getRevocationDate();
  117. /**
  118. Checks if this X509CRLEntry has extensions.
  119. @return true if it has extensions, false otherwise
  120. */
  121. public abstract boolean hasExtensions();
  122. /**
  123. Returns a string that represents this X509CRLEntry.
  124. @return a string representing this X509CRLEntry.
  125. */
  126. public abstract String toString();
  127. }