diff options
Diffstat (limited to 'auth')
14 files changed, 35 insertions, 25 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) { |