Package javax.security.cert
Class Certificate
java.lang.Object
javax.security.cert.Certificate
- Direct Known Subclasses:
X509Certificate
public abstract class Certificate extends Object
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.
Note: This package is provided only for compatibility reasons. It contains a simplified version of the java.security.cert package that was previously used by JSSE (Java SSL package). All applications that do not have to be compatible with older versions of JSSE (that is before Java SDK 1.5) should only use java.security.cert.
-
Constructor Summary
Constructors Constructor Description Certificate()Creates a newCertificate. -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)Compares the argument to this Certificate.abstract byte[]getEncoded()Returns the encoded representation for this certificate.abstract PublicKeygetPublicKey()Returns the public key corresponding to this certificate.inthashCode()Returns an integer hash code for the receiver.abstract StringtoString()Returns a string containing a concise, human-readable description of the receiver.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.
-
Constructor Details
-
Certificate
public Certificate()Creates a newCertificate.
-
-
Method Details
-
equals
Compares the argument to this Certificate. If both have the same bytes they are assumed to be equal.- Overrides:
equalsin classObject- Parameters:
obj- theCertificateto compare with this object- Returns:
trueifobjis the same as thisCertificate,falseotherwise- See Also:
hashCode()
-
hashCode
public int hashCode()Returns an integer hash code for the receiver. Any two objects which returntruewhen passed toequalsmust answer the same value for this method.- Overrides:
hashCodein classObject- Returns:
- the receiver'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 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- public key for which verification should be performed.- Throws:
CertificateException- if encoding errors are detectedNoSuchAlgorithmException- if an unsupported algorithm is detectedInvalidKeyException- if an invalid key is detectedNoSuchProviderException- if there is no default providerSignatureException- 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. Uses the signature algorithm given by the provider.- Parameters:
key- public key for which verification should be performed.sigProvider- the name of the signature provider.- Throws:
CertificateException- if encoding errors are detectedNoSuchAlgorithmException- if an unsupported algorithm is detectedInvalidKeyException- if an invalid key is detectedNoSuchProviderException- 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 receiver. -
getPublicKey
Returns the public key corresponding to this certificate.- Returns:
- the public key corresponding to this certificate.
-