summaryrefslogtreecommitdiffstats
path: root/cadi/core
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-07-03 07:51:17 -0500
committerInstrumental <jonathan.gathman@att.com>2018-07-03 12:06:59 -0500
commitf85f0889b3b0e5e9694afab4dd01a4a97a155188 (patch)
tree4a7119cfa0a112e514f50bbc2961981c3670ea03 /cadi/core
parent8efa968683ef2c4ab0ae7f4c0d2ccb0fcaa8af7b (diff)
Collection syntax change because of Sonar
Issue-ID: AAF-386 Change-Id: I8ba8d8561d03e680ddc90a81b8db0339814c65fa Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/core')
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java14
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/User.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java7
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java14
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java4
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_User.java4
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Pool.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Vars.java6
19 files changed, 51 insertions, 38 deletions
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java b/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
index c65a9b22..1d01a3e8 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
@@ -55,7 +55,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
private static Timer timer;
// Map of userName to User
private final Map<String, User<PERM>> userMap;
- private static final Map<String, Miss> missMap = new TreeMap<String,Miss>();
+ private static final Map<String, Miss> missMap = new TreeMap<>();
private final Symm missEncrypt;
private Clean clean;
@@ -73,7 +73,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
}
missEncrypt = s;
- userMap = new ConcurrentHashMap<String, User<PERM>>();
+ userMap = new ConcurrentHashMap<>();
if(cleanInterval>0) {
@@ -236,7 +236,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
}
public final List<DumpInfo> dumpInfo() {
- List<DumpInfo> rv = new ArrayList<DumpInfo>();
+ List<DumpInfo> rv = new ArrayList<>();
for(User<PERM> user : userMap.values()) {
rv.add(new DumpInfo(user));
}
@@ -265,7 +265,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
// Simple map of Group name to a set of User Names
- // private Map<String, Set<String>> groupMap = new HashMap<String, Set<String>>();
+ // private Map<String, Set<String>> groupMap = new HashMap<>();
/**
* Class to hold a small subset of the data, because we don't want to expose actual Permission or User Objects
@@ -276,7 +276,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
public DumpInfo(User<PERM> user) {
this.user = user.principal.getName();
- perms = new ArrayList<String>(user.perms.keySet());
+ perms = new ArrayList<>(user.perms.keySet());
}
}
@@ -315,7 +315,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
int total = 0;
try {
// look at now. If we need to expire more by increasing "now" by "advance"
- ArrayList<User<PERM>> al = new ArrayList<User<PERM>>(userMap.values().size());
+ ArrayList<User<PERM>> al = new ArrayList<>(userMap.values().size());
al.addAll(0, userMap.values());
long now = System.currentTimeMillis() + advance;
for(User<PERM> user : al) {
@@ -367,7 +367,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
int missTotal = missMap.keySet().size();
int miss = 0;
if(missTotal>0) {
- ArrayList<String> keys = new ArrayList<String>(missTotal);
+ ArrayList<String> keys = new ArrayList<>(missTotal);
keys.addAll(missMap.keySet());
for(String key : keys) {
Miss m = missMap.get(key);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java b/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
index 49572f4c..a2dfba37 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
@@ -140,7 +140,7 @@ public class CadiWrap extends HttpServletRequestWrapper implements HttpServletRe
* To utilize, the Request must be a "CadiWrap" object, then call.
*/
public List<Permission> getPermissions(Principal p) {
- List<Permission> perms = new ArrayList<Permission>();
+ List<Permission> perms = new ArrayList<>();
lur.fishAll(p, perms);
return perms;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
index 00383851..935e4f14 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
@@ -36,7 +36,7 @@ import java.util.ArrayList;
*/
public class Capacitor {
private static final int DEFAULT_CHUNK = 256;
- private ArrayList<ByteBuffer> bbs = new ArrayList<ByteBuffer>();
+ private ArrayList<ByteBuffer> bbs = new ArrayList<>();
private ByteBuffer curr = null;
private int idx;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
index c827477f..5e001561 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
@@ -184,7 +184,7 @@ public class PropAccess implements Access {
String chainProp = props.getProperty(Config.CADI_PROP_FILES);
if(chainProp!=null) {
if(recursionProtection==null) {
- recursionProtection = new ArrayList<String>();
+ recursionProtection = new ArrayList<>();
recursionProtection.add(cadi_prop_files);
}
if(!recursionProtection.contains(chainProp)) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
index 5a3fe825..4067f160 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
@@ -138,7 +138,7 @@ public class Symm {
// There can be time efficiencies gained when the underlying keyset consists mainly of ordered
// data (i.e. abcde...). Therefore, we'll quickly analyze the keyset. If it proves to have
// too much entropy, the "Unordered" algorithm, which is faster in such cases is used.
- ArrayList<int[]> la = new ArrayList<int[]>();
+ ArrayList<int[]> la = new ArrayList<>();
for(int i=0;i<codeset.length;++i) {
curr = codeset[i];
if(prev+1==curr) { // is next character in set
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
index 5e9f8a58..34aaf170 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
@@ -36,7 +36,7 @@ import org.onap.aaf.cadi.lur.LocalPermission;
*
*/
public final class User<PERM extends Permission> {
- private static final Map<String,Permission> NULL_MAP = new HashMap<String,Permission>();
+ private static final Map<String,Permission> NULL_MAP = new HashMap<>();
public String name;
private byte[] cred;
public Principal principal;
@@ -121,7 +121,7 @@ public final class User<PERM extends Permission> {
}
public Map<String,Permission> newMap() {
- return new ConcurrentHashMap<String,Permission>();
+ return new ConcurrentHashMap<>();
}
public void add(LocalPermission permission) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
index b74ccb36..dfcf7e3d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
@@ -259,7 +259,7 @@ public class Config {
access.log(Level.INIT, "Hostname set to",hostname);
// Get appropriate TAFs
- ArrayList<HttpTaf> htlist = new ArrayList<HttpTaf>();
+ ArrayList<HttpTaf> htlist = new ArrayList<>();
/////////////////////////////////////////////////////
// Add a Denial of Service TAF
@@ -507,7 +507,7 @@ public class Config {
public static Lur configLur(SecurityInfoC<HttpURLConnection> si, Connector con, Object ... additionalTafLurs) throws CadiException {
Access access = si.access;
- List<Lur> lurs = new ArrayList<Lur>();
+ List<Lur> lurs = new ArrayList<>();
/////////////////////////////////////////////////////
// Configure a Local Property Based RBAC/LUR
@@ -671,7 +671,7 @@ public class Config {
aafConClass = loadClass(access, AAF_V2_0_AAF_CON_HTTP);
if (aafConClass != null) {
for (Constructor<?> c : aafConClass.getConstructors()) {
- List<Object> lo = new ArrayList<Object>();
+ List<Object> lo = new ArrayList<>();
for (Class<?> pc : c.getParameterTypes()) {
if (pc.equals(Access.class)) {
lo.add(access);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
index cc366c27..a5fb4a0c 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
@@ -31,7 +31,7 @@ import org.onap.aaf.cadi.SecuritySetter;
public class SecurityInfoC<CLIENT> extends SecurityInfo {
public static final String DEF_ID = "ID not Set";
- private static Map<Class<?>,SecurityInfoC<?>> sicMap = new HashMap<Class<?>,SecurityInfoC<?>>();
+ private static Map<Class<?>,SecurityInfoC<?>> sicMap = new HashMap<>();
public SecuritySetter<CLIENT> defSS;
public SecurityInfoC(Access access) throws CadiException {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
index a3e267cd..974e5810 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
@@ -58,7 +58,7 @@ public class UsersDump {
StringBuilder sb = new StringBuilder();
// Obtain all unique role names
- HashSet<String> groups = new HashSet<String>();
+ HashSet<String> groups = new HashSet<>();
for(AbsUserCache<?>.DumpInfo di : lur.dumpInfo()) {
sb.append("\n <user username=\"");
sb.append(di.user);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
index 1f302c64..237aa28d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
@@ -218,7 +218,7 @@ public class CadiFilter implements Filter {
if(map.length>0) {
MapPermConverter mpc=null;
int idx;
- mapPairs = new ArrayList<Pair>();
+ mapPairs = new ArrayList<>();
for(String entry : map) {
if((idx=entry.indexOf('='))<0) { // it's a Path, so create a new converter
access.log(Level.INIT,"Loading Perm Conversions for:",entry);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
index 5cd6323d..5b51c111 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
@@ -93,7 +93,12 @@ public class HttpEpiTaf implements HttpTaf {
TafResp tresp = null;
TafResp firstTry = null;
List<Redirectable> redirectables = null;
- List<TafResp> log = (access.willLog(Level.DEBUG)) ? new ArrayList<TafResp>() : null;
+ List<TafResp> log;
+ if(access.willLog(Level.DEBUG)) {
+ log = new ArrayList<>();
+ } else {
+ log = null;
+ }
try {
for (HttpTaf taf : tafs) {
tresp = taf.validate(reading, req, resp);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
index dc07bb90..7b7f2db0 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
@@ -86,7 +86,7 @@ public class X509Taf implements HttpTaf {
throw new CadiException("X509Taf requires Environment ("+Config.AAF_ENV+") to be set.");
}
// this.lur = lur;
- this.cadiIssuers = new ArrayList<String>();
+ this.cadiIssuers = new ArrayList<>();
for(String ci : access.getProperty(Config.CADI_X509_ISSUERS, "").split(":")) {
access.printf(Level.INIT, "Trusting Identity for Certificates signed by \"%s\"",ci);
cadiIssuers.add(ci);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
index 44a3a4a3..a0d56f67 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
@@ -126,7 +126,7 @@ public class DenialOfServiceTaf implements HttpTaf {
public static synchronized boolean denyIP(String ip) {
boolean rv = false;
if(deniedIP==null) {
- deniedIP = new HashMap<String,Counter>();
+ deniedIP = new HashMap<>();
deniedIP.put(ip, new Counter(ip)); // Noted duplicated for minimum time spent
rv= true;
} else if(deniedIP.get(ip)==null) {
@@ -170,7 +170,7 @@ public class DenialOfServiceTaf implements HttpTaf {
br = new BufferedReader(new FileReader(dosIP));
try {
if(deniedIP==null) {
- deniedIP=new HashMap<String,Counter>();
+ deniedIP=new HashMap<>();
}
String line;
@@ -215,7 +215,7 @@ public class DenialOfServiceTaf implements HttpTaf {
public static synchronized boolean denyID(String id) {
boolean rv = false;
if(deniedID==null) {
- deniedID = new HashMap<String,Counter>();
+ deniedID = new HashMap<>();
deniedID.put(id, new Counter(id)); // Noted duplicated for minimum time spent
rv = true;
} else if(deniedID.get(id)==null) {
@@ -260,7 +260,7 @@ public class DenialOfServiceTaf implements HttpTaf {
br = new BufferedReader(new FileReader(dosID));
try {
if(deniedID==null) {
- deniedID=new HashMap<String,Counter>();
+ deniedID=new HashMap<>();
}
String line;
@@ -299,7 +299,7 @@ public class DenialOfServiceTaf implements HttpTaf {
int initSize = 0;
if(deniedIP!=null)initSize+=deniedIP.size();
if(deniedID!=null)initSize+=deniedID.size();
- ArrayList<String> al = new ArrayList<String>(initSize);
+ ArrayList<String> al = new ArrayList<>(initSize);
if(deniedID!=null) {
for(Counter c : deniedID.values()) {
al.add(c.toString());
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java
index 4312c3ca..7cd7a633 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java
@@ -107,7 +107,7 @@ public class Pool<T> {
public Pool(Creator<T> creator) {
count = spares = 0;
this.creator = creator;
- list = new LinkedList<Pooled<T>>();
+ list = new LinkedList<>();
logger = Log.NULL;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
index 7af475ad..78265e4b 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
@@ -354,14 +354,22 @@ public class XReader {
for(Tag tag : t.attribs) {
if("xmlns".equals(tag.prefix)) {
if(newnss==null) {
- newnss = new HashMap<String,String>();
+ newnss = new HashMap<>();
if(nss!=null)newnss.putAll(nss);
}
newnss.put(tag.name, tag.value);
}
}
}
- return newnss==null?(nss==null?new HashMap<String,String>():nss):newnss;
+ //return newnss==null?(nss==null?new HashMap<String,String>():nss):newnss;
+ if(newnss==null) {
+ if(nss==null) {
+ newnss = new HashMap<>();
+ } else {
+ newnss = nss;
+ }
+ }
+ return newnss;
}
/**
@@ -392,7 +400,7 @@ public class XReader {
*/
public void add(Tag attrib) {
if(attribs == null) {
- attribs = new ArrayList<Tag>();
+ attribs = new ArrayList<>();
}
attribs.add(attrib);
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
index b2739b9d..11877dea 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
@@ -284,10 +284,10 @@ public class JU_AbsUserCache {
assertThat(dumpInfo.size(), is(2));
// Utility lists
- List<String> names = new ArrayList<String>();
+ List<String> names = new ArrayList<>();
names.add(name1);
names.add(name2);
- List<String> permissions = new ArrayList<String>();
+ List<String> permissions = new ArrayList<>();
permissions.add("NewKey1");
permissions.add("NewKey2");
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_User.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_User.java
index 25683249..2d5ba8d2 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_User.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_User.java
@@ -158,7 +158,7 @@ public class JU_User {
@Test
public void addValuesToNewMapTest() {
User<Permission> user = new User<Permission>(principal);
- Map<String, Permission> newMap = new HashMap<String,Permission>();
+ Map<String, Permission> newMap = new HashMap<>();
assertFalse(user.contains(permission));
@@ -167,7 +167,7 @@ public class JU_User {
assertTrue(user.contains(permission));
- List<Permission> sink = new ArrayList<Permission>();
+ List<Permission> sink = new ArrayList<>();
user.copyPermsTo(sink);
assertThat(sink.size(), is(1));
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Pool.java b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Pool.java
index 79209322..b9f0e997 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Pool.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Pool.java
@@ -71,7 +71,7 @@ public class JU_Pool {
public void getTest() throws CadiException {
Pool<Integer> intPool = new Pool<Integer>(new IntegerCreator());
- List<Pooled<Integer>> gotten = new ArrayList<Pooled<Integer>>();
+ List<Pooled<Integer>> gotten = new ArrayList<>();
for (int i = 0; i < 10; i++) {
gotten.add(intPool.get());
assertThat(gotten.get(i).content, is(i));
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Vars.java b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Vars.java
index b2600aa5..551f725d 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Vars.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_Vars.java
@@ -39,21 +39,21 @@ public class JU_Vars {
@Test
public void convert() {
String test = "test";
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
list.add("method");
assertEquals(Vars.convert(test, list), test);
}
@Test
public void convertTest1() {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
list.add("method");
assertEquals(Vars.convert("test", list), "test");
}
@Test
public void convertTest2() {
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
list.add("method");
assertEquals(Vars.convert("test", list), "test");
}