From f85f0889b3b0e5e9694afab4dd01a4a97a155188 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Tue, 3 Jul 2018 07:51:17 -0500 Subject: Collection syntax change because of Sonar Issue-ID: AAF-386 Change-Id: I8ba8d8561d03e680ddc90a81b8db0339814c65fa Signed-off-by: Instrumental --- .../core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java | 14 +++++++------- cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java | 2 +- cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java | 2 +- cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java | 2 +- cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java | 2 +- cadi/core/src/main/java/org/onap/aaf/cadi/User.java | 4 ++-- .../src/main/java/org/onap/aaf/cadi/config/Config.java | 6 +++--- .../main/java/org/onap/aaf/cadi/config/SecurityInfoC.java | 2 +- .../src/main/java/org/onap/aaf/cadi/config/UsersDump.java | 2 +- .../src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java | 2 +- .../src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java | 7 ++++++- .../src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java | 2 +- .../java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java | 10 +++++----- cadi/core/src/main/java/org/onap/aaf/cadi/util/Pool.java | 2 +- .../core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java | 14 +++++++++++--- 15 files changed, 43 insertions(+), 30 deletions(-) (limited to 'cadi/core/src/main') 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 { private static Timer timer; // Map of userName to User private final Map> userMap; - private static final Map missMap = new TreeMap(); + private static final Map missMap = new TreeMap<>(); private final Symm missEncrypt; private Clean clean; @@ -73,7 +73,7 @@ public abstract class AbsUserCache { } missEncrypt = s; - userMap = new ConcurrentHashMap>(); + userMap = new ConcurrentHashMap<>(); if(cleanInterval>0) { @@ -236,7 +236,7 @@ public abstract class AbsUserCache { } public final List dumpInfo() { - List rv = new ArrayList(); + List rv = new ArrayList<>(); for(User user : userMap.values()) { rv.add(new DumpInfo(user)); } @@ -265,7 +265,7 @@ public abstract class AbsUserCache { // Simple map of Group name to a set of User Names - // private Map> groupMap = new HashMap>(); + // private Map> 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 { public DumpInfo(User user) { this.user = user.principal.getName(); - perms = new ArrayList(user.perms.keySet()); + perms = new ArrayList<>(user.perms.keySet()); } } @@ -315,7 +315,7 @@ public abstract class AbsUserCache { int total = 0; try { // look at now. If we need to expire more by increasing "now" by "advance" - ArrayList> al = new ArrayList>(userMap.values().size()); + ArrayList> al = new ArrayList<>(userMap.values().size()); al.addAll(0, userMap.values()); long now = System.currentTimeMillis() + advance; for(User user : al) { @@ -367,7 +367,7 @@ public abstract class AbsUserCache { int missTotal = missMap.keySet().size(); int miss = 0; if(missTotal>0) { - ArrayList keys = new ArrayList(missTotal); + ArrayList 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 getPermissions(Principal p) { - List perms = new ArrayList(); + List 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 bbs = new ArrayList(); + private ArrayList 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(); + 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 la = new ArrayList(); + ArrayList la = new ArrayList<>(); for(int i=0;i { - private static final Map NULL_MAP = new HashMap(); + private static final Map NULL_MAP = new HashMap<>(); public String name; private byte[] cred; public Principal principal; @@ -121,7 +121,7 @@ public final class User { } public Map newMap() { - return new ConcurrentHashMap(); + 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 htlist = new ArrayList(); + ArrayList htlist = new ArrayList<>(); ///////////////////////////////////////////////////// // Add a Denial of Service TAF @@ -507,7 +507,7 @@ public class Config { public static Lur configLur(SecurityInfoC si, Connector con, Object ... additionalTafLurs) throws CadiException { Access access = si.access; - List lurs = new ArrayList(); + List 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 lo = new ArrayList(); + List 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 extends SecurityInfo { public static final String DEF_ID = "ID not Set"; - private static Map,SecurityInfoC> sicMap = new HashMap,SecurityInfoC>(); + private static Map,SecurityInfoC> sicMap = new HashMap<>(); public SecuritySetter 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 groups = new HashSet(); + HashSet groups = new HashSet<>(); for(AbsUserCache.DumpInfo di : lur.dumpInfo()) { sb.append("\n 0) { MapPermConverter mpc=null; int idx; - mapPairs = new ArrayList(); + 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 redirectables = null; - List log = (access.willLog(Level.DEBUG)) ? new ArrayList() : null; + List 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(); + 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(); + 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(); + 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(); + 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(); + 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 al = new ArrayList(initSize); + ArrayList 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 { public Pool(Creator creator) { count = spares = 0; this.creator = creator; - list = new LinkedList>(); + 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(); + newnss = new HashMap<>(); if(nss!=null)newnss.putAll(nss); } newnss.put(tag.name, tag.value); } } } - return newnss==null?(nss==null?new HashMap():nss):newnss; + //return newnss==null?(nss==null?new HashMap():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(); + attribs = new ArrayList<>(); } attribs.add(attrib); } -- cgit 1.2.3-korg