提交 88504796 编写于 作者: X xuelei

7063647: To use synchronized map in key manager

Reviewed-by: wetmore, weijun
上级 8c5badde
...@@ -84,7 +84,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { ...@@ -84,7 +84,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* *
* Map: String(keyType) -> String[](alias) * 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. * Basic container for credentials implemented as an inner class.
...@@ -113,11 +113,13 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { ...@@ -113,11 +113,13 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
} }
} }
SunX509KeyManagerImpl(KeyStore ks, char[] password) throws KeyStoreException, SunX509KeyManagerImpl(KeyStore ks, char[] password)
throws KeyStoreException,
NoSuchAlgorithmException, UnrecoverableKeyException { NoSuchAlgorithmException, UnrecoverableKeyException {
credentialsMap = new HashMap<String,X509Credentials>(); credentialsMap = new HashMap<String,X509Credentials>();
serverAliasCache = new HashMap<String,String[]>(); serverAliasCache = Collections.synchronizedMap(
new HashMap<String,String[]>());
if (ks == null) { if (ks == null) {
return; return;
} }
...@@ -352,15 +354,17 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { ...@@ -352,15 +354,17 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
if (sigType != null) { if (sigType != null) {
if (certs.length > 1) { if (certs.length > 1) {
// if possible, check the public key in the issuer cert // 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; continue;
} }
} else { } else {
// Check the signature algorithm of the certificate itself. // Check the signature algorithm of the certificate itself.
// Look for the "withRSA" in "SHA1withRSA", etc. // Look for the "withRSA" in "SHA1withRSA", etc.
String sigAlgName = String sigAlgName =
certs[0].getSigAlgName().toUpperCase(Locale.ENGLISH); certs[0].getSigAlgName().toUpperCase(Locale.ENGLISH);
String pattern = "WITH" + sigType.toUpperCase(Locale.ENGLISH); String pattern = "WITH" +
sigType.toUpperCase(Locale.ENGLISH);
if (sigAlgName.contains(pattern) == false) { if (sigAlgName.contains(pattern) == false) {
continue; continue;
} }
...@@ -412,5 +416,4 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { ...@@ -412,5 +416,4 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
} }
return list.toArray(new X500Principal[list.size()]); return list.toArray(new X500Principal[list.size()]);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册