mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-17 13:55:20 +00:00
7008728: diamond conversion of basic security, permissions, authentication
Reviewed-by: mullan
This commit is contained in:
parent
c816ca10db
commit
b2ef93e7d4
@ -1180,7 +1180,7 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||
// Done
|
||||
return certs;
|
||||
|
||||
ArrayList<Certificate> userCertList = new ArrayList<Certificate>();
|
||||
ArrayList<Certificate> userCertList = new ArrayList<>();
|
||||
i = 0;
|
||||
while (i < certs.length) {
|
||||
userCertList.add(certs[i]);
|
||||
|
||||
@ -99,10 +99,10 @@ public class DialogCallbackHandler implements CallbackHandler {
|
||||
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();
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
|
||||
|
||||
// new configuration
|
||||
HashMap<String, LinkedList<AppConfigurationEntry>> newConfig =
|
||||
new HashMap<String, LinkedList<AppConfigurationEntry>>();
|
||||
new HashMap<>();
|
||||
|
||||
if (url != null) {
|
||||
|
||||
@ -392,8 +392,7 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
|
||||
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 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
|
||||
}
|
||||
|
||||
// get the args
|
||||
HashMap<String, String> options = new HashMap<String, String>();
|
||||
HashMap<String, String> options = new HashMap<>();
|
||||
String key;
|
||||
String value;
|
||||
while (peek(";") == false) {
|
||||
|
||||
@ -184,7 +184,7 @@ public class JndiLoginModule implements LoginModule {
|
||||
private UnixNumericUserPrincipal UIDPrincipal;
|
||||
private UnixNumericGroupPrincipal GIDPrincipal;
|
||||
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
|
||||
new LinkedList<UnixNumericGroupPrincipal>();
|
||||
new LinkedList<>();
|
||||
|
||||
// initial state
|
||||
private Subject subject;
|
||||
|
||||
@ -658,8 +658,7 @@ public class KeyStoreLoginModule implements LoginModule {
|
||||
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]);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class SolarisLoginModule implements LoginModule {
|
||||
private SolarisNumericUserPrincipal UIDPrincipal;
|
||||
private SolarisNumericGroupPrincipal GIDPrincipal;
|
||||
private LinkedList<SolarisNumericGroupPrincipal> supplementaryGroups =
|
||||
new LinkedList<SolarisNumericGroupPrincipal>();
|
||||
new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Initialize this <code>LoginModule</code>.
|
||||
|
||||
@ -70,7 +70,7 @@ public class UnixLoginModule implements LoginModule {
|
||||
private UnixNumericUserPrincipal UIDPrincipal;
|
||||
private UnixNumericGroupPrincipal GIDPrincipal;
|
||||
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
|
||||
new LinkedList<UnixNumericGroupPrincipal>();
|
||||
new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Initialize this <code>LoginModule</code>.
|
||||
|
||||
@ -121,7 +121,7 @@ public final class AccessControlContext {
|
||||
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]);
|
||||
|
||||
@ -515,7 +515,7 @@ implements java.io.Serializable
|
||||
|
||||
// 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);
|
||||
|
||||
@ -188,7 +188,7 @@ public class CodeSource implements java.io.Serializable {
|
||||
} 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 @@ public class CodeSource implements java.io.Serializable {
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
@ -362,7 +362,7 @@ implements Serializable
|
||||
|
||||
// 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 @@ implements Serializable
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -336,8 +336,8 @@ public class ProtectionDomain {
|
||||
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
|
||||
|
||||
@ -437,7 +437,7 @@ public abstract class Provider extends Properties {
|
||||
|
||||
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 @@ public abstract class Provider extends Properties {
|
||||
}
|
||||
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 @@ public abstract class Provider extends Properties {
|
||||
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) {
|
||||
|
||||
@ -50,7 +50,7 @@ public class SecureClassLoader extends ClassLoader {
|
||||
// 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");
|
||||
|
||||
|
||||
@ -545,8 +545,7 @@ public final class Security {
|
||||
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 @@ public final class Security {
|
||||
// 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 @@ public final class Security {
|
||||
}
|
||||
|
||||
// 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 @@ public final class Security {
|
||||
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 @@ public final class Security {
|
||||
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++) {
|
||||
|
||||
@ -198,7 +198,7 @@ implements java.io.Serializable
|
||||
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]);
|
||||
|
||||
@ -119,7 +119,7 @@ implements java.io.Serializable
|
||||
|
||||
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 @@ implements java.io.Serializable
|
||||
|
||||
// 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 @@ implements java.io.Serializable
|
||||
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 @@ implements java.io.Serializable
|
||||
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
|
||||
|
||||
@ -329,7 +329,7 @@ public final class PrivateCredentialPermission extends Permission {
|
||||
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;
|
||||
|
||||
@ -48,7 +48,7 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner {
|
||||
|
||||
private Subject subject;
|
||||
private WeakKeyValueMap<ProtectionDomain, ProtectionDomain> cachedPDs =
|
||||
new WeakKeyValueMap<ProtectionDomain, ProtectionDomain>();
|
||||
new WeakKeyValueMap<>();
|
||||
private Set<Principal> principalSet;
|
||||
private Principal[] principals;
|
||||
|
||||
|
||||
@ -361,7 +361,7 @@ final class KrbDelegationPermissionCollection extends PermissionCollection
|
||||
// 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);
|
||||
|
||||
@ -569,7 +569,7 @@ final class KrbServicePermissionCollection extends PermissionCollection
|
||||
// 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);
|
||||
|
||||
@ -37,7 +37,7 @@ import java.security.acl.*;
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
|
||||
@ -41,15 +41,15 @@ public class AclImpl extends OwnerImpl implements Acl {
|
||||
// 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 @@ public class AclImpl extends OwnerImpl implements Acl {
|
||||
//
|
||||
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 @@ public class AclImpl extends OwnerImpl implements Acl {
|
||||
//
|
||||
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());
|
||||
|
||||
@ -34,7 +34,7 @@ import java.security.acl.*;
|
||||
* @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 @@ public class GroupImpl implements Group {
|
||||
if (groupMembers.contains(member)) {
|
||||
return true;
|
||||
} else {
|
||||
Vector<Group> alreadySeen = new Vector<Group>(10);
|
||||
Vector<Group> alreadySeen = new Vector<>(10);
|
||||
return isMemberRecurse(member, alreadySeen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ class SearchFirstMode extends LdapConfiguration {
|
||||
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 @@ class AuthFirstMode extends LdapConfiguration {
|
||||
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 @@ class AuthOnlyMode extends LdapConfiguration {
|
||||
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",
|
||||
|
||||
@ -73,7 +73,7 @@ public class CheckOptions {
|
||||
|
||||
// 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 @@ public class CheckOptions {
|
||||
|
||||
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 @@ public class CheckOptions {
|
||||
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user