1. /*
  2. * @(#)Certificate.java 1.28 01/11/29
  3. *
  4. * Copyright 2002 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.28 01/11/29
  38. * @author Benjamin Renaud
  39. * @deprecated A new certificate handling package is created in JDK1.2.
  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. public interface Certificate {
  46. /**
  47. * Returns the guarantor of the certificate, that is, the principal
  48. * guaranteeing that the public key associated with this certificate
  49. * is that of the principal associated with this certificate. For X.509
  50. * certificates, the guarantor will typically be a Certificate Authority
  51. * (such as the United States Postal Service or Verisign, Inc.).
  52. *
  53. * @return the guarantor which guaranteed the principal-key
  54. * binding.
  55. */
  56. public abstract Principal getGuarantor();
  57. /**
  58. * Returns the principal of the principal-key pair being guaranteed by
  59. * the guarantor.
  60. *
  61. * @return the principal to which this certificate is bound.
  62. */
  63. public abstract Principal getPrincipal();
  64. /**
  65. * Returns the key of the principal-key pair being guaranteed by
  66. * the guarantor.
  67. *
  68. * @return the public key that this certificate certifies belongs
  69. * to a particular principal.
  70. */
  71. public abstract PublicKey getPublicKey();
  72. /**
  73. * Encodes the certificate to an output stream in a format that can
  74. * be decoded by the <code>decode</code> method.
  75. *
  76. * @param stream the output stream to which to encode the
  77. * certificate.
  78. *
  79. * @exception KeyException if the certificate is not
  80. * properly initialized, or data is missing, etc.
  81. *
  82. * @exception IOException if a stream exception occurs while
  83. * trying to output the encoded certificate to the output stream.
  84. *
  85. * @see #decode
  86. * @see #getFormat
  87. */
  88. public abstract void encode(OutputStream stream)
  89. throws KeyException, IOException;
  90. /**
  91. * Decodes a certificate from an input stream. The format should be
  92. * that returned by <code>getFormat</code> and produced by
  93. * <code>encode</code>.
  94. *
  95. * @param stream the input stream from which to fetch the data
  96. * being decoded.
  97. *
  98. * @exception KeyException if the certificate is not properly initialized,
  99. * or data is missing, etc.
  100. *
  101. * @exception IOException if an exception occurs while trying to input
  102. * the encoded certificate from the input stream.
  103. *
  104. * @see #encode
  105. * @see #getFormat
  106. */
  107. public abstract void decode(InputStream stream)
  108. throws KeyException, IOException;
  109. /**
  110. * Returns the name of the coding format. This is used as a hint to find
  111. * an appropriate parser. It could be "X.509", "PGP", etc. This is
  112. * the format produced and understood by the <code>encode</code>
  113. * and <code>decode</code> methods.
  114. *
  115. * @return the name of the coding format.
  116. */
  117. public abstract String getFormat();
  118. /**
  119. * Returns a string that represents the contents of the certificate.
  120. *
  121. * @param detailed whether or not to give detailed information
  122. * about the certificate.
  123. */
  124. public String toString(boolean detailed);
  125. }