home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 July & August / Pcwk78a98.iso / Internet / Javadraw / DATA.Z / Certificate.java < prev    next >
Text File  |  1997-08-30  |  5KB  |  148 lines

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