001: /*
002: * @(#)Certificate.java 1.38 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package java.security;
029:
030: import java.io.*;
031: import java.util.Date;
032:
033: /**
034: * <p>This is an interface of abstract methods for managing a
035: * variety of identity certificates.
036: * An identity certificate is a guarantee by a principal that
037: * a public key is that of another principal. (A principal represents
038: * an entity such as an individual user, a group, or a corporation.)
039: *
040: * <p>In particular, this interface is intended to be a common
041: * abstraction for constructs that have different formats but
042: * important common uses. For example, different types of
043: * certificates, such as X.509 certificates and PGP certificates,
044: * share general certificate functionality (the need to encode and
045: * decode certificates) and some types of information, such as a
046: * public key, the principal whose key it is, and the guarantor
047: * guaranteeing that the public key is that of the specified
048: * principal. So an implementation of X.509 certificates and an
049: * implementation of PGP certificates can both utilize the Certificate
050: * interface, even though their formats and additional types and
051: * amounts of information stored are different.
052: *
053: * <p><b>Important</b>: This interface is useful for cataloging and
054: * grouping objects sharing certain common uses. It does not have any
055: * semantics of its own. In particular, a Certificate object does not
056: * make any statement as to the <i>validity</i> of the binding. It is
057: * the duty of the application implementing this interface to verify
058: * the certificate and satisfy itself of its validity.
059: *
060: * @version 1.31, 02/02/00
061: * @author Benjamin Renaud
062: * @deprecated A new certificate handling package is created in the Java 2 platform.
063: * This Certificate interface is entirely deprecated and
064: * is here to allow for a smooth transition to the new
065: * package.
066: * @see java.security.cert.Certificate
067: */
068: public interface Certificate {
069:
070: /**
071: * Returns the guarantor of the certificate, that is, the principal
072: * guaranteeing that the public key associated with this certificate
073: * is that of the principal associated with this certificate. For X.509
074: * certificates, the guarantor will typically be a Certificate Authority
075: * (such as the United States Postal Service or Verisign, Inc.).
076: *
077: * @return the guarantor which guaranteed the principal-key
078: * binding.
079: */
080: public abstract Principal getGuarantor();
081:
082: /**
083: * Returns the principal of the principal-key pair being guaranteed by
084: * the guarantor.
085: *
086: * @return the principal to which this certificate is bound.
087: */
088: public abstract Principal getPrincipal();
089:
090: /**
091: * Returns the key of the principal-key pair being guaranteed by
092: * the guarantor.
093: *
094: * @return the public key that this certificate certifies belongs
095: * to a particular principal.
096: */
097: public abstract PublicKey getPublicKey();
098:
099: /**
100: * Encodes the certificate to an output stream in a format that can
101: * be decoded by the <code>decode</code> method.
102: *
103: * @param stream the output stream to which to encode the
104: * certificate.
105: *
106: * @exception KeyException if the certificate is not
107: * properly initialized, or data is missing, etc.
108: *
109: * @exception IOException if a stream exception occurs while
110: * trying to output the encoded certificate to the output stream.
111: *
112: * @see #decode
113: * @see #getFormat
114: */
115: public abstract void encode(OutputStream stream)
116: throws KeyException, IOException;
117:
118: /**
119: * Decodes a certificate from an input stream. The format should be
120: * that returned by <code>getFormat</code> and produced by
121: * <code>encode</code>.
122: *
123: * @param stream the input stream from which to fetch the data
124: * being decoded.
125: *
126: * @exception KeyException if the certificate is not properly initialized,
127: * or data is missing, etc.
128: *
129: * @exception IOException if an exception occurs while trying to input
130: * the encoded certificate from the input stream.
131: *
132: * @see #encode
133: * @see #getFormat
134: */
135: public abstract void decode(InputStream stream)
136: throws KeyException, IOException;
137:
138: /**
139: * Returns the name of the coding format. This is used as a hint to find
140: * an appropriate parser. It could be "X.509", "PGP", etc. This is
141: * the format produced and understood by the <code>encode</code>
142: * and <code>decode</code> methods.
143: *
144: * @return the name of the coding format.
145: */
146: public abstract String getFormat();
147:
148: /**
149: * Returns a string that represents the contents of the certificate.
150: *
151: * @param detailed whether or not to give detailed information
152: * about the certificate
153: *
154: * @return a string representing the contents of the certificate
155: */
156: public String toString(boolean detailed);
157: }
|