java.security.cert
Class Certificate

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.cert.Certificate
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable
Direct Known Subclasses:
X509Certificate sample code for java.security.cert.X509Certificate definition code for java.security.cert.X509Certificate

public abstract class Certificate
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

Abstract class for managing a variety of identity certificates. An identity certificate is a binding of a principal to a public key which is vouched for by 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.

See Also:
X509Certificate sample code for java.security.cert.X509Certificate definition code for java.security.cert.X509Certificate , CertificateFactory sample code for java.security.cert.CertificateFactory definition code for java.security.cert.CertificateFactory , Serialized Form

Nested Class Summary
protected static class Certificate.CertificateRep sample code for java.security.cert.Certificate.CertificateRep definition code for java.security.cert.Certificate.CertificateRep
          Alternate Certificate class for serialization.
 
Constructor Summary
protected Certificate sample code for java.security.cert.Certificate.Certificate(java.lang.String) definition code for java.security.cert.Certificate.Certificate(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  type)
          Creates a certificate of the specified type.
 
Method Summary
 boolean equals sample code for java.security.cert.Certificate.equals(java.lang.Object) definition code for java.security.cert.Certificate.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  other)
          Compares this certificate for equality with the specified object.
abstract  byte[] getEncoded sample code for java.security.cert.Certificate.getEncoded() definition code for java.security.cert.Certificate.getEncoded() ()
          Returns the encoded form of this certificate.
abstract  PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey getPublicKey sample code for java.security.cert.Certificate.getPublicKey() definition code for java.security.cert.Certificate.getPublicKey() ()
          Gets the public key from this certificate.
 String sample code for java.lang.String definition code for java.lang.String getType sample code for java.security.cert.Certificate.getType() definition code for java.security.cert.Certificate.getType() ()
          Returns the type of this certificate.
 int hashCode sample code for java.security.cert.Certificate.hashCode() definition code for java.security.cert.Certificate.hashCode() ()
          Returns a hashcode value for this certificate from its encoded form.
abstract  String sample code for java.lang.String definition code for java.lang.String toString sample code for java.security.cert.Certificate.toString() definition code for java.security.cert.Certificate.toString() ()
          Returns a string representation of this certificate.
abstract  void verify sample code for java.security.cert.Certificate.verify(java.security.PublicKey) definition code for java.security.cert.Certificate.verify(java.security.PublicKey) (PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  key)
          Verifies that this certificate was signed using the private key that corresponds to the specified public key.
abstract  void verify sample code for java.security.cert.Certificate.verify(java.security.PublicKey, java.lang.String) definition code for java.security.cert.Certificate.verify(java.security.PublicKey, java.lang.String) (PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  key, String sample code for java.lang.String definition code for java.lang.String  sigProvider)
          Verifies that this certificate was signed using the private key that corresponds to the specified public key.
protected  Object sample code for java.lang.Object definition code for java.lang.Object writeReplace sample code for java.security.cert.Certificate.writeReplace() definition code for java.security.cert.Certificate.writeReplace() ()
          Replace the Certificate to be serialized.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

Certificate sample code for java.security.cert.Certificate(java.lang.String) definition code for java.security.cert.Certificate(java.lang.String)

protected Certificate(String sample code for java.lang.String definition code for java.lang.String  type)
Creates a certificate of the specified type.

Parameters:
type - the standard name of the certificate type. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard certificate types.
Method Detail

getType sample code for java.security.cert.Certificate.getType() definition code for java.security.cert.Certificate.getType()

public final String sample code for java.lang.String definition code for java.lang.String  getType()
Returns the type of this certificate.

Returns:
the type of this certificate.

equals sample code for java.security.cert.Certificate.equals(java.lang.Object) definition code for java.security.cert.Certificate.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  other)
Compares this certificate for equality with the specified object. If the other object is an instanceof Certificate, then its encoded form is retrieved and compared with the encoded form of this certificate.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
other - the object to test for equality with this certificate.
Returns:
true iff the encoded forms of the two certificates match, false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for java.security.cert.Certificate.hashCode() definition code for java.security.cert.Certificate.hashCode()

public int hashCode()
Returns a hashcode value for this certificate from its encoded form.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the hashcode value.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

getEncoded sample code for java.security.cert.Certificate.getEncoded() definition code for java.security.cert.Certificate.getEncoded()

public abstract byte[] getEncoded()
                           throws CertificateEncodingException sample code for java.security.cert.CertificateEncodingException definition code for java.security.cert.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:
the encoded form of this certificate
Throws:
CertificateEncodingException sample code for java.security.cert.CertificateEncodingException definition code for java.security.cert.CertificateEncodingException - if an encoding error occurs.

verify sample code for java.security.cert.Certificate.verify(java.security.PublicKey) definition code for java.security.cert.Certificate.verify(java.security.PublicKey)

public abstract void verify(PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  key)
                     throws CertificateException sample code for java.security.cert.CertificateException definition code for java.security.cert.CertificateException ,
                            NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException ,
                            InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException ,
                            NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException ,
                            SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException 
Verifies that this certificate was signed using the private key that corresponds to the specified public key.

Parameters:
key - the PublicKey used to carry out the verification.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - on unsupported signature algorithms.
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - on incorrect key.
NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException - if there's no default provider.
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - on signature errors.
CertificateException sample code for java.security.cert.CertificateException definition code for java.security.cert.CertificateException - on encoding errors.

verify sample code for java.security.cert.Certificate.verify(java.security.PublicKey, java.lang.String) definition code for java.security.cert.Certificate.verify(java.security.PublicKey, java.lang.String)

public abstract void verify(PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  key,
                            String sample code for java.lang.String definition code for java.lang.String  sigProvider)
                     throws CertificateException sample code for java.security.cert.CertificateException definition code for java.security.cert.CertificateException ,
                            NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException ,
                            InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException ,
                            NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException ,
                            SignatureException sample code for java.security.SignatureException definition code for java.security.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 - the PublicKey used to carry out the verification.
sigProvider - the name of the signature provider.
Throws:
NoSuchAlgorithmException sample code for java.security.NoSuchAlgorithmException definition code for java.security.NoSuchAlgorithmException - on unsupported signature algorithms.
InvalidKeyException sample code for java.security.InvalidKeyException definition code for java.security.InvalidKeyException - on incorrect key.
NoSuchProviderException sample code for java.security.NoSuchProviderException definition code for java.security.NoSuchProviderException - on incorrect provider.
SignatureException sample code for java.security.SignatureException definition code for java.security.SignatureException - on signature errors.
CertificateException sample code for java.security.cert.CertificateException definition code for java.security.cert.CertificateException - on encoding errors.

toString sample code for java.security.cert.Certificate.toString() definition code for java.security.cert.Certificate.toString()

public abstract String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string representation of this certificate.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this certificate.

getPublicKey sample code for java.security.cert.Certificate.getPublicKey() definition code for java.security.cert.Certificate.getPublicKey()

public abstract PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  getPublicKey()
Gets the public key from this certificate.

Returns:
the public key.

writeReplace sample code for java.security.cert.Certificate.writeReplace() definition code for java.security.cert.Certificate.writeReplace()

protected Object sample code for java.lang.Object definition code for java.lang.Object  writeReplace()
                       throws ObjectStreamException sample code for java.io.ObjectStreamException definition code for java.io.ObjectStreamException 
Replace the Certificate to be serialized.

Returns:
the alternate Certificate object to be serialized
Throws:
ObjectStreamException sample code for java.io.ObjectStreamException definition code for java.io.ObjectStreamException - if a new object representing this Certificate could not be created