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