src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
changeset 54443 dfba4e321ab3
parent 50768 68fa3d4026ea
equal deleted inserted replaced
54442:172f929786ea 54443:dfba4e321ab3
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2019, 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
   100 
   100 
   101     /*
   101     /*
   102      * Basic container for credentials implemented as an inner class.
   102      * Basic container for credentials implemented as an inner class.
   103      */
   103      */
   104     private static class X509Credentials {
   104     private static class X509Credentials {
   105         PrivateKey privateKey;
   105         final PrivateKey privateKey;
   106         X509Certificate[] certificates;
   106         final X509Certificate[] certificates;
   107         private Set<X500Principal> issuerX500Principals;
   107         private final Set<X500Principal> issuerX500Principals;
   108 
   108 
   109         X509Credentials(PrivateKey privateKey, X509Certificate[] certificates) {
   109         X509Credentials(PrivateKey privateKey, X509Certificate[] certificates) {
   110             // assert privateKey and certificates != null
   110             // assert privateKey and certificates != null
   111             this.privateKey = privateKey;
   111             this.privateKey = privateKey;
   112             this.certificates = certificates;
   112             this.certificates = certificates;
   113         }
   113             this.issuerX500Principals = new HashSet<>(certificates.length);
   114 
   114             for (X509Certificate certificate : certificates) {
   115         synchronized Set<X500Principal> getIssuerX500Principals() {
   115                 issuerX500Principals.add(certificate.getIssuerX500Principal());
   116             // lazy initialization
   116             }
   117             if (issuerX500Principals == null) {
   117         }
   118                 issuerX500Principals = new HashSet<X500Principal>();
   118 
   119                 for (int i = 0; i < certificates.length; i++) {
   119         Set<X500Principal> getIssuerX500Principals() {
   120                     issuerX500Principals.add(
       
   121                                 certificates[i].getIssuerX500Principal());
       
   122                 }
       
   123             }
       
   124             return issuerX500Principals;
   120             return issuerX500Principals;
   125         }
   121         }
   126     }
   122     }
   127 
   123 
   128     SunX509KeyManagerImpl(KeyStore ks, char[] password)
   124     SunX509KeyManagerImpl(KeyStore ks, char[] password)