summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java13
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java4
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java2
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java2
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java2
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java5
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java3
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java3
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java22
12 files changed, 40 insertions, 22 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java
index de8ae7df..e336042a 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java
@@ -56,7 +56,7 @@ import aaf.v2_0.Users.User;
public class AAFListedCertIdentity implements CertIdentity {
//TODO should 8 hours be configurable?
- private static final long EIGHT_HOURS = 1000*60*60*8;
+ private static final long EIGHT_HOURS = 1000*60*60*8L;
private static Map<ByteArrayHolder,String> certs = null;
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
index 19beef68..ab0f595c 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.NoSuchElementException;
import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.Access.Level;
@@ -291,7 +292,8 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
case 1:
return new AAFLItem(iter,first);
default:
- int i = Math.abs(sr.nextInt())%lep.size();
+ int rand = sr.nextInt(); // Sonar chokes without.
+ int i = Math.abs(rand)%lep.size();
if(i<0) {
return null;
} else {
@@ -340,6 +342,9 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
@Override
public EP next() {
+ if(!hasNext() ) {
+ throw new NoSuchElementException();
+ }
return (EP)epa[idx++];
}
@@ -434,10 +439,10 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
public int compareTo(EP o) {
if(distance<o.distance) {
return -1;
- } else if(distance==o.distance) {
- return 0;
- } else {
+ } else if(distance>o.distance) {
return 1;
+ } else {
+ return 0;
}
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java
index 14efd32c..f900a1f4 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java
@@ -337,7 +337,7 @@ public class CmAgent {
String mechID = mechID(cmds);
String machine = machine(cmds);
String[] newmachs = machines(cmds);
- if(newmachs==null || newmachs == null) {
+ if(machine==null || newmachs == null) {
trans.error().log("No machines listed to copy to");
} else {
TimeTaken tt = trans.start("Copy Artifact", Env.REMOTE);
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java
index d9ea0170..9754b1e6 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java
@@ -48,8 +48,8 @@ import org.onap.aaf.misc.rosetta.env.RosettaDF;
import org.onap.aaf.misc.rosetta.env.RosettaEnv;
public abstract class Persist<T,CT extends Persistable<T>> extends PersistFile {
- private static final long ONE_DAY = 86400000;
- private static final long CLEAN_CHECK = 2*60*1000; // check every 2 mins
+ private static final long ONE_DAY = 86400000L;
+ private static final long CLEAN_CHECK = 2*60*1000L; // check every 2 mins
private static Timer clean;
// store all the directories to review
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java
index f75527d3..7131b607 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java
@@ -33,7 +33,7 @@ public class Persisting<T> implements Persistable<T> {
private static final byte[] EMPTY = new byte[0];
private final byte[] hash; // need to be able to validate disk entry
- private static final long SYNC_TIME = 1000*60*1; // Checking File change max 1 min
+ private static final long SYNC_TIME = 1000*60*1L; // Checking File change max 1 min
private FileTime lastTouched;
private int count;
private long expires;
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
index f2f4def1..954c8555 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
@@ -32,7 +32,7 @@ import org.onap.aaf.misc.env.impl.BasicEnv;
public class Registrar<ENV extends BasicEnv> {
private static final String REGISTRAR = "Registrar";
- private static final long INTERVAL = 15*60*1000; // 15 mins
+ private static final long INTERVAL = 15*60*1000L; // 15 mins
private static final long START = 3000; // Start in 3 seconds
private static final Object LOCK = new Object();
private Deque<Registrant<ENV>> registrants;
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java
index 7a32473c..80e6dc40 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java
@@ -51,7 +51,7 @@ public abstract class AbsAuthentication<CLIENT> implements SecuritySetter<CLIENT
protected static final String REPEAT_OFFENDER = "This call is aborted because of repeated usage of invalid Passwords";
private static final int MAX_TEMP_COUNT = 10;
private static final int MAX_SPAM_COUNT = 10000;
- private static final long WAIT_TIME = 1000*60*4;
+ private static final long WAIT_TIME = 1000*60*4L;
private final byte[] headValue;
private String user;
protected final SecurityInfoC<CLIENT> securityInfo;
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java
index f289b0e3..908b895b 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java
@@ -58,7 +58,7 @@ public class HRcli extends Rcli<HttpURLConnection> {
}
public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
- locItem=item;
+ item=locItem;
this.uri = uri;
this.hman = hman;
ss=secSet;
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
index 5820bf29..9761937e 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
@@ -49,7 +49,7 @@ public class PropertyLocator implements Locator<URI> {
private long backgroundRefresh;
public PropertyLocator(String locList) throws LocatorException {
- this(locList,10000L, 1000*60*20); // defaults, do not refresh more than once in 10 seconds, Refresh Locator every 20 mins.
+ this(locList,10000L, 1000*60*20L); // defaults, do not refresh more than once in 10 seconds, Refresh Locator every 20 mins.
}
/**
* comma delimited root url list
@@ -168,7 +168,8 @@ public class PropertyLocator implements Locator<URI> {
case 1:
return current[0];
default:
- return current[Math.abs(random.nextInt())%current.length];
+ int rand = random.nextInt(); // sonar driven syntax
+ return current[Math.abs(rand)%current.length];
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
index 90f14405..99bdb49c 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
@@ -28,8 +28,6 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import org.onap.aaf.cadi.util.Chmod;
@@ -160,7 +158,6 @@ public class CmdLine {
if((idx = line.indexOf(' '))>=0
&& (idx = line.indexOf(' ',++idx))>0
&& (idx = line.indexOf('=',++idx))>0
- && (idx = line.indexOf('=',++idx))>0
) {
System.out.println(line.substring(0, idx-5));
int start = idx+2;
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 07e9b592..bd1ad72d 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
@@ -38,7 +38,8 @@ import org.onap.aaf.cadi.config.SecurityInfo;
import java.util.Properties;
public class PropAccess implements Access {
- private static final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ // Sonar says cannot be static... it's ok. not too many PropAccesses created.
+ private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
public static Level DEFAULT = Level.AUDIT;
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 a66b6880..0c011541 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
@@ -380,7 +380,13 @@ public class Config {
/////////////////////////////////////////////////////
if(!hasOAuthDirectTAF) {
String oauth_token_url = logProp(access,Config.AAF_OAUTH2_TOKEN_URL,null);
- if(additionalTafLurs!=null && additionalTafLurs.length>0 && additionalTafLurs[0].getClass().getName().equals("org.osaaf.authz.oauth.OAuthDirectTAF")) {
+ Class<?> oadtClss;
+ try {
+ oadtClss = Class.forName("org.osaaf.authz.oauth.OAuthDirectTAF");
+ } catch (ClassNotFoundException e1) {
+ oadtClss = null;
+ }
+ if(additionalTafLurs!=null && additionalTafLurs.length>0 && (oadtClss!=null && additionalTafLurs[0].getClass().isAssignableFrom(oadtClss))) {
htlist.add((HttpTaf)additionalTafLurs[0]);
String array[] = new String[additionalTafLurs.length-1];
if(array.length>0) {
@@ -428,9 +434,17 @@ public class Config {
if(additional instanceof HttpTaf) {
htlist.add((HttpTaf)additional);
access.printf(Level.INIT,"%s Authentication is enabled",additional.getClass().getSimpleName());
- } else if(hasOAuthDirectTAF && additional.getClass().getSimpleName().equals("DirectAAFUserPass")) {
- htlist.add(new BasicHttpTaf(access, (CredVal)additional , basic_realm, userExp, basic_warn));
- access.printf(Level.INIT,"Direct BasicAuth Authentication is enabled",additional.getClass().getSimpleName());
+ } else if(hasOAuthDirectTAF) {
+ Class<?> daupCls;
+ try {
+ daupCls = Class.forName("org.onap.aaf.auth.direct.DirectAAFUserPass");
+ } catch (ClassNotFoundException e) {
+ daupCls = null;
+ }
+ if(daupCls != null && additional.getClass().isAssignableFrom(daupCls)) {
+ htlist.add(new BasicHttpTaf(access, (CredVal)additional , basic_realm, userExp, basic_warn));
+ access.printf(Level.INIT,"Direct BasicAuth Authentication is enabled",additional.getClass().getSimpleName());
+ }
}
}
}