src/java.base/share/classes/java/security/cert/X509Certificate.java
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
parent 47216 71c04702a3d5
child 54483 ac20c3bdc55d
equal deleted inserted replaced
56541:92cbbfc996f3 56542:56aaa6cb3693
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2018, 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
    25 
    25 
    26 package java.security.cert;
    26 package java.security.cert;
    27 
    27 
    28 import java.math.BigInteger;
    28 import java.math.BigInteger;
    29 import java.security.*;
    29 import java.security.*;
       
    30 import java.security.spec.*;
    30 import java.util.Collection;
    31 import java.util.Collection;
    31 import java.util.Date;
    32 import java.util.Date;
    32 import java.util.List;
    33 import java.util.List;
    33 import javax.security.auth.x500.X500Principal;
    34 import javax.security.auth.x500.X500Principal;
    34 
    35 
    35 import sun.security.x509.X509CertImpl;
    36 import sun.security.x509.X509CertImpl;
       
    37 import sun.security.util.SignatureUtil;
    36 
    38 
    37 /**
    39 /**
    38  * <p>
    40  * <p>
    39  * Abstract class for X.509 certificates. This provides a standard
    41  * Abstract class for X.509 certificates. This provides a standard
    40  * way to access all the attributes of an X.509 certificate.
    42  * way to access all the attributes of an X.509 certificate.
   675         throws CertificateException, NoSuchAlgorithmException,
   677         throws CertificateException, NoSuchAlgorithmException,
   676         InvalidKeyException, SignatureException {
   678         InvalidKeyException, SignatureException {
   677         Signature sig = (sigProvider == null)
   679         Signature sig = (sigProvider == null)
   678             ? Signature.getInstance(getSigAlgName())
   680             ? Signature.getInstance(getSigAlgName())
   679             : Signature.getInstance(getSigAlgName(), sigProvider);
   681             : Signature.getInstance(getSigAlgName(), sigProvider);
       
   682 
   680         sig.initVerify(key);
   683         sig.initVerify(key);
       
   684 
       
   685         // set parameters after Signature.initSign/initVerify call,
       
   686         // so the deferred provider selections occur when key is set
       
   687         try {
       
   688             SignatureUtil.specialSetParameter(sig, getSigAlgParams());
       
   689         } catch (ProviderException e) {
       
   690             throw new CertificateException(e.getMessage(), e.getCause());
       
   691         } catch (InvalidAlgorithmParameterException e) {
       
   692             throw new CertificateException(e);
       
   693         }
   681 
   694 
   682         byte[] tbsCert = getTBSCertificate();
   695         byte[] tbsCert = getTBSCertificate();
   683         sig.update(tbsCert, 0, tbsCert.length);
   696         sig.update(tbsCert, 0, tbsCert.length);
   684 
   697 
   685         if (sig.verify(getSignature()) == false) {
   698         if (sig.verify(getSignature()) == false) {