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