try {
Thread.sleep(wait);
} catch (InterruptedException e) {
- return exec(trans,org,sb);
+ Thread.currentThread().interrupt();
}
}
return exec(trans,org,sb);
}
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) {
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;
@Override
public String next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
return input;
}
}
} catch (InterruptedException e1) {
go = false;
+ Thread.currentThread().interrupt();
}
} while(go);
}
}
} catch (InterruptedException e) {
trans.error().log("Cache Notify Queue posting was interrupted" );
+ Thread.currentThread().interrupt();
}
}
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;
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;
}
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
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;
try {
Thread.sleep(200);
} catch (InterruptedException e) {
- break;
+ Thread.currentThread().interrupt();
}
begin = System.currentTimeMillis();
}
@Override
public String next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
reuse.reset();
int rec = tii.next();
reuse.pos(rec);
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 {
}
public String toString() {
- return data.toString();
+ return Arrays.toString(data);
}
public void write(Writer writer) throws IOException {
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];
import java.io.IOException;
import java.net.ConnectException;
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
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,
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;
}
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,
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,
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(),
}
- private final long DAY_IN_MILLIS = 24*3600*1000;
+ private final long DAY_IN_MILLIS = 24*3600*1000L;
@ApiDoc(
method = POST,
}
// 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) {
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;
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;
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 {
@Override
public EP next() {
+ if(!hasNext() ) {
+ throw new NoSuchElementException();
+ }
return (EP)epa[idx++];
}
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;
}
}
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);
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
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;
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;
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;
}
public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
- locItem=item;
+ item=locItem;
this.uri = uri;
this.hman = hman;
ss=secSet;
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
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];
}
}
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;
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;
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;
/////////////////////////////////////////////////////
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) {
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());
+ }
}
}
}
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" );
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;
@Override
public Void next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
return null;
}
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;
@Override
public Void next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
return null;
}
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;
@Override
public Marshal<T> next() {
+ if(!hasNext()) {
+ throw new NoSuchElementException();
+ }
return pml[++idx];
}