Package java.security.cert
Class Certificate
java.lang.Object
java.security.cert.Certificate
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
X509Certificate
public abstract class Certificate extends Object implements Serializable
Abstract class to represent identity certificates. It represents a way to
verify the binding of a Principal and its public key. Examples are X.509,
PGP, and SDSI.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classCertificate.CertificateRepThe alternateSerializableclass to be used for serialization and deserialization ofCertificateobjects. -
Constructor Summary
Constructors Modifier Constructor Description protectedCertificate(String type)Creates a newCertificatewith the specified type. -
Method Summary
Modifier and Type Method Description booleanequals(Object other)Compares the argument to the certificate, and returnstrueif they represent the same object using a class specific comparison.abstract byte[]getEncoded()Returns the encoded representation for this certificate.abstract PublicKeygetPublicKey()Returns the public key corresponding to this certificate.StringgetType()Returns the certificate type.inthashCode()Returns an integer hash code for the certificate.abstract StringtoString()Returns a string containing a concise, human-readable description of the certificate.abstract voidverify(PublicKey key)Verifies that this certificate was signed with the given public key.abstract voidverify(PublicKey key, String sigProvider)Verifies that this certificate was signed with the given public key.protected ObjectwriteReplace()Returns an alternate object to be serialized.
-
Constructor Details
-
Certificate
Creates a newCertificatewith the specified type.- Parameters:
type- the certificate type.
-
-
Method Details
-
getType
Returns the certificate type.- Returns:
- the certificate type.
-
equals
Compares the argument to the certificate, and returnstrueif they represent the same object using a class specific comparison. The implementation in Object returnstrueonly if the argument is the exact same object as the callee (==).- Overrides:
equalsin classObject- Parameters:
other- the object to compare with this object.- Returns:
trueif the object is the same as this object,falseif it is different from this object.- See Also:
hashCode()
-
hashCode
public int hashCode()Returns an integer hash code for the certificate. Any two objects which returntruewhen passed toequalsmust return the same value for this method.- Overrides:
hashCodein classObject- Returns:
- the certificate's hash
- See Also:
equals(java.lang.Object)
-
getEncoded
Returns the encoded representation for this certificate.- Returns:
- the encoded representation for this certificate.
- Throws:
CertificateEncodingException- if the encoding fails.
-
verify
public abstract void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureExceptionVerifies that this certificate was signed with the given public key.- Parameters:
key- PublicKey public key for which verification should be performed.- Throws:
CertificateException- if encoding errors are detected.NoSuchAlgorithmException- if an unsupported algorithm is detected.InvalidKeyException- if an invalid key is detected.NoSuchProviderException- if there is no default provider.SignatureException- if signature errors are detected.
-
verify
public abstract void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureExceptionVerifies that this certificate was signed with the given public key. It Uses the signature algorithm given by the provider.- Parameters:
key- PublicKey public key for which verification should be performed.sigProvider- String the name of the signature provider.- Throws:
CertificateException- if encoding errors are detected.NoSuchAlgorithmException- if an unsupported algorithm is detected.InvalidKeyException- if an invalid key is detected.NoSuchProviderException- if the specified provider does not exists.SignatureException- if signature errors are detected.
-
toString
Returns a string containing a concise, human-readable description of the certificate. -
getPublicKey
Returns the public key corresponding to this certificate.- Returns:
- the public key corresponding to this certificate.
-
writeReplace
Returns an alternate object to be serialized.- Returns:
- the object to serialize.
- Throws:
ObjectStreamException- if the creation of the alternate object fails.
-