diff options
30 files changed, 88 insertions, 48 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/Email.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/Email.java index 0687364b..25e2ffca 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/Email.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/Email.java @@ -167,7 +167,7 @@ public class Email implements Action<Organization,Void, String>{ try { Thread.sleep(wait); } catch (InterruptedException e) { - return exec(trans,org,sb); + Thread.currentThread().interrupt(); } } return exec(trans,org,sb); diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Cred.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Cred.java index 58af03b5..1131aca7 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Cred.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Cred.java @@ -264,7 +264,7 @@ public class Cred { } public long authCount(int idx) { - return basic_auth[idx]+basic_auth_256[idx]; + return (long)basic_auth[idx]+basic_auth_256[idx]; } public long x509Count(int idx) { diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/InputIterator.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/InputIterator.java index cb0bfa6a..0afcac27 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/InputIterator.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/InputIterator.java @@ -25,6 +25,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.PrintStream; import java.util.Iterator; +import java.util.NoSuchElementException; public class InputIterator implements Iterable<String> { private BufferedReader in; @@ -57,6 +58,9 @@ public class InputIterator implements Iterable<String> { @Override public String next() { + if(!hasNext()) { + throw new NoSuchElementException(); + } return input; } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java index e47e9352..66ab7344 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java @@ -321,6 +321,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl } } catch (InterruptedException e1) { go = false; + Thread.currentThread().interrupt(); } } while(go); } @@ -353,6 +354,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl } } catch (InterruptedException e) { trans.error().log("Cache Notify Queue posting was interrupted" ); + Thread.currentThread().interrupt(); } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java index 8e4ada10..0cfc1dc5 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java @@ -56,9 +56,6 @@ import com.datastax.driver.core.Row; public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> { private static final String TABLE = "history"; - public static final SimpleDateFormat monthFormat = new SimpleDateFormat("yyyyMM"); -// private static final SimpleDateFormat dayTimeFormat = new SimpleDateFormat("ddHHmmss"); - private String[] helpers; private HistLoader defLoader; @@ -177,7 +174,8 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> { public static Data newInitedData() { Data data = new Data(); Date now = new Date(); - data.yr_mon = Integer.parseInt(monthFormat.format(now)); + // Sonar claims that SimpleDateFormat is not thread safe, so we can't be static + data.yr_mon = Integer.parseInt(new SimpleDateFormat("yyyyMM").format(now)); // data.day_time = Integer.parseInt(dayTimeFormat.format(now)); return data; } diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java index 9ee321e7..896cbb30 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java @@ -56,7 +56,8 @@ import aaf.v2_0.Request; public abstract class Cmd { - private static final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); + // Sonar claims DateFormat is not thread safe. Leave as Instance Variable. + private final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); protected static final String BLANK = ""; protected static final String COMMA = ","; // for use in splits diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java index d9f7ac96..17edae42 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java @@ -26,6 +26,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.util.Iterator; +import java.util.NoSuchElementException; import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.local.DataFile.Token; @@ -87,7 +88,7 @@ public abstract class AbsData implements Iterable<String> { try { Thread.sleep(200); } catch (InterruptedException e) { - break; + Thread.currentThread().interrupt(); } begin = System.currentTimeMillis(); } @@ -188,6 +189,9 @@ public abstract class AbsData implements Iterable<String> { @Override public String next() { + if(!hasNext()) { + throw new NoSuchElementException(); + } reuse.reset(); int rec = tii.next(); reuse.pos(rec); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java index 36efb5dc..d12345a9 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java @@ -79,10 +79,16 @@ public class OrganizationFactory { if(orgClass == null) { env.warn().log("There is no Organization." + orgNS + " property"); } else { - for(Organization o : orgs.values()) { - if(orgClass.equals(o.getClass().getName())) { - org = o; + try { + Class<?> orgCls = Class.forName(orgClass); + for(Organization o : orgs.values()) { + if(o.getClass().isAssignableFrom(orgCls)) { + org = o; + } } + } catch (ClassNotFoundException e1) { + env.error().log(e1, orgClass + " is not on the Classpath."); + throw new OrganizationException(e1); } if(org==null) { try { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java index 7bb276a2..07b67bb0 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java @@ -486,7 +486,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void } public String toString() { - return data.toString(); + return Arrays.toString(data); } public void write(Writer writer) throws IOException { diff --git a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java index e0848926..9fc983e2 100644 --- a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java +++ b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java @@ -608,7 +608,7 @@ public class DefaultOrg implements Organization { Identity mechid = getIdentity(trans, vars[0]); if(mechid!=null) { Identity sponsor = mechid.responsibleTo(); - if(sponsor!=null && requestor.equals(sponsor.fullID())) { + if(sponsor!=null && requestor.fullID().equals(sponsor.fullID())) { return null; } else { return trans.user() + " is not the Sponsor of MechID " + vars[0]; diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java index e55d803c..a42d6b0b 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java @@ -23,7 +23,6 @@ package org.onap.aaf.auth.gui.pages; import java.io.IOException; import java.net.ConnectException; -import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; @@ -60,7 +59,6 @@ public class PendingRequestsShow extends Page { public static final String HREF = "/gui/myrequests"; public static final String NAME = "MyRequests"; static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id="; - private static DateFormat createdDF = new SimpleDateFormat("yyyy-MM-dd"); public PendingRequestsShow(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException { super(gui.env, NAME,HREF, NO_FIELDS, @@ -153,7 +151,8 @@ public class PendingRequestsShow extends Page { tsCell = AbsCell.Null; } else { UUID id = UUID.fromString(a.getId()); - tsCell = new RefCell(createdDF.format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000), + // Sonar says SimpleDate should not be static + tsCell = new RefCell(new SimpleDateFormat("yyyy-MM-dd").format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000), RequestDetail.HREF + "?ticket=" + ticket,false); prevTicket = ticket; } diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RolesShow.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RolesShow.java index 071666d0..e3f91ba3 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RolesShow.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RolesShow.java @@ -58,11 +58,6 @@ import aaf.v2_0.UserRoles; public class RolesShow extends Page { public static final String HREF = "/gui/myroles"; private static final String DATE_TIME_FORMAT = "yyyy-MM-dd"; - private static SimpleDateFormat expiresDF; - - static { - expiresDF = new SimpleDateFormat(DATE_TIME_FORMAT); - } public RolesShow(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException { super(gui.env, "MyRoles",HREF, NO_FIELDS, @@ -101,7 +96,7 @@ public class RolesShow extends Page { if(u.getExpires().compare(Chrono.timeStamp()) < 0) { AbsCell[] sa = new AbsCell[] { new TextCell(u.getRole() + "*", "class=expired"), - new TextCell(expiresDF.format(u.getExpires().toGregorianCalendar().getTime()),"class=expired"), + new TextCell(new SimpleDateFormat(DATE_TIME_FORMAT).format(u.getExpires().toGregorianCalendar().getTime()),"class=expired"), new RefCell("Extend", UserRoleExtend.HREF + "?user="+trans.user()+"&role="+u.getRole(), false, @@ -118,7 +113,7 @@ public class RolesShow extends Page { new RefCell(u.getRole(), RoleDetail.HREF+"?role="+u.getRole(), false), - new TextCell(expiresDF.format(u.getExpires().toGregorianCalendar().getTime())), + new TextCell(new SimpleDateFormat(DATE_TIME_FORMAT).format(u.getExpires().toGregorianCalendar().getTime())), AbsCell.Null, new RefCell("Remove", UserRoleRemove.HREF + "?user="+trans.user()+"&role="+u.getRole(), diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java index 5c8526a9..b5676372 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java @@ -2258,7 +2258,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS } - private final long DAY_IN_MILLIS = 24*3600*1000; + private final long DAY_IN_MILLIS = 24*3600*1000L; @ApiDoc( method = POST, diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_History.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_History.java index 9800ca42..8c55e7dc 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_History.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_History.java @@ -180,9 +180,10 @@ public class API_History { } // Get Common "yyyymm" parameter, or none - private static final SimpleDateFormat FMT = new SimpleDateFormat("yyyyMM"); private static int[] getYears(HttpServletRequest req) throws NumberFormatException { + // Sonar says threading issues. + SimpleDateFormat FMT = new SimpleDateFormat("yyyyMM"); String yyyymm = req.getParameter("yyyymm"); ArrayList<Integer> ai= new ArrayList<Integer>(); if(yyyymm==null) { 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()); + } } } } diff --git a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java index a8830b47..f8c6611e 100644 --- a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java +++ b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java @@ -71,7 +71,7 @@ public class LogFileNamer { public void configure(String props) { String fname; if(new File(fname="etc/"+props).exists()) { - org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000); + org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000L); } else { URL rsrc = ClassLoader.getSystemResource(props); if(rsrc==null) System.err.println("Neither File: " + fname + " or resource on Classpath " + props + " exist" ); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java index d482b247..595bc630 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java @@ -22,6 +22,7 @@ package org.onap.aaf.misc.rosetta; import java.util.Iterator; +import java.util.NoSuchElementException; import org.onap.aaf.misc.env.Env; import org.onap.aaf.misc.env.TimeTaken; @@ -58,6 +59,9 @@ public abstract class Marshal<T> implements Parse<T, Marshal.State> { @Override public Void next() { + if(!hasNext()) { + throw new NoSuchElementException(); + } return null; } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java index 5249a17a..2776546f 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java @@ -22,6 +22,7 @@ package org.onap.aaf.misc.rosetta.marshal; import java.util.Iterator; +import java.util.NoSuchElementException; import org.onap.aaf.misc.rosetta.Ladder; import org.onap.aaf.misc.rosetta.Marshal; @@ -67,6 +68,9 @@ public class DocMarshal<T> extends Marshal<T> { @Override public Void next() { + if(!hasNext()) { + throw new NoSuchElementException(); + } return null; } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java index eaa7a74a..4857293e 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java @@ -22,6 +22,7 @@ package org.onap.aaf.misc.rosetta.marshal; import java.util.Iterator; +import java.util.NoSuchElementException; import org.onap.aaf.misc.rosetta.Ladder; import org.onap.aaf.misc.rosetta.Marshal; @@ -111,6 +112,9 @@ public abstract class ObjMarshal<T> extends Marshal<T> { @Override public Marshal<T> next() { + if(!hasNext()) { + throw new NoSuchElementException(); + } return pml[++idx]; } |