public abstract class Certificate extends java.lang.Object implements java.io.Serializable
This class is used to manage different types of certificates but have important common puposes. Different types of certificates like X.509 and OpenPGP share general certificate functions (like encoding and verifying) and information like public keys.
X.509, OpenPGP, and SDSI can be implemented by subclassing this class even though they differ in storage methods and information stored.
CertificateFactory,
X509Certificate,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
Certificate.CertificateRep
Certificate.CertificateRep is an inner class used to provide an alternate
storage mechanism for serialized Certificates.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Certificate(java.lang.String type)
Constructs a new certificate of the specified type.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other)
Compares this Certificate to other.
|
abstract byte[] |
getEncoded()
Gets the DER ASN.1 encoded format for this Certificate.
|
abstract java.security.PublicKey |
getPublicKey()
Returns the public key stored in the Certificate.
|
java.lang.String |
getType()
Returns the Certificate type.
|
int |
hashCode()
Returns a hash code for this Certificate in its encoded
form.
|
abstract java.lang.String |
toString()
Returns a string representing the Certificate.
|
abstract void |
verify(java.security.PublicKey key)
Verifies that this Certificate was properly signed with the
PublicKey that corresponds to its private key.
|
abstract void |
verify(java.security.PublicKey key,
java.lang.String sigProvider)
Verifies that this Certificate was properly signed with the
PublicKey that corresponds to its private key and uses
the signature engine provided by the provider.
|
protected java.lang.Object |
writeReplace()
Returns a replacement for this certificate to be serialized.
|
protected Certificate(java.lang.String type)
type - a valid standard name for a certificate.public final java.lang.String getType()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - An Object to test for equalityObject.hashCode()public int hashCode()
hashCode in class java.lang.ObjectObject.equals(Object),
System.identityHashCode(Object)public abstract byte[] getEncoded() throws CertificateEncodingException
CertificateEncodingException - if an error occurspublic abstract void verify(java.security.PublicKey key) throws CertificateException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
key - PublicKey to verify withCertificateException - encoding errorjava.security.NoSuchAlgorithmException - unsupported algorithmjava.security.InvalidKeyException - incorrect keyjava.security.NoSuchProviderException - no providerjava.security.SignatureException - signature errorpublic abstract void verify(java.security.PublicKey key, java.lang.String sigProvider) throws CertificateException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
key - PublicKey to verify withsigProvider - Provider to use for signature algorithmCertificateException - encoding errorjava.security.NoSuchAlgorithmException - unsupported algorithmjava.security.InvalidKeyException - incorrect keyjava.security.NoSuchProviderException - incorrect providerjava.security.SignatureException - signature errorpublic abstract java.lang.String toString()
toString in class java.lang.ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)public abstract java.security.PublicKey getPublicKey()
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException
new CertificateRep(getType(), getEncoded());
This thusly replaces the certificate with its name and its
encoded form, which can be deserialized later with the CertificateFactory implementation for this certificate's type.
java.io.ObjectStreamException - If the replacement could not be
created.