home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / security / Certificate.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  5.2 KB  |  144 lines

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