java.security.cert
abstract public class: Certificate [javadoc |
source]
java.lang.Object
java.security.cert.Certificate
All Implemented Interfaces:
java$io$Serializable
Direct Known Subclasses:
X509Certificate
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.
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from java.security.cert.Certificate Detail: |
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Certificate)) {
return false;
}
try {
byte[] thisCert = X509CertImpl.getEncodedInternal(this);
byte[] otherCert = X509CertImpl.getEncodedInternal((Certificate)other);
return Arrays.equals(thisCert, otherCert);
} catch (CertificateException e) {
return false;
}
}
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. |
abstract public 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. |
abstract public PublicKey getPublicKey()
Gets the public key from this certificate. |
public final String getType() {
return this.type;
}
Returns the type of this certificate. |
public int hashCode() {
int retval = 0;
try {
byte[] certData = X509CertImpl.getEncodedInternal(this);
for (int i = 1; i < certData.length; i++) {
retval += certData[i] * i;
}
return retval;
} catch (CertificateException e) {
return retval;
}
}
Returns a hashcode value for this certificate from its
encoded form. |
abstract public String toString()
Returns a string representation of this certificate. |
abstract public 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. |
abstract public 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. |
protected Object writeReplace() throws ObjectStreamException {
try {
return new CertificateRep(type, getEncoded());
} catch (CertificateException e) {
throw new java.io.NotSerializableException
("java.security.cert.Certificate: " +
type +
": " +
e.getMessage());
}
}
Replace the Certificate to be serialized. |