1. /*
  2. * @(#)Certificate.java 1.31 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.security;
  11. import java.io.*;
  12. import java.util.Date;
  13. /**
  14. * <p>This is an interface of abstract methods for managing a
  15. * variety of identity certificates.
  16. * An identity certificate is a guarantee by a principal that
  17. * a public key is that of another principal. (A principal represents
  18. * an entity such as an individual user, a group, or a corporation.)
  19. *
  20. * <p>In particular, this interface is intended to be a common
  21. * abstraction for constructs that have different formats but
  22. * important common uses. For example, different types of
  23. * certificates, such as X.509 certificates and PGP certificates,
  24. * share general certificate functionality (the need to encode and
  25. * decode certificates) and some types of information, such as a
  26. * public key, the principal whose key it is, and the guarantor
  27. * guaranteeing that the public key is that of the specified
  28. * principal. So an implementation of X.509 certificates and an
  29. * implementation of PGP certificates can both utilize the Certificate
  30. * interface, even though their formats and additional types and
  31. * amounts of information stored are different.
  32. *
  33. * <p><b>Important</b>: This interface is useful for cataloging and
  34. * grouping objects sharing certain common uses. It does not have any
  35. * semantics of its own. In particular, a Certificate object does not
  36. * make any statement as to the <i>validity</i> of the binding. It is
  37. * the duty of the application implementing this interface to verify
  38. * the certificate and satisfy itself of its validity.
  39. *
  40. * @version 1.31, 02/02/00
  41. * @author Benjamin Renaud
  42. * @deprecated A new certificate handling package is created in the Java 2 platform.
  43. * This Certificate interface is entirely deprecated and
  44. * is here to allow for a smooth transition to the new
  45. * package.
  46. * @see java.security.cert.Certificate
  47. */
  48. public interface Certificate {
  49. /**
  50. * Returns the guarantor of the certificate, that is, the principal
  51. * guaranteeing that the public key associated with this certificate
  52. * is that of the principal associated with this certificate. For X.509
  53. * certificates, the guarantor will typically be a Certificate Authority
  54. * (such as the United States Postal Service or Verisign, Inc.).
  55. *
  56. * @return the guarantor which guaranteed the principal-key
  57. * binding.
  58. */
  59. public abstract Principal getGuarantor();
  60. /**
  61. * Returns the principal of the principal-key pair being guaranteed by
  62. * the guarantor.
  63. *
  64. * @return the principal to which this certificate is bound.
  65. */
  66. public abstract Principal getPrincipal();
  67. /**
  68. * Returns the key of the principal-key pair being guaranteed by
  69. * the guarantor.
  70. *
  71. * @return the public key that this certificate certifies belongs
  72. * to a particular principal.
  73. */
  74. public abstract PublicKey getPublicKey();
  75. /**
  76. * Encodes the certificate to an output stream in a format that can
  77. * be decoded by the <code>decode</code> method.
  78. *
  79. * @param stream the output stream to which to encode the
  80. * certificate.
  81. *
  82. * @exception KeyException if the certificate is not
  83. * properly initialized, or data is missing, etc.
  84. *
  85. * @exception IOException if a stream exception occurs while
  86. * trying to output the encoded certificate to the output stream.
  87. *
  88. * @see #decode
  89. * @see #getFormat
  90. */
  91. public abstract void encode(OutputStream stream)
  92. throws KeyException, IOException;
  93. /**
  94. * Decodes a certificate from an input stream. The format should be
  95. * that returned by <code>getFormat</code> and produced by
  96. * <code>encode</code>.
  97. *
  98. * @param stream the input stream from which to fetch the data
  99. * being decoded.
  100. *
  101. * @exception KeyException if the certificate is not properly initialized,
  102. * or data is missing, etc.
  103. *
  104. * @exception IOException if an exception occurs while trying to input
  105. * the encoded certificate from the input stream.
  106. *
  107. * @see #encode
  108. * @see #getFormat
  109. */
  110. public abstract void decode(InputStream stream)
  111. throws KeyException, IOException;
  112. /**
  113. * Returns the name of the coding format. This is used as a hint to find
  114. * an appropriate parser. It could be "X.509", "PGP", etc. This is
  115. * the format produced and understood by the <code>encode</code>
  116. * and <code>decode</code> methods.
  117. *
  118. * @return the name of the coding format.
  119. */
  120. public abstract String getFormat();
  121. /**
  122. * Returns a string that represents the contents of the certificate.
  123. *
  124. * @param detailed whether or not to give detailed information
  125. * about the certificate.
  126. */
  127. public String toString(boolean detailed);
  128. }