提交 179dde1b 编写于 作者: S smarks

7005608: diamond conversion of JCA and crypto providers

Reviewed-by: wetmore
上级 064f64a0
...@@ -659,7 +659,7 @@ public final class Security { ...@@ -659,7 +659,7 @@ public final class Security {
} }
// Map containing cached Spi Class objects of the specified type // Map containing cached Spi Class objects of the specified type
private static final Map<String,Class> spiMap = new ConcurrentHashMap<>(); private static final Map<String, Class> spiMap = new ConcurrentHashMap<>();
/** /**
* Return the Class object for the given engine type * Return the Class object for the given engine type
......
...@@ -96,7 +96,7 @@ public final class ProviderList { ...@@ -96,7 +96,7 @@ public final class ProviderList {
if (providerList.getProvider(p.getName()) != null) { if (providerList.getProvider(p.getName()) != null) {
return providerList; return providerList;
} }
List<ProviderConfig> list = new ArrayList<ProviderConfig> List<ProviderConfig> list = new ArrayList<>
(Arrays.asList(providerList.configs)); (Arrays.asList(providerList.configs));
int n = list.size(); int n = list.size();
if ((position < 0) || (position > n)) { if ((position < 0) || (position > n)) {
...@@ -160,7 +160,7 @@ public final class ProviderList { ...@@ -160,7 +160,7 @@ public final class ProviderList {
* Return a new ProviderList parsed from the java.security Properties. * Return a new ProviderList parsed from the java.security Properties.
*/ */
private ProviderList() { private ProviderList() {
List<ProviderConfig> configList = new ArrayList<ProviderConfig>(); List<ProviderConfig> configList = new ArrayList<>();
for (int i = 1; true; i++) { for (int i = 1; true; i++) {
String entry = Security.getProperty("security.provider." + i); String entry = Security.getProperty("security.provider." + i);
if (entry == null) { if (entry == null) {
...@@ -200,7 +200,7 @@ public final class ProviderList { ...@@ -200,7 +200,7 @@ public final class ProviderList {
* possible recursion and deadlock during verification. * possible recursion and deadlock during verification.
*/ */
ProviderList getJarList(String[] jarClassNames) { ProviderList getJarList(String[] jarClassNames) {
List<ProviderConfig> newConfigs = new ArrayList<ProviderConfig>(); List<ProviderConfig> newConfigs = new ArrayList<>();
for (String className : jarClassNames) { for (String className : jarClassNames) {
ProviderConfig newConfig = new ProviderConfig(className); ProviderConfig newConfig = new ProviderConfig(className);
for (ProviderConfig config : configs) { for (ProviderConfig config : configs) {
...@@ -356,7 +356,7 @@ public final class ProviderList { ...@@ -356,7 +356,7 @@ public final class ProviderList {
*/ */
@Deprecated @Deprecated
public List<Service> getServices(String type, List<String> algorithms) { public List<Service> getServices(String type, List<String> algorithms) {
List<ServiceId> ids = new ArrayList<ServiceId>(); List<ServiceId> ids = new ArrayList<>();
for (String alg : algorithms) { for (String alg : algorithms) {
ids.add(new ServiceId(type, alg)); ids.add(new ServiceId(type, alg));
} }
......
...@@ -40,7 +40,7 @@ import java.security.Security; ...@@ -40,7 +40,7 @@ import java.security.Security;
public class Providers { public class Providers {
private static final ThreadLocal<ProviderList> threadLists = private static final ThreadLocal<ProviderList> threadLists =
new InheritableThreadLocal<ProviderList>(); new InheritableThreadLocal<>();
// number of threads currently using thread-local provider lists // number of threads currently using thread-local provider lists
// tracked to allow an optimization if == 0 // tracked to allow an optimization if == 0
......
...@@ -299,8 +299,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -299,8 +299,7 @@ public class PolicyFile extends java.security.Policy {
private static final int DEFAULT_CACHE_SIZE = 1; private static final int DEFAULT_CACHE_SIZE = 1;
// contains the policy grant entries, PD cache, and alias mapping // contains the policy grant entries, PD cache, and alias mapping
private AtomicReference<PolicyInfo> policyInfo = private AtomicReference<PolicyInfo> policyInfo = new AtomicReference<>();
new AtomicReference<PolicyInfo>();
private boolean constructed = false; private boolean constructed = false;
private boolean expandProperties = true; private boolean expandProperties = true;
...@@ -1334,8 +1333,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -1334,8 +1333,7 @@ public class PolicyFile extends java.security.Policy {
List<PolicyParser.PrincipalEntry> entryPs = entry.getPrincipals(); List<PolicyParser.PrincipalEntry> entryPs = entry.getPrincipals();
if (debug != null) { if (debug != null) {
ArrayList<PolicyParser.PrincipalEntry> accPs = ArrayList<PolicyParser.PrincipalEntry> accPs = new ArrayList<>();
new ArrayList<PolicyParser.PrincipalEntry>();
if (principals != null) { if (principals != null) {
for (int i = 0; i < principals.length; i++) { for (int i = 0; i < principals.length; i++) {
accPs.add(new PolicyParser.PrincipalEntry accPs.add(new PolicyParser.PrincipalEntry
...@@ -1416,8 +1414,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -1416,8 +1414,7 @@ public class PolicyFile extends java.security.Policy {
// check if the PrincipalComparator // check if the PrincipalComparator
// implies the current thread's principals // implies the current thread's principals
Set<Principal> pSet = Set<Principal> pSet = new HashSet<>(principals.length);
new HashSet<Principal>(principals.length);
for (int j = 0; j < principals.length; j++) { for (int j = 0; j < principals.length; j++) {
pSet.add(principals[j]); pSet.add(principals[j]);
} }
...@@ -1700,7 +1697,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -1700,7 +1697,7 @@ public class PolicyFile extends java.security.Policy {
// build an info array for every principal // build an info array for every principal
// in the current domain which has a principal class // in the current domain which has a principal class
// that is equal to policy entry principal class name // that is equal to policy entry principal class name
List<Principal> plist = new ArrayList<Principal>(); List<Principal> plist = new ArrayList<>();
for (int i = 0; i < pdp.length; i++) { for (int i = 0; i < pdp.length; i++) {
if(pe.principalClass.equals(pdp[i].getClass().getName())) if(pe.principalClass.equals(pdp[i].getClass().getName()))
plist.add(pdp[i]); plist.add(pdp[i]);
...@@ -1770,7 +1767,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -1770,7 +1767,7 @@ public class PolicyFile extends java.security.Policy {
// Done // Done
return certs; return certs;
ArrayList<Certificate> userCertList = new ArrayList<Certificate>(); ArrayList<Certificate> userCertList = new ArrayList<>();
i = 0; i = 0;
while (i < certs.length) { while (i < certs.length) {
userCertList.add(certs[i]); userCertList.add(certs[i]);
...@@ -2234,7 +2231,7 @@ public class PolicyFile extends java.security.Policy { ...@@ -2234,7 +2231,7 @@ public class PolicyFile extends java.security.Policy {
if (this.certs == null) { if (this.certs == null) {
// extract the signer certs // extract the signer certs
ArrayList<Certificate> signerCerts = ArrayList<Certificate> signerCerts =
new ArrayList<Certificate>(); new ArrayList<>();
i = 0; i = 0;
while (i < certs.length) { while (i < certs.length) {
signerCerts.add(certs[i]); signerCerts.add(certs[i]);
......
...@@ -55,7 +55,7 @@ public final class Sun extends Provider { ...@@ -55,7 +55,7 @@ public final class Sun extends Provider {
SunEntries.putEntries(this); SunEntries.putEntries(this);
} else { } else {
// use LinkedHashMap to preserve the order of the PRNGs // use LinkedHashMap to preserve the order of the PRNGs
Map<Object, Object> map = new LinkedHashMap<Object, Object>(); Map<Object, Object> map = new LinkedHashMap<>();
SunEntries.putEntries(map); SunEntries.putEntries(map);
AccessController.doPrivileged(new PutAllAction(this, map)); AccessController.doPrivileged(new PutAllAction(this, map));
} }
......
...@@ -76,7 +76,7 @@ public final class VerificationProvider extends Provider { ...@@ -76,7 +76,7 @@ public final class VerificationProvider extends Provider {
SunRsaSignEntries.putEntries(this); SunRsaSignEntries.putEntries(this);
} else { } else {
// use LinkedHashMap to preserve the order of the PRNGs // use LinkedHashMap to preserve the order of the PRNGs
Map<Object, Object> map = new LinkedHashMap<Object, Object>(); Map<Object, Object> map = new LinkedHashMap<>();
SunEntries.putEntries(map); SunEntries.putEntries(map);
SunRsaSignEntries.putEntries(map); SunRsaSignEntries.putEntries(map);
AccessController.doPrivileged(new PutAllAction(this, map)); AccessController.doPrivileged(new PutAllAction(this, map));
......
...@@ -409,10 +409,10 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -409,10 +409,10 @@ public class X509Factory extends CertificateFactorySpi {
parseX509orPKCS7Cert(InputStream is) parseX509orPKCS7Cert(InputStream is)
throws CertificateException, IOException throws CertificateException, IOException
{ {
Collection<X509CertImpl> coll = new ArrayList<X509CertImpl>(); Collection<X509CertImpl> coll = new ArrayList<>();
byte[] data = readOneBlock(is); byte[] data = readOneBlock(is);
if (data == null) { if (data == null) {
return new ArrayList<X509CertImpl>(0); return new ArrayList<>(0);
} }
try { try {
PKCS7 pkcs7 = new PKCS7(data); PKCS7 pkcs7 = new PKCS7(data);
...@@ -422,7 +422,7 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -422,7 +422,7 @@ public class X509Factory extends CertificateFactorySpi {
return Arrays.asList(certs); return Arrays.asList(certs);
} else { } else {
// no crls provided // no crls provided
return new ArrayList<X509Certificate>(0); return new ArrayList<>(0);
} }
} catch (ParsingException e) { } catch (ParsingException e) {
while (data != null) { while (data != null) {
...@@ -442,10 +442,10 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -442,10 +442,10 @@ public class X509Factory extends CertificateFactorySpi {
parseX509orPKCS7CRL(InputStream is) parseX509orPKCS7CRL(InputStream is)
throws CRLException, IOException throws CRLException, IOException
{ {
Collection<X509CRLImpl> coll = new ArrayList<X509CRLImpl>(); Collection<X509CRLImpl> coll = new ArrayList<>();
byte[] data = readOneBlock(is); byte[] data = readOneBlock(is);
if (data == null) { if (data == null) {
return new ArrayList<X509CRL>(0); return new ArrayList<>(0);
} }
try { try {
PKCS7 pkcs7 = new PKCS7(data); PKCS7 pkcs7 = new PKCS7(data);
...@@ -455,7 +455,7 @@ public class X509Factory extends CertificateFactorySpi { ...@@ -455,7 +455,7 @@ public class X509Factory extends CertificateFactorySpi {
return Arrays.asList(crls); return Arrays.asList(crls);
} else { } else {
// no crls provided // no crls provided
return new ArrayList<X509CRL>(0); return new ArrayList<>(0);
} }
} catch (ParsingException e) { } catch (ParsingException e) {
while (data != null) { while (data != null) {
......
...@@ -215,11 +215,11 @@ public final class RSACore { ...@@ -215,11 +215,11 @@ public final class RSACore {
// value suggested by Paul Kocher (quoted by NSS) // value suggested by Paul Kocher (quoted by NSS)
private final static int BLINDING_MAX_REUSE = 50; private final static int BLINDING_MAX_REUSE = 50;
// cache for blinding parameters. Map<BigInteger,BlindingParameters> // cache for blinding parameters. Map<BigInteger, BlindingParameters>
// use a weak hashmap so that cached values are automatically cleared // use a weak hashmap so that cached values are automatically cleared
// when the modulus is GC'ed // when the modulus is GC'ed
private final static Map<BigInteger,BlindingParameters> blindingCache = private final static Map<BigInteger, BlindingParameters> blindingCache =
new WeakHashMap<BigInteger,BlindingParameters>(); new WeakHashMap<>();
/** /**
* Set of blinding parameters for a given RSA key. * Set of blinding parameters for a given RSA key.
......
...@@ -52,7 +52,7 @@ public final class SunRsaSign extends Provider { ...@@ -52,7 +52,7 @@ public final class SunRsaSign extends Provider {
SunRsaSignEntries.putEntries(this); SunRsaSignEntries.putEntries(this);
} else { } else {
// use LinkedHashMap to preserve the order of the PRNGs // use LinkedHashMap to preserve the order of the PRNGs
Map<Object, Object> map = new HashMap<Object, Object>(); Map<Object, Object> map = new HashMap<>();
SunRsaSignEntries.putEntries(map); SunRsaSignEntries.putEntries(map);
AccessController.doPrivileged(new PutAllAction(this, map)); AccessController.doPrivileged(new PutAllAction(this, map));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册