From 36b62be84b398044e1feae657c662dba6247782f Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 29 Mar 2018 20:26:02 -0500 Subject: Clean up Sonar results 2 Issue-ID: AAF-206 Change-Id: Ia000b144be58af970f4a5264ca5a9718fdbf9f5d Signed-off-by: Instrumental --- .../main/java/org/onap/aaf/cadi/config/Config.java | 70 ++++++++++++---------- .../org/onap/aaf/cadi/config/SecurityInfo.java | 14 +++-- .../java/org/onap/aaf/cadi/config/UsersDump.java | 23 ++++--- .../org/onap/aaf/cadi/filter/CadiHTTPManip.java | 3 +- .../onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java | 15 ++--- .../src/main/java/org/onap/aaf/cadi/util/FQI.java | 2 +- .../main/java/org/onap/aaf/cadi/wsse/XReader.java | 6 +- 7 files changed, 74 insertions(+), 59 deletions(-) (limited to 'cadi/core') 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 122996a6..a66b6880 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 @@ -542,24 +542,26 @@ public class Config { } else {// There's an AAF_URL... try to configure an AAF String aafLurClassStr = logProp(access,AAF_LUR_CLASS,"org.osaaf.cadi.aaf.v2_0.AAFLurPerm"); ////////////AAF Lur 2.0 ///////////// - if(aafLurClassStr.startsWith("org.osaaf.cadi.aaf.v2_0")) { + if(aafLurClassStr!=null && aafLurClassStr.startsWith("org.osaaf.cadi.aaf.v2_0")) { try { Object aafcon = loadAAFConnector(si, aafURL); if(aafcon==null) { access.log(Level.INIT,"AAF LUR class,",aafLurClassStr,"cannot be constructed without valid AAFCon object."); } else { Class aafAbsAAFCon = loadClass(access, "org.osaaf.cadi.aaf.v2_0.AAFCon"); - Method mNewLur = aafAbsAAFCon.getMethod("newLur"); - Object aaflur = mNewLur.invoke(aafcon); - - if(aaflur==null) { - access.log(Level.INIT,"ERROR! AAF LUR Failed construction. NOT Configured"); - } else { - access.log(Level.INIT,"AAF LUR Configured to ",aafURL); - lurs.add((Lur)aaflur); - String debugIDs = logProp(access,Config.AAF_DEBUG_IDS, null); - if(debugIDs !=null && aaflur instanceof CachingLur) { - ((CachingLur)aaflur).setDebug(debugIDs); + if(aafAbsAAFCon!=null) { + Method mNewLur = aafAbsAAFCon.getMethod("newLur"); + Object aaflur = mNewLur.invoke(aafcon); + + if(aaflur==null) { + access.log(Level.INIT,"ERROR! AAF LUR Failed construction. NOT Configured"); + } else { + access.log(Level.INIT,"AAF LUR Configured to ",aafURL); + lurs.add((Lur)aaflur); + String debugIDs = logProp(access,Config.AAF_DEBUG_IDS, null); + if(debugIDs !=null && aaflur instanceof CachingLur) { + ((CachingLur)aaflur).setDebug(debugIDs); + } } } } @@ -623,23 +625,25 @@ public class Config { String aafConnector = access.getProperty(AAF_CONNECTOR_CLASS, COM_ATT_CADI_AAF_V2_0_AAF_CON_HTTP); if(COM_ATT_CADI_AAF_V2_0_AAF_CON_HTTP.equals(aafConnector)) { aafConClass = loadClass(access, COM_ATT_CADI_AAF_V2_0_AAF_CON_HTTP); - for(Constructor c : aafConClass.getConstructors()) { - List lo = new ArrayList(); - for(Class pc : c.getParameterTypes()) { - if(pc.equals(PropAccess.class)) { - lo.add(access); - } else if(pc.equals(Locator.class)) { - lo.add(loadLocator(si, aafURL)); + if(aafConClass!=null) { + for(Constructor c : aafConClass.getConstructors()) { + List lo = new ArrayList(); + for(Class pc : c.getParameterTypes()) { + if(pc.equals(PropAccess.class)) { + lo.add(access); + } else if(pc.equals(Locator.class)) { + lo.add(loadLocator(si, aafURL)); + } else { + continue; + } + } + if(c.getParameterTypes().length!=lo.size()) { + continue; // back to another Constructor } else { - continue; + aafcon = c.newInstance(lo.toArray()); } + break; } - if(c.getParameterTypes().length!=lo.size()) { - continue; // back to another Constructor - } else { - aafcon = c.newInstance(lo.toArray()); - } - break; } } if(aafcon!=null) { @@ -680,16 +684,16 @@ public class Config { @SuppressWarnings("unchecked") public static Locator loadLocator(SecurityInfoC si, final String _url) { Access access = si.access; - String url = _url, replacement; - int idxAAF_LOCATE_URL; - if((idxAAF_LOCATE_URL=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) { - url = replacement + "/locate" + _url.substring(idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length()); - } - Locator locator = null; - if(url==null) { + if(_url==null) { access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled"); } else { + String url = _url, replacement; + int idxAAF_LOCATE_URL; + if((idxAAF_LOCATE_URL=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) { + url = replacement + "/locate" + _url.substring(idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length()); + } + try { Class lcls = loadClass(access,"org.onap.aaf.cadi.aaf.v2_0.AAFLocator"); if(lcls==null) { diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java index 99f41362..30496d78 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java @@ -176,12 +176,14 @@ public class SecurityInfo { } } TrustManager tms[] = tmf.getTrustManagers(); - tm = new X509TrustManager[tms==null?0:tms.length]; - for(int i=0;i line) - int startA=0, startB=0; - for(int i=0;startA line) + int startA=0, startB=0; + for(int i=0;startA(); - } - try { + if(deniedIP==null) { + deniedIP=new HashMap(); + } + String line; while((line=br.readLine())!=null) { deniedIP.put(line, new Counter(line)); @@ -258,10 +258,11 @@ public class DenialOfServiceTaf implements HttpTaf { BufferedReader br; try { br = new BufferedReader(new FileReader(dosID)); - if(deniedID==null) { - deniedID=new HashMap(); - } try { + if(deniedID==null) { + deniedID=new HashMap(); + } + String line; while((line=br.readLine())!=null) { deniedID.put(line, new Counter(line)); diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java index b953c871..4ea50a10 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java @@ -45,7 +45,7 @@ public class FQI { } } - return sb.toString(); + return sb==null?"":sb.toString(); } } 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 4e5048b8..7af475ad 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 @@ -140,7 +140,7 @@ public class XReader { // scoping behavior when used with the Stack // drop through on purpose case END_TAG: - ns = t.prefix==null?"":nss.get(t.prefix); // Get the namespace from prefix (if exists) + ns = t.prefix==null||nss==null?"":nss.get(t.prefix); // Get the namespace from prefix (if exists) break; default: ns = ""; @@ -330,7 +330,9 @@ public class XReader { if(type==0) { type=START_TAG; } - tag.state|=type; // add the appropriate Tag States + if(tag!=null) { + tag.state|=type; // add the appropriate Tag States + } return tag; } -- cgit 1.2.3-korg