KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > Certificate


1 /*
2  * @(#)Certificate.java 1.37 04/05/18
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package java.security;
9
10 import java.io.*;
11 import java.util.Date JavaDoc;
12
13 /**
14  * <p>This is an interface of abstract methods for managing a
15  * variety of identity certificates.
16  * An identity certificate is a guarantee by a principal that
17  * a public key is that of another principal. (A principal represents
18  * an entity such as an individual user, a group, or a corporation.)
19  *
20  * <p>In particular, this interface is intended to be a common
21  * abstraction for constructs that have different formats but
22  * important common uses. For example, different types of
23  * certificates, such as X.509 certificates and PGP certificates,
24  * share general certificate functionality (the need to encode and
25  * decode certificates) and some types of information, such as a
26  * public key, the principal whose key it is, and the guarantor
27  * guaranteeing that the public key is that of the specified
28  * principal. So an implementation of X.509 certificates and an
29  * implementation of PGP certificates can both utilize the Certificate
30  * interface, even though their formats and additional types and
31  * amounts of information stored are different.
32  *
33  * <p><b>Important</b>: This interface is useful for cataloging and
34  * grouping objects sharing certain common uses. It does not have any
35  * semantics of its own. In particular, a Certificate object does not
36  * make any statement as to the <i>validity</i> of the binding. It is
37  * the duty of the application implementing this interface to verify
38  * the certificate and satisfy itself of its validity.
39  *
40  * @version 1.37, 05/18/04
41  * @author Benjamin Renaud
42  * @deprecated A new certificate handling package is created in the Java 2 platform.
43  * This Certificate interface is entirely deprecated and
44  * is here to allow for a smooth transition to the new
45  * package.
46  * @see java.security.cert.Certificate
47  */

48 @Deprecated JavaDoc
49 public interface Certificate {
50
51     /**
52      * Returns the guarantor of the certificate, that is, the principal
53      * guaranteeing that the public key associated with this certificate
54      * is that of the principal associated with this certificate. For X.509
55      * certificates, the guarantor will typically be a Certificate Authority
56      * (such as the United States Postal Service or Verisign, Inc.).
57      *
58      * @return the guarantor which guaranteed the principal-key
59      * binding.
60      */

61     public abstract Principal JavaDoc getGuarantor();
62     
63     /**
64      * Returns the principal of the principal-key pair being guaranteed by
65      * the guarantor.
66      *
67      * @return the principal to which this certificate is bound.
68      */

69     public abstract Principal JavaDoc getPrincipal();
70
71     /**
72      * Returns the key of the principal-key pair being guaranteed by
73      * the guarantor.
74      *
75      * @return the public key that this certificate certifies belongs
76      * to a particular principal.
77      */

78     public abstract PublicKey JavaDoc getPublicKey();
79
80     /**
81      * Encodes the certificate to an output stream in a format that can
82      * be decoded by the <code>decode</code> method.
83      *
84      * @param stream the output stream to which to encode the
85      * certificate.
86      *
87      * @exception KeyException if the certificate is not
88      * properly initialized, or data is missing, etc.
89      *
90      * @exception IOException if a stream exception occurs while
91      * trying to output the encoded certificate to the output stream.
92      *
93      * @see #decode
94      * @see #getFormat
95      */

96     public abstract void encode(OutputStream stream)
97         throws KeyException JavaDoc, IOException;
98
99     /**
100      * Decodes a certificate from an input stream. The format should be
101      * that returned by <code>getFormat</code> and produced by
102      * <code>encode</code>.
103      *
104      * @param stream the input stream from which to fetch the data
105      * being decoded.
106      *
107      * @exception KeyException if the certificate is not properly initialized,
108      * or data is missing, etc.
109      *
110      * @exception IOException if an exception occurs while trying to input
111      * the encoded certificate from the input stream.
112      *
113      * @see #encode
114      * @see #getFormat
115      */

116     public abstract void decode(InputStream stream)
117         throws KeyException JavaDoc, IOException;
118
119
120     /**
121      * Returns the name of the coding format. This is used as a hint to find
122      * an appropriate parser. It could be "X.509", "PGP", etc. This is
123      * the format produced and understood by the <code>encode</code>
124      * and <code>decode</code> methods.
125      *
126      * @return the name of the coding format.
127      */

128     public abstract String JavaDoc getFormat();
129
130     /**
131      * Returns a string that represents the contents of the certificate.
132      *
133      * @param detailed whether or not to give detailed information
134      * about the certificate
135      *
136      * @return a string representing the contents of the certificate
137      */

138     public String JavaDoc toString(boolean detailed);
139 }
140
Popular Tags