APIdia Launch Partner
Top Description Constructors Methods
javax.security.cert

public abstract Class Certificate

extends Object
Class Inheritance
Known Direct Subclasses
javax.security.cert.X509Certificate
Annotations
@SuppressWarnings:removal
@Deprecated
since:9
forRemoval:true
Imports
java.security.PublicKey, .NoSuchAlgorithmException, .NoSuchProviderException, .InvalidKeyException, .SignatureException, java.util.Arrays

Deprecated

for removal since 9.

Use the classes in java.security.cert instead.

Abstract class for managing a variety of identity certificates. An identity certificate is a guarantee by a principal that a public key is that of another principal. (A principal represents an entity such as an individual user, a group, or a corporation.)

This class is an abstraction for certificates that have different formats but important common uses. For example, different types of certificates, such as X.509 and PGP, share general certificate functionality (like encoding and verifying) and some types of information (like a public key).

X.509, PGP, and SDSI certificates can all be implemented by subclassing the Certificate class, even though they contain different sets of information, and they store and retrieve the information in different ways.

Note

The classes in the package javax.security.cert exist for compatibility with earlier versions of the Java Secure Sockets Extension (JSSE). New applications should instead use the standard Java SE certificate classes located in java.security.cert.

Author
Hemma Prafullchandra
Since
1.4
See Also
X509Certificate

Constructor Summary

AccessConstructor and Description
public
Certificate()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the encoded forms of the two certificates match, false otherwise.
equals
(Object
the object to test for equality with this certificate.
obj
)

Overrides java.lang.Object.equals.

Compares this certificate for equality with the specified object.

public abstract byte[]

Returns:

encoded form of this certificate
getEncoded
()

Returns the encoded form of this certificate.

public abstract PublicKey

Returns:

the public key.
getPublicKey
()

Gets the public key from this certificate.

public int

Returns:

a hashcode value for this certificate from its encoded form
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode value for this certificate from its encoded form.

public abstract String

Returns:

a string representation of this certificate.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this certificate.

public abstract void
verify(PublicKey
the PublicKey used to carry out the verification.
key
)

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

public abstract void
verify(PublicKey
the PublicKey used to carry out the verification.
key
,
String
the name of the signature provider.
sigProvider
)

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Constructor Detail

Certificateback to summary
public Certificate()

Constructor for subclasses to call.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this certificate for equality with the specified object. If the obj object is an instanceof Certificate, then its encoded form is retrieved and compared with the encoded form of this certificate.

Parameters
obj:Object

the object to test for equality with this certificate.

Returns:boolean

true if the encoded forms of the two certificates match, false otherwise.

Annotations
@Override
getEncodedback to summary
public abstract byte[] getEncoded() throws CertificateEncodingException

Returns the encoded form of this certificate. It is assumed that each certificate type would have only a single form of encoding; for example, X.509 certificates would be encoded as ASN.1 DER.

Returns:byte[]

encoded form of this certificate

Exceptions
CertificateEncodingException:
on internal certificate encoding failure
getPublicKeyback to summary
public abstract PublicKey getPublicKey()

Gets the public key from this certificate.

Returns:PublicKey

the public key.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode value for this certificate from its encoded form.

Returns:int

a hashcode value for this certificate from its encoded form

Annotations
@Override
toStringback to summary
public abstract String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this certificate.

Returns:String

a string representation of this certificate.

verifyback to summary
public abstract void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

Parameters
key:PublicKey

the PublicKey used to carry out the verification.

Exceptions
CertificateException:
on encoding errors.
NoSuchAlgorithmException:
on unsupported signature algorithms.
InvalidKeyException:
on incorrect key.
NoSuchProviderException:
if there's no default provider.
SignatureException:
on signature errors.
verifyback to summary
public abstract void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException

Verifies that this certificate was signed using the private key that corresponds to the specified public key. This method uses the signature verification engine supplied by the specified provider.

Parameters
key:PublicKey

the PublicKey used to carry out the verification.

sigProvider:String

the name of the signature provider.

Exceptions
CertificateException:
on encoding errors.
NoSuchAlgorithmException:
on unsupported signature algorithms.
InvalidKeyException:
on incorrect key.
NoSuchProviderException:
on incorrect provider.
SignatureException:
on signature errors.