7008728: diamond conversion of basic security, permissions, authentication
Reviewed-by: mullan
--- a/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java Fri Jan 07 15:39:58 2011 -0800
@@ -1180,7 +1180,7 @@
// Done
return certs;
- ArrayList<Certificate> userCertList = new ArrayList<Certificate>();
+ ArrayList<Certificate> userCertList = new ArrayList<>();
i = 0;
while (i < certs.length) {
userCertList.add(certs[i]);
--- a/jdk/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/callback/DialogCallbackHandler.java Fri Jan 07 15:39:58 2011 -0800
@@ -99,10 +99,10 @@
throws UnsupportedCallbackException
{
/* Collect messages to display in the dialog */
- final List<Object> messages = new ArrayList<Object>(3);
+ final List<Object> messages = new ArrayList<>(3);
/* Collection actions to perform if the user clicks OK */
- final List<Action> okActions = new ArrayList<Action>(2);
+ final List<Action> okActions = new ArrayList<>(2);
ConfirmationInfo confirmation = new ConfirmationInfo();
--- a/jdk/src/share/classes/com/sun/security/auth/login/ConfigFile.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/login/ConfigFile.java Fri Jan 07 15:39:58 2011 -0800
@@ -152,7 +152,7 @@
// new configuration
HashMap<String, LinkedList<AppConfigurationEntry>> newConfig =
- new HashMap<String, LinkedList<AppConfigurationEntry>>();
+ new HashMap<>();
if (url != null) {
@@ -392,8 +392,7 @@
String moduleClass;
String sflag;
AppConfigurationEntry.LoginModuleControlFlag controlFlag;
- LinkedList<AppConfigurationEntry> configEntries =
- new LinkedList<AppConfigurationEntry>();
+ LinkedList<AppConfigurationEntry> configEntries = new LinkedList<>();
// application name
appName = st.sval;
@@ -433,7 +432,7 @@
}
// get the args
- HashMap<String, String> options = new HashMap<String, String>();
+ HashMap<String, String> options = new HashMap<>();
String key;
String value;
while (peek(";") == false) {
--- a/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java Fri Jan 07 15:39:58 2011 -0800
@@ -184,7 +184,7 @@
private UnixNumericUserPrincipal UIDPrincipal;
private UnixNumericGroupPrincipal GIDPrincipal;
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
- new LinkedList<UnixNumericGroupPrincipal>();
+ new LinkedList<>();
// initial state
private Subject subject;
--- a/jdk/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java Fri Jan 07 15:39:58 2011 -0800
@@ -658,8 +658,7 @@
throw new FailedLoginException(
"Unable to find X.509 certificate chain in keystore");
} else {
- LinkedList<Certificate> certList =
- new LinkedList<Certificate>();
+ LinkedList<Certificate> certList = new LinkedList<>();
for (int i=0; i < fromKeyStore.length; i++) {
certList.add(fromKeyStore[i]);
}
--- a/jdk/src/share/classes/com/sun/security/auth/module/SolarisLoginModule.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/module/SolarisLoginModule.java Fri Jan 07 15:39:58 2011 -0800
@@ -76,7 +76,7 @@
private SolarisNumericUserPrincipal UIDPrincipal;
private SolarisNumericGroupPrincipal GIDPrincipal;
private LinkedList<SolarisNumericGroupPrincipal> supplementaryGroups =
- new LinkedList<SolarisNumericGroupPrincipal>();
+ new LinkedList<>();
/**
* Initialize this <code>LoginModule</code>.
--- a/jdk/src/share/classes/com/sun/security/auth/module/UnixLoginModule.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/com/sun/security/auth/module/UnixLoginModule.java Fri Jan 07 15:39:58 2011 -0800
@@ -70,7 +70,7 @@
private UnixNumericUserPrincipal UIDPrincipal;
private UnixNumericGroupPrincipal GIDPrincipal;
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
- new LinkedList<UnixNumericGroupPrincipal>();
+ new LinkedList<>();
/**
* Initialize this <code>LoginModule</code>.
--- a/jdk/src/share/classes/java/security/AccessControlContext.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/AccessControlContext.java Fri Jan 07 15:39:58 2011 -0800
@@ -121,7 +121,7 @@
this.context = null;
}
} else {
- List<ProtectionDomain> v = new ArrayList<ProtectionDomain>(context.length);
+ List<ProtectionDomain> v = new ArrayList<>(context.length);
for (int i =0; i< context.length; i++) {
if ((context[i] != null) && (!v.contains(context[i])))
v.add(context[i]);
--- a/jdk/src/share/classes/java/security/BasicPermission.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/BasicPermission.java Fri Jan 07 15:39:58 2011 -0800
@@ -515,7 +515,7 @@
// Copy perms into a Hashtable
Hashtable<String, Permission> permissions =
- new Hashtable<String, Permission>(perms.size()*2);
+ new Hashtable<>(perms.size()*2);
synchronized (this) {
permissions.putAll(perms);
--- a/jdk/src/share/classes/java/security/CodeSource.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/CodeSource.java Fri Jan 07 15:39:58 2011 -0800
@@ -188,7 +188,7 @@
} else if (signers != null) {
// Convert the code signers to certs
ArrayList<java.security.cert.Certificate> certChains =
- new ArrayList<java.security.cert.Certificate>();
+ new ArrayList<>();
for (int i = 0; i < signers.length; i++) {
certChains.addAll(
signers[i].getSignerCertPath().getCertificates());
@@ -606,10 +606,10 @@
// Iterate through all the certificates
int i = 0;
- List<CodeSigner> signers = new ArrayList<CodeSigner>();
+ List<CodeSigner> signers = new ArrayList<>();
while (i < certs.length) {
List<java.security.cert.Certificate> certChain =
- new ArrayList<java.security.cert.Certificate>();
+ new ArrayList<>();
certChain.add(certs[i++]); // first cert is an end-entity cert
int j = i;
--- a/jdk/src/share/classes/java/security/Permissions.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/Permissions.java Fri Jan 07 15:39:58 2011 -0800
@@ -362,7 +362,7 @@
// Copy perms into a Hashtable
Hashtable<Class<?>, PermissionCollection> perms =
- new Hashtable<Class<?>, PermissionCollection>(permsMap.size()*2); // no sync; estimate
+ new Hashtable<>(permsMap.size()*2); // no sync; estimate
synchronized (this) {
perms.putAll(permsMap);
}
@@ -567,7 +567,7 @@
// Copy perms into a Hashtable
Hashtable<Permission, Permission> perms =
- new Hashtable<Permission, Permission>(permsMap.size()*2);
+ new Hashtable<>(permsMap.size()*2);
synchronized (this) {
perms.putAll(permsMap);
}
--- a/jdk/src/share/classes/java/security/ProtectionDomain.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/ProtectionDomain.java Fri Jan 07 15:39:58 2011 -0800
@@ -336,8 +336,8 @@
int swag = 32;
int vcap = 8;
Enumeration<Permission> e;
- List<Permission> pdVector = new ArrayList<Permission>(vcap);
- List<Permission> plVector = new ArrayList<Permission>(swag);
+ List<Permission> pdVector = new ArrayList<>(vcap);
+ List<Permission> plVector = new ArrayList<>(swag);
//
// Build a vector of domain permissions for subsequent merge
--- a/jdk/src/share/classes/java/security/Provider.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/Provider.java Fri Jan 07 15:39:58 2011 -0800
@@ -437,7 +437,7 @@
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- Map<Object,Object> copy = new HashMap<Object,Object>();
+ Map<Object,Object> copy = new HashMap<>();
for (Map.Entry<Object,Object> entry : super.entrySet()) {
copy.put(entry.getKey(), entry.getValue());
}
@@ -719,7 +719,7 @@
}
if (serviceSet == null) {
ensureLegacyParsed();
- Set<Service> set = new LinkedHashSet<Service>();
+ Set<Service> set = new LinkedHashSet<>();
if (serviceMap != null) {
set.addAll(serviceMap.values());
}
@@ -1395,7 +1395,7 @@
if (s != null) {
String[] classNames = s.split("\\|");
List<Class> classList =
- new ArrayList<Class>(classNames.length);
+ new ArrayList<>(classNames.length);
for (String className : classNames) {
Class clazz = getKeyClass(className);
if (clazz != null) {
--- a/jdk/src/share/classes/java/security/SecureClassLoader.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/SecureClassLoader.java Fri Jan 07 15:39:58 2011 -0800
@@ -50,7 +50,7 @@
// HashMap that maps CodeSource to ProtectionDomain
// @GuardedBy("pdcache")
private final HashMap<CodeSource, ProtectionDomain> pdcache =
- new HashMap<CodeSource, ProtectionDomain>(11);
+ new HashMap<>(11);
private static final Debug debug = Debug.getInstance("scl");
--- a/jdk/src/share/classes/java/security/Security.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/Security.java Fri Jan 07 15:39:58 2011 -0800
@@ -545,8 +545,7 @@
value = filter.substring(index + 1);
}
- Hashtable<String, String> hashtableFilter =
- new Hashtable<String, String>(1);
+ Hashtable<String, String> hashtableFilter = new Hashtable<>(1);
hashtableFilter.put(key, value);
return (getProviders(hashtableFilter));
@@ -606,7 +605,7 @@
// Then only return those providers who satisfy the selection criteria.
Provider[] allProviders = Security.getProviders();
Set<String> keySet = filter.keySet();
- LinkedHashSet<Provider> candidates = new LinkedHashSet<Provider>(5);
+ LinkedHashSet<Provider> candidates = new LinkedHashSet<>(5);
// Returns all installed providers
// if the selection criteria is null.
@@ -660,8 +659,7 @@
}
// Map containing cached Spi Class objects of the specified type
- private static final Map<String,Class> spiMap =
- new ConcurrentHashMap<String,Class>();
+ private static final Map<String,Class> spiMap = new ConcurrentHashMap<>();
/**
* Return the Class object for the given engine type
@@ -885,7 +883,7 @@
String attrName,
String filterValue,
Provider[] allProviders) {
- LinkedHashSet<Provider> candidates = new LinkedHashSet<Provider>(5);
+ LinkedHashSet<Provider> candidates = new LinkedHashSet<>(5);
for (int i = 0; i < allProviders.length; i++) {
if (isCriterionSatisfied(allProviders[i], serviceName,
algName,
@@ -1082,7 +1080,7 @@
return Collections.EMPTY_SET;
}
- HashSet<String> result = new HashSet<String>();
+ HashSet<String> result = new HashSet<>();
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
--- a/jdk/src/share/classes/java/security/UnresolvedPermission.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/UnresolvedPermission.java Fri Jan 07 15:39:58 2011 -0800
@@ -198,7 +198,7 @@
if (this.certs == null) {
// extract the signer certs
ArrayList<java.security.cert.Certificate> signerCerts =
- new ArrayList<java.security.cert.Certificate>();
+ new ArrayList<>();
i = 0;
while (i < certs.length) {
signerCerts.add(certs[i]);
--- a/jdk/src/share/classes/java/security/UnresolvedPermissionCollection.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/java/security/UnresolvedPermissionCollection.java Fri Jan 07 15:39:58 2011 -0800
@@ -119,7 +119,7 @@
public Enumeration<Permission> elements() {
List<Permission> results =
- new ArrayList<Permission>(); // where results are stored
+ new ArrayList<>(); // where results are stored
// Get iterator of Map values (which are lists of permissions)
synchronized (this) {
@@ -161,7 +161,7 @@
// Copy perms into a Hashtable
Hashtable<String, Vector<UnresolvedPermission>> permissions =
- new Hashtable<String, Vector<UnresolvedPermission>>(perms.size()*2);
+ new Hashtable<>(perms.size()*2);
// Convert each entry (List) into a Vector
synchronized (this) {
@@ -169,8 +169,7 @@
for (Map.Entry<String, List<UnresolvedPermission>> e : set) {
// Convert list into Vector
List<UnresolvedPermission> list = e.getValue();
- Vector<UnresolvedPermission> vec =
- new Vector<UnresolvedPermission>(list.size());
+ Vector<UnresolvedPermission> vec = new Vector<>(list.size());
synchronized (list) {
vec.addAll(list);
}
@@ -207,8 +206,7 @@
for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
// Convert Vector into ArrayList
Vector<UnresolvedPermission> vec = e.getValue();
- List<UnresolvedPermission> list =
- new ArrayList<UnresolvedPermission>(vec.size());
+ List<UnresolvedPermission> list = new ArrayList<>(vec.size());
list.addAll(vec);
// Add to Hashtable being serialized
--- a/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Fri Jan 07 15:39:58 2011 -0800
@@ -329,7 +329,7 @@
throw new IllegalArgumentException("invalid empty name");
}
- ArrayList<CredOwner> pList = new ArrayList<CredOwner>();
+ ArrayList<CredOwner> pList = new ArrayList<>();
StringTokenizer tokenizer = new StringTokenizer(name, " ", true);
String principalClass = null;
String principalName = null;
--- a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Fri Jan 07 15:39:58 2011 -0800
@@ -48,7 +48,7 @@
private Subject subject;
private WeakKeyValueMap<ProtectionDomain, ProtectionDomain> cachedPDs =
- new WeakKeyValueMap<ProtectionDomain, ProtectionDomain>();
+ new WeakKeyValueMap<>();
private Set<Principal> principalSet;
private Principal[] principals;
--- a/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Fri Jan 07 15:39:58 2011 -0800
@@ -361,7 +361,7 @@
// Don't call out.defaultWriteObject()
// Write out Vector
- Vector<Permission> permissions = new Vector<Permission>(perms.size());
+ Vector<Permission> permissions = new Vector<>(perms.size());
synchronized (this) {
permissions.addAll(perms);
--- a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Fri Jan 07 15:39:58 2011 -0800
@@ -569,7 +569,7 @@
// Don't call out.defaultWriteObject()
// Write out Vector
- Vector<Permission> permissions = new Vector<Permission>(perms.size());
+ Vector<Permission> permissions = new Vector<>(perms.size());
synchronized (this) {
permissions.addAll(perms);
--- a/jdk/src/share/classes/sun/security/acl/AclEntryImpl.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/sun/security/acl/AclEntryImpl.java Fri Jan 07 15:39:58 2011 -0800
@@ -37,7 +37,7 @@
*/
public class AclEntryImpl implements AclEntry {
private Principal user = null;
- private Vector<Permission> permissionSet = new Vector<Permission>(10, 10);
+ private Vector<Permission> permissionSet = new Vector<>(10, 10);
private boolean negative = false;
/**
--- a/jdk/src/share/classes/sun/security/acl/AclImpl.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/sun/security/acl/AclImpl.java Fri Jan 07 15:39:58 2011 -0800
@@ -41,15 +41,15 @@
// or principal.
//
private Hashtable<Principal, AclEntry> allowedUsersTable =
- new Hashtable<Principal, AclEntry>(23);
+ new Hashtable<>(23);
private Hashtable<Principal, AclEntry> allowedGroupsTable =
- new Hashtable<Principal, AclEntry>(23);
+ new Hashtable<>(23);
private Hashtable<Principal, AclEntry> deniedUsersTable =
- new Hashtable<Principal, AclEntry>(23);
+ new Hashtable<>(23);
private Hashtable<Principal, AclEntry> deniedGroupsTable =
- new Hashtable<Principal, AclEntry>(23);
+ new Hashtable<>(23);
private String aclName = null;
- private Vector<Permission> zeroSet = new Vector<Permission>(1,1);
+ private Vector<Permission> zeroSet = new Vector<>(1,1);
/**
@@ -294,7 +294,7 @@
//
private static Enumeration<Permission> union(Enumeration<Permission> e1,
Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<Permission>(20, 20);
+ Vector<Permission> v = new Vector<>(20, 20);
while (e1.hasMoreElements())
v.addElement(e1.nextElement());
@@ -313,7 +313,7 @@
//
private Enumeration<Permission> subtract(Enumeration<Permission> e1,
Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<Permission>(20, 20);
+ Vector<Permission> v = new Vector<>(20, 20);
while (e1.hasMoreElements())
v.addElement(e1.nextElement());
--- a/jdk/src/share/classes/sun/security/acl/GroupImpl.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/src/share/classes/sun/security/acl/GroupImpl.java Fri Jan 07 15:39:58 2011 -0800
@@ -34,7 +34,7 @@
* @author Satish Dharmaraj
*/
public class GroupImpl implements Group {
- private Vector<Principal> groupMembers = new Vector<Principal>(50, 100);
+ private Vector<Principal> groupMembers = new Vector<>(50, 100);
private String group;
/**
@@ -131,7 +131,7 @@
if (groupMembers.contains(member)) {
return true;
} else {
- Vector<Group> alreadySeen = new Vector<Group>(10);
+ Vector<Group> alreadySeen = new Vector<>(10);
return isMemberRecurse(member, alreadySeen);
}
}
--- a/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.java Fri Jan 07 15:39:58 2011 -0800
@@ -178,7 +178,7 @@
public SearchFirstMode() {
super();
- Map<String, String> options = new HashMap<String, String>(4);
+ Map<String, String> options = new HashMap<>(4);
options.put("userProvider", "ldap://localhost:23456/dc=example,dc=com");
options.put("userFilter",
"(&(uid={USERNAME})(objectClass=inetOrgPerson))");
@@ -213,7 +213,7 @@
public AuthFirstMode() {
super();
- Map<String, String> options = new HashMap<String, String>(5);
+ Map<String, String> options = new HashMap<>(5);
options.put("userProvider", "ldap://localhost:23456/dc=example,dc=com");
options.put("authIdentity", "{USERNAME}");
options.put("userFilter",
@@ -248,7 +248,7 @@
public AuthOnlyMode() {
super();
- Map<String, String> options = new HashMap<String, String>(4);
+ Map<String, String> options = new HashMap<>(4);
options.put("userProvider",
"ldap://localhost:23456 ldap://localhost:23457");
options.put("authIdentity",
--- a/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckOptions.java Fri Jan 07 21:02:58 2011 +0000
+++ b/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckOptions.java Fri Jan 07 15:39:58 2011 -0800
@@ -73,7 +73,7 @@
// bad value for userProvider option
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, String> options = new HashMap<>();
options.put(USER_PROVIDER_OPTION, "ldap://localhost:23456");
ldap.initialize(subject, null, null, options);
@@ -93,7 +93,7 @@
LdapLoginModule ldap = new LdapLoginModule();
Subject subject = new Subject();
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, String> options = new HashMap<>();
ldap.initialize(subject, null, null, options);
try {
@@ -110,7 +110,7 @@
LdapLoginModule ldap = new LdapLoginModule();
Subject subject = new Subject();
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, String> options = new HashMap<>();
CallbackHandler goodHandler = new MyCallbackHandler(true);
ldap.initialize(subject, goodHandler, null, options);