FileDocCategorySizeDatePackage
Certificate.javaAPI DocAndroid 1.5 API6089Wed May 06 22:41:06 BST 2009javax.security.cert

Certificate

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.

since
Android 1.0

Fields Summary
Constructors Summary
public Certificate()
Creates a new {@code Certificate}.

since
Android 1.0

Methods Summary
public booleanequals(java.lang.Object obj)
Compares the argument to this Certificate. If both have the same bytes they are assumed to be equal.

param
obj the {@code Certificate} to compare with this object
return
true if {@code obj} is the same as this {@code Certificate}, false otherwise
see
#hashCode
since
Android 1.0

        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Certificate)) {
            return false;
        }
        Certificate object = (Certificate) obj;
        try {
            return Arrays.equals(getEncoded(), object.getEncoded());
        } catch (CertificateEncodingException e) {
            return false;
        }
    
public abstract byte[]getEncoded()
Returns the encoded representation for this certificate.

return
the encoded representation for this certificate.
throws
CertificateEncodingException if encoding fails.
since
Android 1.0

public abstract java.security.PublicKeygetPublicKey()
Returns the public key corresponding to this certificate.

return
the public key corresponding to this certificate.
since
Android 1.0

public inthashCode()
Returns an integer hash code for the receiver. Any two objects which return true when passed to equals must answer the same value for this method.

return
the receiver's hash
see
#equals
since
Android 1.0

        int res = 0;
        try {
            byte[] array = getEncoded();
            for (int i=0; i<array.length; i++) {
                res += array[i];
            }
        } catch (CertificateEncodingException e) {
        }
        return res;
    
public abstract java.lang.StringtoString()
Returns a string containing a concise, human-readable description of the receiver.

return
a printable representation for the receiver.
since
Android 1.0

public abstract voidverify(java.security.PublicKey key)
Verifies that this certificate was signed with the given public key.

param
key public key for which verification should be performed.
throws
CertificateException if encoding errors are detected
throws
NoSuchAlgorithmException if an unsupported algorithm is detected
throws
InvalidKeyException if an invalid key is detected
throws
NoSuchProviderException if there is no default provider
throws
SignatureException if signature errors are detected
since
Android 1.0

public abstract voidverify(java.security.PublicKey key, java.lang.String sigProvider)
Verifies that this certificate was signed with the given public key. Uses the signature algorithm given by the provider.

param
key public key for which verification should be performed.
param
sigProvider the name of the signature provider.
exception
CertificateException if encoding errors are detected
exception
NoSuchAlgorithmException if an unsupported algorithm is detected
exception
InvalidKeyException if an invalid key is detected
exception
NoSuchProviderException if the specified provider does not exists.
exception
SignatureException if signature errors are detected
since
Android 1.0