src/share/classes/java/security/cert/Certificate.java

Print this page




  73      * See the CertificateFactory section in the <a href=
  74      * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
  75      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
  76      * for information about standard certificate types.
  77      */
  78     protected Certificate(String type) {
  79         this.type = type;
  80     }
  81 
  82     /**
  83      * Returns the type of this certificate.
  84      *
  85      * @return the type of this certificate.
  86      */
  87     public final String getType() {
  88         return this.type;
  89     }
  90 
  91     /**
  92      * Compares this certificate for equality with the specified
  93      * object. If the <code>other</code> object is an
  94      * <code>instanceof</code> <code>Certificate</code>, then
  95      * its encoded form is retrieved and compared with the
  96      * encoded form of this certificate.
  97      *
  98      * @param other the object to test for equality with this certificate.
  99      * @return true iff the encoded forms of the two certificates
 100      * match, false otherwise.
 101      */
 102     public boolean equals(Object other) {
 103         if (this == other) {
 104             return true;
 105         }
 106         if (!(other instanceof Certificate)) {
 107             return false;
 108         }
 109         try {
 110             byte[] thisCert = X509CertImpl.getEncodedInternal(this);
 111             byte[] otherCert = X509CertImpl.getEncodedInternal((Certificate)other);
 112 
 113             return Arrays.equals(thisCert, otherCert);
 114         } catch (CertificateException e) {


 179      * algorithms.
 180      * @exception InvalidKeyException on incorrect key.
 181      * @exception NoSuchProviderException on incorrect provider.
 182      * @exception SignatureException on signature errors.
 183      * @exception CertificateException on encoding errors.
 184      */
 185     public abstract void verify(PublicKey key, String sigProvider)
 186         throws CertificateException, NoSuchAlgorithmException,
 187         InvalidKeyException, NoSuchProviderException,
 188         SignatureException;
 189 
 190     /**
 191      * Verifies that this certificate was signed using the
 192      * private key that corresponds to the specified public key.
 193      * This method uses the signature verification engine
 194      * supplied by the specified provider. Note that the specified
 195      * Provider object does not have to be registered in the provider list.
 196      *
 197      * <p> This method was added to version 1.8 of the Java Platform
 198      * Standard Edition. In order to maintain backwards compatibility with
 199      * existing service providers, this method cannot be <code>abstract</code>
 200      * and by default throws an <code>UnsupportedOperationException</code>.
 201      *
 202      * @param key the PublicKey used to carry out the verification.
 203      * @param sigProvider the signature provider.
 204      *
 205      * @exception NoSuchAlgorithmException on unsupported signature
 206      * algorithms.
 207      * @exception InvalidKeyException on incorrect key.
 208      * @exception SignatureException on signature errors.
 209      * @exception CertificateException on encoding errors.
 210      * @exception UnsupportedOperationException if the method is not supported
 211      * @since 1.8
 212      */
 213     public void verify(PublicKey key, Provider sigProvider)
 214         throws CertificateException, NoSuchAlgorithmException,
 215         InvalidKeyException, SignatureException {
 216         throw new UnsupportedOperationException();
 217     }
 218 
 219     /**
 220      * Returns a string representation of this certificate.




  73      * See the CertificateFactory section in the <a href=
  74      * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
  75      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
  76      * for information about standard certificate types.
  77      */
  78     protected Certificate(String type) {
  79         this.type = type;
  80     }
  81 
  82     /**
  83      * Returns the type of this certificate.
  84      *
  85      * @return the type of this certificate.
  86      */
  87     public final String getType() {
  88         return this.type;
  89     }
  90 
  91     /**
  92      * Compares this certificate for equality with the specified
  93      * object. If the {@code other} object is an
  94      * {@code instanceof} {@code Certificate}, then
  95      * its encoded form is retrieved and compared with the
  96      * encoded form of this certificate.
  97      *
  98      * @param other the object to test for equality with this certificate.
  99      * @return true iff the encoded forms of the two certificates
 100      * match, false otherwise.
 101      */
 102     public boolean equals(Object other) {
 103         if (this == other) {
 104             return true;
 105         }
 106         if (!(other instanceof Certificate)) {
 107             return false;
 108         }
 109         try {
 110             byte[] thisCert = X509CertImpl.getEncodedInternal(this);
 111             byte[] otherCert = X509CertImpl.getEncodedInternal((Certificate)other);
 112 
 113             return Arrays.equals(thisCert, otherCert);
 114         } catch (CertificateException e) {


 179      * algorithms.
 180      * @exception InvalidKeyException on incorrect key.
 181      * @exception NoSuchProviderException on incorrect provider.
 182      * @exception SignatureException on signature errors.
 183      * @exception CertificateException on encoding errors.
 184      */
 185     public abstract void verify(PublicKey key, String sigProvider)
 186         throws CertificateException, NoSuchAlgorithmException,
 187         InvalidKeyException, NoSuchProviderException,
 188         SignatureException;
 189 
 190     /**
 191      * Verifies that this certificate was signed using the
 192      * private key that corresponds to the specified public key.
 193      * This method uses the signature verification engine
 194      * supplied by the specified provider. Note that the specified
 195      * Provider object does not have to be registered in the provider list.
 196      *
 197      * <p> This method was added to version 1.8 of the Java Platform
 198      * Standard Edition. In order to maintain backwards compatibility with
 199      * existing service providers, this method cannot be {@code abstract}
 200      * and by default throws an {@code UnsupportedOperationException}.
 201      *
 202      * @param key the PublicKey used to carry out the verification.
 203      * @param sigProvider the signature provider.
 204      *
 205      * @exception NoSuchAlgorithmException on unsupported signature
 206      * algorithms.
 207      * @exception InvalidKeyException on incorrect key.
 208      * @exception SignatureException on signature errors.
 209      * @exception CertificateException on encoding errors.
 210      * @exception UnsupportedOperationException if the method is not supported
 211      * @since 1.8
 212      */
 213     public void verify(PublicKey key, Provider sigProvider)
 214         throws CertificateException, NoSuchAlgorithmException,
 215         InvalidKeyException, SignatureException {
 216         throw new UnsupportedOperationException();
 217     }
 218 
 219     /**
 220      * Returns a string representation of this certificate.