KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > security > cert > Certificate


1 /*
2  * @(#)Certificate.java 1.8 04/02/16
3  *
4  * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7   
8 /*
9  * NOTE:
10  * Because of various external restrictions (i.e. US export
11  * regulations, etc.), the actual source code can not be provided
12  * at this time. This file represents the skeleton of the source
13  * file, so that javadocs of the API can be created.
14  */

15
16 package javax.security.cert;
17
18 import java.security.PublicKey;
19 import java.security.NoSuchAlgorithmException;
20 import java.security.NoSuchProviderException;
21 import java.security.InvalidKeyException;
22 import java.security.SignatureException;
23
24 /**
25  * <p>Abstract class for managing a variety of identity certificates.
26  * An identity certificate is a guarantee by a principal that
27  * a public key is that of another principal. (A principal represents
28  * an entity such as an individual user, a group, or a corporation.)
29  *<p>
30  * This class is an abstraction for certificates that have different
31  * formats but important common uses. For example, different types of
32  * certificates, such as X.509 and PGP, share general certificate
33  * functionality (like encoding and verifying) and
34  * some types of information (like a public key).
35  * <p>
36  * X.509, PGP, and SDSI certificates can all be implemented by
37  * subclassing the Certificate class, even though they contain different
38  * sets of information, and they store and retrieve the information in
39  * different ways.
40  *
41  * <p><em>Note: The classes in the package <code>javax.security.cert</code>
42  * exist for compatibility with earlier versions of the
43  * Java Secure Sockets Extension (JSSE). New applications should instead
44  * use the standard J2SE certificate classes located in
45  * <code>java.security.cert</code>.</em></p>
46  *
47  * @since 1.4
48  * @see X509Certificate
49  *
50  * @author Hemma Prafullchandra
51  * @version 1.16
52  */

53 public abstract class Certificate
54 {
55
56     public Certificate() { }
57
58     /**
59      * Compares this certificate for equality with the specified
60      * object. If the <code>other</code> object is an
61      * <code>instanceof</code> <code>Certificate</code>, then
62      * its encoded form is retrieved and compared with the
63      * encoded form of this certificate.
64      *
65      * @param other the object to test for equality with this certificate.
66      * @return true if the encoded forms of the two certificates
67      * match, false otherwise.
68      */

69     public boolean equals(Object other) {
70         return false;
71     }
72
73     /**
74      * Returns a hashcode value for this certificate from its
75      * encoded form.
76      *
77      * @return the hashcode value.
78      */

79     public int hashCode() {
80         return 0;
81     }
82
83     /**
84      * Returns the encoded form of this certificate. It is
85      * assumed that each certificate type would have only a single
86      * form of encoding; for example, X.509 certificates would
87      * be encoded as ASN.1 DER.
88      *
89      * @return encoded form of this certificate
90      * @exception CertificateEncodingException on internal certificate
91      * encoding failure
92      */

93     public abstract byte[] getEncoded() throws CertificateEncodingException;
94
95     /**
96      * Verifies that this certificate was signed using the
97      * private key that corresponds to the specified public key.
98      *
99      * @param key the PublicKey used to carry out the verification.
100      *
101      * @exception NoSuchAlgorithmException on unsupported signature
102      * algorithms.
103      * @exception InvalidKeyException on incorrect key.
104      * @exception NoSuchProviderException if there's no default provider.
105      * @exception SignatureException on signature errors.
106      * @exception CertificateException on encoding errors.
107      */

108     public abstract void verify(PublicKey key)
109         throws CertificateException, NoSuchAlgorithmException,
110         InvalidKeyException, NoSuchProviderException, SignatureException;
111
112     /**
113      * Verifies that this certificate was signed using the
114      * private key that corresponds to the specified public key.
115      * This method uses the signature verification engine
116      * supplied by the specified provider.
117      *
118      * @param key the PublicKey used to carry out the verification.
119      * @param sigProvider the name of the signature provider.
120      * @exception NoSuchAlgorithmException on unsupported signature algorithms.
121      * @exception InvalidKeyException on incorrect key.
122      * @exception NoSuchProviderException on incorrect provider.
123      * @exception SignatureException on signature errors.
124      * @exception CertificateException on encoding errors.
125      */

126     public abstract void verify(PublicKey key, String sigProvider)
127         throws CertificateException, NoSuchAlgorithmException,
128         InvalidKeyException, NoSuchProviderException, SignatureException;
129
130     /**
131      * Returns a string representation of this certificate.
132      *
133      * @return a string representation of this certificate.
134      */

135     public abstract String toString();
136
137     /**
138      * Gets the public key from this certificate.
139      *
140      * @return the public key.
141      */

142     public abstract PublicKey getPublicKey();
143 }
144
Popular Tags