提交 af9d07b8 编写于 作者: S smarks

7012003: diamond conversion for ssl

Reviewed-by: wetmore
上级 1c541e4b
......@@ -393,7 +393,7 @@ final class CipherSuite implements Comparable {
// Map BulkCipher -> Boolean(available)
private final static Map<BulkCipher,Boolean> availableCache =
new HashMap<BulkCipher,Boolean>(8);
new HashMap<>(8);
// descriptive name including key size, e.g. AES/128
final String description;
......
......@@ -221,7 +221,7 @@ final class CipherSuiteList {
private static CipherSuiteList buildAvailableCache(int minPriority) {
// SortedSet automatically arranges ciphersuites in default
// preference order
Set<CipherSuite> cipherSuites = new TreeSet<CipherSuite>();
Set<CipherSuite> cipherSuites = new TreeSet<>();
Collection<CipherSuite> allowedCipherSuites =
CipherSuite.allowedCipherSuites();
for (CipherSuite c : allowedCipherSuites) {
......
......@@ -655,7 +655,7 @@ final class ClientHandshaker extends Handshaker {
if (certRequest != null) {
X509ExtendedKeyManager km = sslContext.getX509KeyManager();
ArrayList<String> keytypesTmp = new ArrayList<String>(4);
ArrayList<String> keytypesTmp = new ArrayList<>(4);
for (int i = 0; i < certRequest.types.length; i++) {
String typeName;
......@@ -1174,8 +1174,7 @@ final class ClientHandshaker extends Handshaker {
"Can't reuse existing SSL client session");
}
Collection<CipherSuite> cipherList =
new ArrayList<CipherSuite>(2);
Collection<CipherSuite> cipherList = new ArrayList<>(2);
cipherList.add(sessionSuite);
if (!secureRenegotiation &&
cipherSuites.contains(CipherSuite.C_SCSV)) {
......@@ -1193,7 +1192,7 @@ final class ClientHandshaker extends Handshaker {
// exclude SCSV for secure renegotiation
if (secureRenegotiation && cipherSuites.contains(CipherSuite.C_SCSV)) {
Collection<CipherSuite> cipherList =
new ArrayList<CipherSuite>(cipherSuites.size() - 1);
new ArrayList<>(cipherSuites.size() - 1);
for (CipherSuite suite : cipherSuites.collection()) {
if (suite != CipherSuite.C_SCSV) {
cipherList.add(suite);
......
......@@ -98,7 +98,7 @@ public final class DefaultSSLContextImpl extends SSLContextImpl {
return defaultKeyManagers;
}
final Map<String,String> props = new HashMap<String,String>();
final Map<String,String> props = new HashMap<>();
AccessController.doPrivileged(
new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
......
......@@ -258,7 +258,7 @@ static final class ClientHello extends HandshakeMessage {
// add server_name extension
void addServerNameIndicationExtension(String hostname) {
// We would have checked that the hostname ia a FQDN.
ArrayList<String> hostnames = new ArrayList<String>(1);
ArrayList<String> hostnames = new ArrayList<>(1);
hostnames.add(hostname);
try {
......@@ -434,7 +434,7 @@ class CertificateMsg extends HandshakeMessage
CertificateMsg(HandshakeInStream input) throws IOException {
int chainLen = input.getInt24();
List<Certificate> v = new ArrayList<Certificate>(4);
List<Certificate> v = new ArrayList<>(4);
CertificateFactory cf = null;
while (chainLen > 0) {
......@@ -1328,7 +1328,7 @@ class CertificateRequest extends HandshakeMessage
// read the certificate_authorities
int len = input.getInt16();
ArrayList<DistinguishedName> v = new ArrayList<DistinguishedName>();
ArrayList<DistinguishedName> v = new ArrayList<>();
while (len >= 3) {
DistinguishedName dn = new DistinguishedName(input);
v.add(dn);
......@@ -1719,7 +1719,7 @@ static final class CertificateVerify extends HandshakeMessage {
// Note that this will prevent the Spi classes from being GC'd. We assume
// that is not a problem.
private final static Map<Class,Object> methodCache =
new ConcurrentHashMap<Class,Object>();
new ConcurrentHashMap<>();
private static void digestKey(MessageDigest md, SecretKey key) {
try {
......
......@@ -569,7 +569,7 @@ abstract class Handshaker {
activeProtocols = getActiveProtocols();
}
ArrayList<CipherSuite> suites = new ArrayList<CipherSuite>();
ArrayList<CipherSuite> suites = new ArrayList<>();
if (!(activeProtocols.collection().isEmpty()) &&
activeProtocols.min.v != ProtocolVersion.NONE.v) {
for (CipherSuite suite : enabledCipherSuites.collection()) {
......@@ -614,8 +614,7 @@ abstract class Handshaker {
*/
ProtocolList getActiveProtocols() {
if (activeProtocols == null) {
ArrayList<ProtocolVersion> protocols =
new ArrayList<ProtocolVersion>(4);
ArrayList<ProtocolVersion> protocols = new ArrayList<>(4);
for (ProtocolVersion protocol : enabledProtocols.collection()) {
boolean found = false;
for (CipherSuite suite : enabledCipherSuites.collection()) {
......
......@@ -169,8 +169,7 @@ final class ExtensionType {
return name;
}
static List<ExtensionType> knownExtensions =
new ArrayList<ExtensionType>(9);
static List<ExtensionType> knownExtensions = new ArrayList<>(9);
static ExtensionType get(int id) {
for (ExtensionType ext : knownExtensions) {
......@@ -674,7 +673,7 @@ final class SupportedEllipticPointFormatsExtension extends HelloExtension {
}
public String toString() {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (byte format : formats) {
list.add(toString(format));
}
......
......@@ -83,7 +83,7 @@ final class ProtocolList {
throw new IllegalArgumentException("Protocols may not be null");
}
ArrayList<ProtocolVersion> versions = new ArrayList<ProtocolVersion>(3);
ArrayList<ProtocolVersion> versions = new ArrayList<>(3);
for (int i = 0; i < names.length; i++ ) {
ProtocolVersion version = ProtocolVersion.valueOf(names[i]);
if (versions.contains(version) == false) {
......
......@@ -261,7 +261,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
protected Set<String> decomposes(KeyExchange keyExchange,
boolean forCertPathOnly) {
Set<String> components = new HashSet<String>();
Set<String> components = new HashSet<>();
switch (keyExchange) {
case K_NULL:
if (!forCertPathOnly) {
......@@ -356,7 +356,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
protected Set<String> decomposes(BulkCipher bulkCipher) {
Set<String> components = new HashSet<String>();
Set<String> components = new HashSet<>();
if (bulkCipher.transformation != null) {
components.addAll(super.decomposes(bulkCipher.transformation));
......@@ -366,7 +366,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
protected Set<String> decomposes(MacAlg macAlg) {
Set<String> components = new HashSet<String>();
Set<String> components = new HashSet<>();
if (macAlg == CipherSuite.M_MD5) {
components.add("MD5");
......@@ -407,7 +407,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
if (cipherSuite != null) {
Set<String> components = new HashSet<String>();
Set<String> components = new HashSet<>();
if(cipherSuite.keyExchange != null) {
components.addAll(
......@@ -448,7 +448,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
if (cipherSuite != null) {
Set<String> components = new HashSet<String>();
Set<String> components = new HashSet<>();
if(cipherSuite.keyExchange != null) {
components.addAll(
......
......@@ -618,8 +618,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* key and the calling security context. This is important since
* sessions can be shared across different protection domains.
*/
private Hashtable<SecureKey, Object> table =
new Hashtable<SecureKey, Object>();
private Hashtable<SecureKey, Object> table = new Hashtable<>();
/**
* Assigns a session value. Session change events are given if
......@@ -687,7 +686,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
*/
public String[] getValueNames() {
Enumeration<SecureKey> e;
Vector<Object> v = new Vector<Object>();
Vector<Object> v = new Vector<>();
SecureKey key;
Object securityCtx = SecureKey.getCurrentSecurityContext();
......
......@@ -153,8 +153,7 @@ final class SignatureAndHashAlgorithm {
static Collection<SignatureAndHashAlgorithm>
getSupportedAlgorithms(AlgorithmConstraints constraints) {
Collection<SignatureAndHashAlgorithm> supported =
new ArrayList<SignatureAndHashAlgorithm>();
Collection<SignatureAndHashAlgorithm> supported = new ArrayList<>();
synchronized (priorityMap) {
for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) {
if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM &&
......@@ -171,8 +170,7 @@ final class SignatureAndHashAlgorithm {
// Get supported algorithm collection from an untrusted collection
static Collection<SignatureAndHashAlgorithm> getSupportedAlgorithms(
Collection<SignatureAndHashAlgorithm> algorithms ) {
Collection<SignatureAndHashAlgorithm> supported =
new ArrayList<SignatureAndHashAlgorithm>();
Collection<SignatureAndHashAlgorithm> supported = new ArrayList<>();
for (SignatureAndHashAlgorithm sigAlg : algorithms) {
if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) {
supported.add(sigAlg);
......@@ -184,7 +182,7 @@ final class SignatureAndHashAlgorithm {
static String[] getAlgorithmNames(
Collection<SignatureAndHashAlgorithm> algorithms) {
ArrayList<String> algorithmNames = new ArrayList<String>();
ArrayList<String> algorithmNames = new ArrayList<>();
if (algorithms != null) {
for (SignatureAndHashAlgorithm sigAlg : algorithms) {
algorithmNames.add(sigAlg.algorithm);
......@@ -197,7 +195,7 @@ final class SignatureAndHashAlgorithm {
static Set<String> getHashAlgorithmNames(
Collection<SignatureAndHashAlgorithm> algorithms) {
Set<String> algorithmNames = new HashSet<String>();
Set<String> algorithmNames = new HashSet<>();
if (algorithms != null) {
for (SignatureAndHashAlgorithm sigAlg : algorithms) {
if (sigAlg.hash.value > 0) {
......
......@@ -337,7 +337,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
X500Principal[] x500Issuers = (X500Principal[])issuers;
// the algorithm below does not produce duplicates, so avoid Set
List<String> aliases = new ArrayList<String>();
List<String> aliases = new ArrayList<>();
for (Map.Entry<String,X509Credentials> entry :
credentialsMap.entrySet()) {
......@@ -397,7 +397,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* possible. Principals that cannot be converted are ignored.
*/
private static X500Principal[] convertPrincipals(Principal[] principals) {
List<X500Principal> list = new ArrayList<X500Principal>(principals.length);
List<X500Principal> list = new ArrayList<>(principals.length);
for (int i = 0; i < principals.length; i++) {
Principal p = principals[i];
if (p instanceof X500Principal) {
......
......@@ -134,7 +134,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
FileInputStream fis = null;
String defaultTrustStoreType;
String defaultTrustStoreProvider;
final HashMap<String,String> props = new HashMap<String,String>();
final HashMap<String,String> props = new HashMap<>();
final String sep = File.separator;
KeyStore ks = null;
......
......@@ -307,7 +307,7 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
(keyTypes.length == 0) || (keyTypes[0] == null)) {
return null;
}
List<KeyType> list = new ArrayList<KeyType>(keyTypes.length);
List<KeyType> list = new ArrayList<>(keyTypes.length);
for (String keyType : keyTypes) {
list.add(new KeyType(keyType));
}
......@@ -429,7 +429,7 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
// make a Set out of the array
private Set<Principal> getIssuerSet(Principal[] issuers) {
if ((issuers != null) && (issuers.length != 0)) {
return new HashSet<Principal>(Arrays.asList(issuers));
return new HashSet<>(Arrays.asList(issuers));
} else {
return null;
}
......
......@@ -300,8 +300,8 @@ public class CookieHandlerTest {
getCalled = true;
// returns cookies[0]
// they will be include in request
Map<String,List<String>> map = new HashMap<String,List<String>>();
List<String> l = new ArrayList<String>();
Map<String,List<String>> map = new HashMap<>();
List<String> l = new ArrayList<>();
l.add(cookies.get("Cookie"));
map.put("Cookie",l);
return Collections.unmodifiableMap(map);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册