jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java
changeset 44476 e275cd2f9319
parent 26967 c182469301ee
child 45474 78b7a8c8fc06
equal deleted inserted replaced
44475:43ac80b688cd 44476:e275cd2f9319
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   645     public Collection<List<?>> getIssuerAlternativeNames()
   645     public Collection<List<?>> getIssuerAlternativeNames()
   646         throws CertificateParsingException {
   646         throws CertificateParsingException {
   647         return X509CertImpl.getIssuerAlternativeNames(this);
   647         return X509CertImpl.getIssuerAlternativeNames(this);
   648     }
   648     }
   649 
   649 
   650      /**
   650     /**
   651      * Verifies that this certificate was signed using the
   651      * Verifies that this certificate was signed using the
   652      * private key that corresponds to the specified public key.
   652      * private key that corresponds to the specified public key.
   653      * This method uses the signature verification engine
   653      * This method uses the signature verification engine
   654      * supplied by the specified provider. Note that the specified
   654      * supplied by the specified provider. Note that the specified
   655      * Provider object does not have to be registered in the provider list.
   655      * Provider object does not have to be registered in the provider list.
   671      * @since 1.8
   671      * @since 1.8
   672      */
   672      */
   673     public void verify(PublicKey key, Provider sigProvider)
   673     public void verify(PublicKey key, Provider sigProvider)
   674         throws CertificateException, NoSuchAlgorithmException,
   674         throws CertificateException, NoSuchAlgorithmException,
   675         InvalidKeyException, SignatureException {
   675         InvalidKeyException, SignatureException {
   676         X509CertImpl.verify(this, key, sigProvider);
   676         Signature sig = (sigProvider == null)
       
   677             ? Signature.getInstance(getSigAlgName())
       
   678             : Signature.getInstance(getSigAlgName(), sigProvider);
       
   679         sig.initVerify(key);
       
   680 
       
   681         byte[] tbsCert = getTBSCertificate();
       
   682         sig.update(tbsCert, 0, tbsCert.length);
       
   683 
       
   684         if (sig.verify(getSignature()) == false) {
       
   685             throw new SignatureException("Signature does not match.");
       
   686         }
   677     }
   687     }
   678 }
   688 }