changeset 4531:b07cf6cbb62a

7063647: To use synchronized map in key manager Reviewed-by: wetmore, weijun
author xuelei
date Mon, 15 Aug 2011 00:30:35 -0700
parents 4af32446555d
children 6e9ed747d0ca
files src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Mon Aug 15 11:43:09 2011 +0800
+++ b/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Mon Aug 15 00:30:35 2011 -0700
@@ -84,7 +84,7 @@
      *
      * Map: String(keyType) -> String[](alias)
      */
-    private Map<String,String[]> serverAliasCache;
+    private final Map<String,String[]> serverAliasCache;
 
     /*
      * Basic container for credentials implemented as an inner class.
@@ -113,11 +113,13 @@
         }
     }
 
-    SunX509KeyManagerImpl(KeyStore ks, char[] password) throws KeyStoreException,
+    SunX509KeyManagerImpl(KeyStore ks, char[] password)
+            throws KeyStoreException,
             NoSuchAlgorithmException, UnrecoverableKeyException {
 
         credentialsMap = new HashMap<String,X509Credentials>();
-        serverAliasCache = new HashMap<String,String[]>();
+        serverAliasCache = Collections.synchronizedMap(
+                            new HashMap<String,String[]>());
         if (ks == null) {
             return;
         }
@@ -352,15 +354,17 @@
             if (sigType != null) {
                 if (certs.length > 1) {
                     // if possible, check the public key in the issuer cert
-                    if (!sigType.equals(certs[1].getPublicKey().getAlgorithm())) {
+                    if (!sigType.equals(
+                            certs[1].getPublicKey().getAlgorithm())) {
                         continue;
                     }
                 } else {
                     // Check the signature algorithm of the certificate itself.
                     // Look for the "withRSA" in "SHA1withRSA", etc.
                     String sigAlgName =
-                            certs[0].getSigAlgName().toUpperCase(Locale.ENGLISH);
-                    String pattern = "WITH" + sigType.toUpperCase(Locale.ENGLISH);
+                        certs[0].getSigAlgName().toUpperCase(Locale.ENGLISH);
+                    String pattern = "WITH" +
+                        sigType.toUpperCase(Locale.ENGLISH);
                     if (sigAlgName.contains(pattern) == false) {
                         continue;
                     }
@@ -412,5 +416,4 @@
         }
         return list.toArray(new X500Principal[list.size()]);
     }
-
 }