diff options
author | Instrumental <jonathan.gathman@att.com> | 2018-09-07 13:43:23 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2018-09-07 13:43:26 -0500 |
commit | 7e966914050e66219689001ff4ab601a49eef0ac (patch) | |
tree | b1bf643f2d191207adc7d9f6b41ac20f56083e76 /auth/auth-core/src | |
parent | ead32f193586e39b59bb366bddf70e665173a52d (diff) |
Mass whitespace changes (Style Warnings)
Issue-ID: AAF-473
Change-Id: Ia1b3825a527bd56299949b5962bb9354dffbeef8
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-core/src')
35 files changed, 348 insertions, 348 deletions
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java index 13aa04fd..9393e143 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java @@ -89,7 +89,7 @@ public class Cache<TRANS extends Trans, DATA> { public static Map<String,Dated> obtain(String key) { Map<String, Dated> m = cacheMap.get(key); - if(m==null) { + if (m==null) { m = new ConcurrentHashMap<>(); synchronized(cacheMap) { cacheMap.put(key, m); @@ -137,13 +137,13 @@ public class Cache<TRANS extends Trans, DATA> { Date now = new Date(System.currentTimeMillis() + advance); - for(String name : set) { + for (String name : set) { Map<String,Dated> map = cacheMap.get(name); - if(map==null) { + if (map==null) { continue; } - for(Map.Entry<String,Dated> me : map.entrySet()) { + for (Map.Entry<String,Dated> me : map.entrySet()) { ++total; if (me.getValue().timestamp.before(now)) { map.remove(me.getKey()); @@ -152,13 +152,13 @@ public class Cache<TRANS extends Trans, DATA> { } } - if(count>0) { + if (count>0) { env.info().log(Level.INFO, "Cache removed",count,"expired Cached Elements out of", total); } // If High (total) is reached during this period, increase the number of expired services removed for next time. // There's no point doing it again here, as there should have been cleaned items. - if(total>high) { + if (total>high) { // advance cleanup by 10%, without getting greater than timeInterval. advance = Math.min(timeInterval, advance+(timeInterval/10)); } else { @@ -169,20 +169,20 @@ public class Cache<TRANS extends Trans, DATA> { } public static synchronized void startCleansing(Env env, String ... keys) { - if(cleanseTimer==null) { + if (cleanseTimer==null) { cleanseTimer = new Timer("Cache Cleanup Timer"); int cleanInterval = Integer.parseInt(env.getProperty(CACHE_CLEAN_INTERVAL,"60000")); // 1 minute clean cycles int highCount = Integer.parseInt(env.getProperty(CACHE_HIGH_COUNT,"5000")); cleanseTimer.schedule(clean = new Clean(env, cleanInterval, highCount), cleanInterval, cleanInterval); } - for(String key : keys) { + for (String key : keys) { clean.add(key); } } public static void stopTimer() { - if(cleanseTimer!=null) { + if (cleanseTimer!=null) { cleanseTimer.cancel(); cleanseTimer = null; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java index 606e7735..7bc1fdc6 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java @@ -38,14 +38,14 @@ public class Define { private static final String ROOT_NS_TAG_DOT = ROOT_NS_TAG +"."; public static String ROOT_NS() { - if(ROOT_NS==null) { + if (ROOT_NS==null) { throw new RuntimeException(Define.class.getName() + MSG); } return ROOT_NS; } public static String ROOT_COMPANY() { - if(ROOT_NS==null) { + if (ROOT_NS==null) { throw new RuntimeException(Define.class.getName() + MSG); } return ROOT_COMPANY; @@ -54,17 +54,17 @@ public class Define { public static void set(Access access) throws CadiException { ROOT_NS = access.getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf"); ROOT_COMPANY = access.getProperty(Config.AAF_ROOT_COMPANY,null); - if(ROOT_COMPANY==null) { + if (ROOT_COMPANY==null) { int last = ROOT_NS.lastIndexOf('.'); - if(last>=0) { + if (last>=0) { ROOT_COMPANY = ROOT_NS.substring(0, last); } else { throw new CadiException(Config.AAF_ROOT_COMPANY + " or " + Config.AAF_ROOT_NS + " property with 3 positions is required."); } } - for( Entry<Object, Object> es : access.getProperties().entrySet()) { - if(es.getKey().toString().startsWith(ROOT_NS_TAG_DOT)) { + for ( Entry<Object, Object> es : access.getProperties().entrySet()) { + if (es.getKey().toString().startsWith(ROOT_NS_TAG_DOT)) { access.getProperties().setProperty(es.getKey().toString(),varReplace(es.getValue().toString())); } } @@ -74,7 +74,7 @@ public class Define { } public static String varReplace(final String potential) { - if(potential.startsWith(ROOT_NS_TAG_DOT)) { + if (potential.startsWith(ROOT_NS_TAG_DOT)) { return ROOT_NS + potential.substring(6); } else { return potential; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java index 70cee5c3..56db6f60 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java @@ -120,7 +120,7 @@ public class AuthzEnv extends RosettaEnv implements Access { public AuthzTransImpl newTrans() { synchronized(this) { times[idx]=System.currentTimeMillis(); - if(++idx>=times.length)idx=0; + if (++idx>=times.length)idx=0; } return new AuthzTransImpl(this); } @@ -137,18 +137,18 @@ public class AuthzEnv extends RosettaEnv implements Access { int count = 0; long pot = 0; long prev = 0; - for(int i=idx;i<times.length;++i) { - if(times[i]>0) { - if(prev>0) { + for (int i=idx;i<times.length;++i) { + if (times[i]>0) { + if (prev>0) { ++count; pot += times[i]-prev; } prev = times[i]; } } - for(int i=0;i<idx;++i) { - if(times[i]>0) { - if(prev>0) { + for (int i=0;i<idx;++i) { + if (times[i]>0) { + if (prev>0) { ++count; pot += times[i]-prev; } @@ -199,11 +199,11 @@ public class AuthzEnv extends RosettaEnv implements Access { private static final byte[] ENC="enc:".getBytes(); public String decrypt(String encrypted, final boolean anytext) throws IOException { - if(encrypted==null) { + if (encrypted==null) { throw new IOException("Password to be decrypted is null"); } - if(anytext || encrypted.startsWith("enc:")) { - if(decryptor.equals(Decryptor.NULL) && getProperty(Config.CADI_KEYFILE)!=null) { + if (anytext || encrypted.startsWith("enc:")) { + if (decryptor.equals(Decryptor.NULL) && getProperty(Config.CADI_KEYFILE)!=null) { final Symm s; try { s = Symm.obtain(this); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java index 06fd310e..b08e0240 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java @@ -54,10 +54,10 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { this.env = env; serviceMetric = new Metric(); serviceMetric.buckets = new float[BUCKETSIZE]; - if(transIDslot==null) { + if (transIDslot==null) { transIDslot = env.slot(TRANS_ID_SLOT); } - if(specialLogSlot==null) { + if (specialLogSlot==null) { specialLogSlot = env.slot(SPECIAL_LOG_SLOT); } } @@ -89,7 +89,7 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { Boolean b = trans.get(specialLogSlot, false); LogTarget lt = b?trans.warn():trans.info(); - if(lt.isLoggable()) { + if (lt.isLoggable()) { // Transaction is done, now post full Audit Trail StringBuilder sb = new StringBuilder("AuditTrail\n"); // We'll grabAct sub-metrics for Remote Calls and JSON @@ -98,12 +98,12 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { // Add current Metrics to total metrics serviceMetric.total+= m.total; - for(int i=0;i<serviceMetric.buckets.length;++i) { + for (int i=0;i<serviceMetric.buckets.length;++i) { serviceMetric.buckets[i]+=m.buckets[i]; } Long tsi; - if((tsi=trans.get(transIDslot, null))!=null) { + if ((tsi=trans.get(transIDslot, null))!=null) { sb.append(" TraceID="); sb.append(Long.toHexString(tsi)); sb.append('\n'); @@ -123,24 +123,24 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { Metric m = trans.auditTrail(lt,1, content, Env.REMOTE,Env.JSON); // Add current Metrics to total metrics serviceMetric.total+= m.total; - for(int i=0;i<serviceMetric.buckets.length;++i) { + for (int i=0;i<serviceMetric.buckets.length;++i) { serviceMetric.buckets[i]+=m.buckets[i]; } StringBuilder sb = new StringBuilder(); sb.append("user="); Principal p = trans.getUserPrincipal(); - if(p==null) { + if (p==null) { sb.append("n/a"); } else { sb.append(p.getName()); - if(p instanceof TrustPrincipal) { + if (p instanceof TrustPrincipal) { sb.append('('); sb.append(((TrustPrincipal)p).personalName()); // UserChain sb.append(')'); } else { sb.append('['); - if(p instanceof TaggedPrincipal) { + if (p instanceof TaggedPrincipal) { sb.append(((TaggedPrincipal)p).tag()); } else { sb.append(p.getClass().getSimpleName()); @@ -154,7 +154,7 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { sb.append(trans.port()); // Current code won't ever get here... Always does a Full Audit Trail // Long tsi; -// if((tsi=trans.get(transIDslot, null))!=null) { +// if ((tsi=trans.get(transIDslot, null))!=null) { // sb.append(",TraceID="); // sb.append(Long.toHexString(tsi)); // } @@ -165,10 +165,10 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { sb.append(",path="); sb.append(trans.path()); - if(content.length()>0) { + if (content.length()>0) { sb.append(",msg=\""); int start = content.lastIndexOf(",msg=\""); - if(start>=0) { + if (start>=0) { sb.append(content,start+6,content.length()-1); } else { sb.append(content); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java index ee90f284..aa6b038b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java @@ -60,12 +60,12 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { meth = req.getMethod(); path = req.getPathInfo(); - for(REQD_TYPE rt : REQD_TYPE.values()) { + for (REQD_TYPE rt : REQD_TYPE.values()) { requested(rt,req); } // Handle alternate "request" for "future" String request = req.getParameter("request"); - if(request!=null) { + if (request!=null) { requested(REQD_TYPE.future,(request.length()==0 || "true".equalsIgnoreCase(request))); } @@ -146,7 +146,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { } public void requested(REQD_TYPE requested, boolean b) { - if(b) { + if (b) { mask|=requested.bit; } else { mask&=~requested.bit; @@ -155,7 +155,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { private void requested(REQD_TYPE reqtype, HttpServletRequest req) { String p = req.getParameter(reqtype.name()); - if(p!=null) { + if (p!=null) { requested(reqtype,p.length()==0 || "true".equalsIgnoreCase(p)); } } @@ -167,7 +167,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { @Override public boolean fish(Permission ... pond) { - if(lur!=null) { + if (lur!=null) { return lur.fish(user, pond); } return false; @@ -178,9 +178,9 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public Organization org() { - if(org==null) { + if (org==null) { try { - if((org = OrganizationFactory.obtain(env(), user()))==null) { + if ((org = OrganizationFactory.obtain(env(), user()))==null) { org = Organization.NULL; } } catch (Exception e) { @@ -196,7 +196,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public void logAuditTrail(LogTarget lt) { - if(lt.isLoggable()) { + if (lt.isLoggable()) { StringBuilder sb = new StringBuilder(); auditTrail(1, sb); lt.log(sb); @@ -208,7 +208,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public Date now() { - if(now==null) { + if (now==null) { now = new Date(); } return now; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java index d7b6f1da..b1111638 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java @@ -70,7 +70,7 @@ public class AuthzTransOnlyFilter extends TransOnlyFilter<AuthzTrans> { Metric m = trans.auditTrail(1, sb, Env.REMOTE,Env.JSON); // Add current Metrics to total metrics serviceMetric.total+= m.total; - for(int i=0;i<serviceMetric.buckets.length;++i) { + for (int i=0;i<serviceMetric.buckets.length;++i) { serviceMetric.buckets[i]+=m.buckets[i]; } // Log current info diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java index 3b7ed6f0..d1c5d28c 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java @@ -225,7 +225,7 @@ public class NullTrans implements AuthzTrans { @Override public Date now() { - if(now==null) { + if (now==null) { now = new Date(); } return now; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java index 92a8269a..edb1f242 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java @@ -55,12 +55,12 @@ public class Result<RV> { protected Result(RV value, int status, String details, String[] variables) { this.value = value; - if(value==null) { + if (value==null) { specialCondition|=EMPTY_LIST; } this.status = status; this.details = details; - if(variables==null) { + if (variables==null) { this.variables = EMPTY_VARS; } else { this.variables=variables; @@ -290,17 +290,17 @@ public class Result<RV> { @Override public String toString() { - if(status==0) { + if (status==0) { return details; } else { StringBuilder sb = new StringBuilder(); sb.append(status); sb.append(':'); sb.append(String.format(details,((Object[])variables))); - if(isEmpty()) { + if (isEmpty()) { sb.append("{empty}"); } - if(value!=null) { + if (value!=null) { sb.append('-'); sb.append(value.toString()); } 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 90857b42..6f644bd4 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 @@ -74,14 +74,14 @@ public abstract class AbsData implements Iterable<String> { TimeTaken tt = trans.start("Open Data File", Env.SUB); boolean first = true; try { - if(!dataf.exists()) { + if (!dataf.exists()) { throw new FileNotFoundException("Data File Missing:" + dataf.getCanonicalPath()); } long begin = System.currentTimeMillis(); long end = begin+timeout; boolean exists; - while((exists=lockf.exists()) && begin<end) { - if(first) { + while ((exists=lockf.exists()) && begin<end) { + if (first) { trans.warn().log("Waiting for",lockf.getCanonicalPath(),"to close"); first = false; } @@ -92,7 +92,7 @@ public abstract class AbsData implements Iterable<String> { } begin = System.currentTimeMillis(); } - if(exists) { + if (exists) { throw new IOException(lockf.getCanonicalPath() + "exists. May not open Datafile"); } data.open(); @@ -110,12 +110,12 @@ public abstract class AbsData implements Iterable<String> { } private synchronized void ensureIdxGood(AuthzTrans trans) throws IOException { - if(!idxf.exists() || idxf.length()==0 || dataf.lastModified()>idxf.lastModified()) { + if (!idxf.exists() || idxf.length()==0 || dataf.lastModified()>idxf.lastModified()) { trans.warn().log(idxf.getAbsolutePath(),"is missing, empty or out of date, creating"); RandomAccessFile raf = new RandomAccessFile(lockf, "rw"); try { ti.create(trans, data, maxLineSize, delim, fieldOffset, skipLines); - if(!idxf.exists() || (idxf.length()==0 && dataf.length()!=0)) { + if (!idxf.exists() || (idxf.length()==0 && dataf.length()!=0)) { throw new IOException("Data Index File did not create correctly"); } } finally { @@ -189,7 +189,7 @@ public abstract class AbsData implements Iterable<String> { @Override public String next() { - if(!hasNext()) { + if (!hasNext()) { throw new NoSuchElementException(); } reuse.reset(); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java index 7e420df4..a65c13db 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java @@ -43,7 +43,7 @@ public class DataFile { this.access = access; } public void open() throws IOException { - if(!file.exists()) throw new FileNotFoundException(); + if (!file.exists()) throw new FileNotFoundException(); rafile = new RandomAccessFile(file,access); channel = rafile.getChannel(); mapBuff = channel.map("r".equals(access)?MapMode.READ_ONLY:MapMode.READ_WRITE,0,channel.size()); @@ -52,10 +52,10 @@ public class DataFile { return mapBuff!=null; } public void close() throws IOException { - if(channel!=null){ + if (channel!=null){ channel.close(); } - if(rafile!=null) { + if (rafile!=null) { rafile.close(); } mapBuff = null; @@ -67,7 +67,7 @@ public class DataFile { private synchronized int load(Token t) { int len = Math.min(mapBuff.limit()-t.next,t.buff.length); - if(len>0) { + if (len>0) { mapBuff.position(t.next); mapBuff.get(t.buff,0,len); } @@ -91,8 +91,8 @@ public class DataFile { public boolean nextLine() { end = load(this); pos = next; - for(int i=0;i<end;++i) { - if(buff[i]=='\n') { + for (int i=0;i<end;++i) { + if (buff[i]=='\n') { end = i; next += i+1; return true; @@ -126,16 +126,16 @@ public class DataFile { } public String next() { - if(idx>=end)return null; + if (idx>=end)return null; int start = idx; byte c=0; int endStr = -1; - while(idx<end && idx<buff.length && (c=buff[idx])!=delim && c!='\n') { // for DOS - if(c=='\r')endStr=idx; + while (idx<end && idx<buff.length && (c=buff[idx])!=delim && c!='\n') { // for DOS + if (c=='\r')endStr=idx; ++idx; } - if(endStr<0) { + if (endStr<0) { endStr=idx-start; } else { endStr=endStr-start; @@ -147,9 +147,9 @@ public class DataFile { public String at(int fieldOffset) { int start; byte c=0; - for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) { - if((c=buff[idx])==delim || c=='\n') { - if(count++ == fieldOffset) { + for (int count = idx = start = 0; idx<end && idx<buff.length; ++idx) { + if ((c=buff[idx])==delim || c=='\n') { + if (count++ == fieldOffset) { break; } start = idx+1; @@ -161,16 +161,16 @@ public class DataFile { public String atToEnd(int fieldOffset) { int start; byte c=0; - for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) { - if((c=buff[idx])==delim || c=='\n') { - if(count++ == fieldOffset) { + for (int count = idx = start = 0; idx<end && idx<buff.length; ++idx) { + if ((c=buff[idx])==delim || c=='\n') { + if (count++ == fieldOffset) { break; } start = idx+1; } } - for(; idx<end && idx<buff.length && (c=buff[idx])!='\n'; ++idx) { + for (; idx<end && idx<buff.length && (c=buff[idx])!='\n'; ++idx) { ++idx; } return new String(buff,start,(idx-start-((c=='\r' || idx>=end)?1:0))); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java index bb1b6117..73ad07c7 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java @@ -54,7 +54,7 @@ public class TextIndex { } public void close() throws IOException { - if(dataFile!=null) { + if (dataFile!=null) { dataFile.close(); dataFile=null; } @@ -65,7 +65,7 @@ public class TextIndex { } public int find(Object key, DataFile.Token dtok, Field df, int offset) throws IOException { - if(dataFile==null) { + if (dataFile==null) { throw new IOException("File not opened"); } long hash = hashToLong(key.hashCode()); @@ -74,13 +74,13 @@ public class TextIndex { IntBuffer tib = ttok.getIntBuffer(); long lhash; int curr; - while((max-min)>100) { + while ((max-min)>100) { ttok.pos((curr=(min+(max-min)/2))*REC_SIZE); tib.rewind(); lhash = hashToLong(tib.get()); - if(lhash<hash) { + if (lhash<hash) { min=curr+1; - } else if(lhash>hash) { + } else if (lhash>hash) { max=curr-1; } else { min=curr-40; @@ -90,20 +90,20 @@ public class TextIndex { } List<Integer> entries = new ArrayList<>(); - for(int i=min;i<=max;++i) { + for (int i=min;i<=max;++i) { ttok.pos(i*REC_SIZE); tib.rewind(); lhash = hashToLong(tib.get()); - if(lhash==hash) { + if (lhash==hash) { entries.add(tib.get()); - } else if(lhash>hash) { + } else if (lhash>hash) { break; } } - for(Integer i : entries) { + for (Integer i : entries) { dtok.pos(i); - if(df.at(offset).equals(key)) { + if (df.at(offset).equals(key)) { return i; } } @@ -116,7 +116,7 @@ public class TextIndex { */ private static long hashToLong(int hash) { long rv; - if(hash<0) { + if (hash<0) { rv = 0xFFFFFFFFL & hash; } else { rv = hash; @@ -145,15 +145,15 @@ public class TextIndex { Field f = t.new Field(delim); int count = 0; - if(skipLines>0) { + if (skipLines>0) { trans.info().log("Skipping",skipLines,"line"+(skipLines==1?" in":"s in"),data.file().getName()); } - for(int i=0;i<skipLines;++i) { + for (int i=0;i<skipLines;++i) { t.nextLine(); } tt2 = trans.start("Read", Env.SUB); try { - while(t.nextLine()) { + while (t.nextLine()) { list.add(new Idx(f.at(fieldOffset),t.pos())); ++count; } @@ -168,8 +168,8 @@ public class TextIndex { try { ByteBuffer bb = ByteBuffer.allocate(8*1024); IntBuffer ib = bb.asIntBuffer(); - for(Idx idx : list) { - if(!ib.hasRemaining()) { + for (Idx idx : list) { + if (!ib.hasRemaining()) { fos.write(bb); ib.clear(); bb.rewind(); @@ -186,7 +186,7 @@ public class TextIndex { fos.close(); } } finally { - if(raf!=null) { + if (raf!=null) { raf.close(); // closed by fos } } @@ -244,7 +244,7 @@ public class TextIndex { */ @Override public boolean equals(Object o) { - if(o!=null && o instanceof Idx) { + if (o!=null && o instanceof Idx) { return hash == ((Idx)o).hash; } return false; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java index 3ade1195..fd252fe4 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java @@ -161,8 +161,8 @@ public interface Organization { Notify(int id) {this.id = id;} public int getValue() {return id;} public static Notify from(int type) { - for(Notify t : Notify.values()) { - if(t.id==type) { + for (Notify t : Notify.values()) { + if (t.id==type) { return t; } } 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 3b97d6f3..80a382a8 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 @@ -53,39 +53,39 @@ public class OrganizationFactory { int idx = ORGANIZATION_DOT.length(); Organization org,firstOrg = null; - for(Entry<Object, Object> es : env.getProperties().entrySet()) { + for (Entry<Object, Object> es : env.getProperties().entrySet()) { String key = es.getKey().toString(); - if(key.startsWith(ORGANIZATION_DOT)) { + if (key.startsWith(ORGANIZATION_DOT)) { org = obtain(env,key.substring(idx)); - if(firstOrg==null) { + if (firstOrg==null) { firstOrg = org; } } } - if(defaultOrg == null) { + if (defaultOrg == null) { defaultOrg = firstOrg; } return defaultOrg; } public static Organization obtain(Env env,final String theNS) throws OrganizationException { String orgNS; - if(theNS.indexOf('@')>=0) { + if (theNS.indexOf('@')>=0) { orgNS=FQI.reverseDomain(theNS); } else { orgNS=theNS; } Organization org = orgs.get(orgNS); - if(org == null) { + if (org == null) { env.debug().printf("Attempting to instantiate Organization %s\n",orgNS); String orgClass = env.getProperty(ORGANIZATION_DOT+orgNS); - if(orgClass == null) { + if (orgClass == null) { env.warn().log("There is no Organization." + orgNS + " property"); } else { try { Class<?> orgCls = Class.forName(orgClass); - for(Organization o : orgs.values()) { - if(o.getClass().isAssignableFrom(orgCls)) { + for (Organization o : orgs.values()) { + if (o.getClass().isAssignableFrom(orgCls)) { org = o; } } @@ -93,15 +93,15 @@ public class OrganizationFactory { env.error().log(e1, orgClass + " is not on the Classpath."); throw new OrganizationException(e1); } - if(org==null) { + if (org==null) { try { @SuppressWarnings("unchecked") Class<Organization> cls = (Class<Organization>) Class.forName(orgClass); Constructor<Organization> cnst = cls.getConstructor(Env.class,String.class); org = cnst.newInstance(env,orgNS); String other_realms = env.getProperty(orgNS+".also_supports"); - if(other_realms!=null) { - for(String r : Split.splitTrim(',', other_realms)) { + if (other_realms!=null) { + for (String r : Split.splitTrim(',', other_realms)) { org.addSupportedRealm(r); } } @@ -114,13 +114,13 @@ public class OrganizationFactory { } orgs.put(orgNS, org); boolean isDefault; - if((isDefault="true".equalsIgnoreCase(env.getProperty(orgNS+".default")))) { + if ((isDefault="true".equalsIgnoreCase(env.getProperty(orgNS+".default")))) { defaultOrg = org; } env.init().printf("Instantiated %s with %s%s\n",orgNS,orgClass,(isDefault?" as default":"")); } - if(org==null) { - if(defaultOrg!=null) { + if (org==null) { + if (defaultOrg!=null) { org=defaultOrg; orgs.put(orgNS, org); } @@ -133,7 +133,7 @@ public class OrganizationFactory { public static Organization get(AuthzTrans trans) throws OrganizationException { String domain = FQI.reverseDomain(trans.user()); Organization org = orgs.get(domain); - if(org==null) { + if (org==null) { org = defaultOrg; // can be null, btw, unless set. } return org; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java index 30924dd5..0e70e25e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java @@ -46,16 +46,16 @@ class Acceptor<TRANS extends Trans> { private boolean eval(HttpCode<TRANS,?> code, String str, List<String> props) { // int plus = str.indexOf('+'); -// if(plus<0) { +// if (plus<0) { boolean ok = false; boolean any = false; - for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) { + for (Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) { ok = true; - if(type.x.equals(str)) { - for(Iterator<String> iter = props.iterator();ok && iter.hasNext();) { + if (type.x.equals(str)) { + for (Iterator<String> iter = props.iterator();ok && iter.hasNext();) { ok = props(type,iter.next(),iter.next()); } - if(ok) { + if (ok) { any = true; acceptable.add(type); } @@ -65,11 +65,11 @@ class Acceptor<TRANS extends Trans> { // int prev = str.indexOf('/')+1; // String first = str.substring(0,prev); // String nstr; -// while(prev!=0) { +// while (prev!=0) { // nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus)); // -// for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) { -// if(type.x.equals(nstr)) { +// for (Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) { +// if (type.x.equals(nstr)) { // acceptable.add(type); // return type; // } @@ -90,14 +90,14 @@ class Acceptor<TRANS extends Trans> { */ private boolean props(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type, String tag, String value) { boolean rv = false; - if(type.y!=null) { - for(Pair<String,Object> prop : type.y.y){ - if(tag.equals(prop.x)) { - if(tag.equals("charset")) { + if (type.y!=null) { + for (Pair<String,Object> prop : type.y.y){ + if (tag.equals(prop.x)) { + if (tag.equals("charset")) { return prop.x==null?false:prop.y.equals(value.toLowerCase()); // return True if Matched - } else if(tag.equals("version")) { + } else if (tag.equals("version")) { return prop.y.equals(new Version(value)); // Note: Version Class knows Minor Version encoding - } else if(tag.equals(Content.Q)) { // replace Q value + } else if (tag.equals(Content.Q)) { // replace Q value try { type.y.y.get(0).y=Float.parseFloat(value); } catch (NumberFormatException e) { @@ -135,34 +135,34 @@ class Acceptor<TRANS extends Trans> { name=null; cis = cie+1; // find comma start - while(cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis; + while (cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis; cie = cntnt.indexOf(',',cis); // find comma end cend = cie<0?bytes.length:cie; // If no comma, set comma end to full length, else cie - while(cend>cis && Character.isSpaceChar(bytes[cend-1]))--cend; + while (cend>cis && Character.isSpaceChar(bytes[cend-1]))--cend; // Start SEMIS sie=cis-1; do { sis = sie+1; // semi start is one after previous end - while(sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis; + while (sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis; sie = cntnt.indexOf(';',sis); send = sie>cend || sie<0?cend:sie; // if the Semicolon is after the comma, or non-existent, use comma end, else keep - while(send>sis && Character.isSpaceChar(bytes[send-1]))--send; - if(name==null) { // first entry in Comma set is the name, not a property + while (send>sis && Character.isSpaceChar(bytes[send-1]))--send; + if (name==null) { // first entry in Comma set is the name, not a property name = new String(bytes,sis,send-sis); } else { // We've looped past the first Semi, now process as properties // If there are additional elements (more entities within Semi Colons) // apply Properties int eq = cntnt.indexOf('=',sis); - if(eq>sis && eq<send) { + if (eq>sis && eq<send) { props.add(new String(bytes,sis,eq-sis)); props.add(new String(bytes,eq+1,send-(eq+1))); } } // End Property - } while(sie<=cend && sie>=cis); // End SEMI processing + } while (sie<=cend && sie>=cis); // End SEMI processing // Now evaluate Comma set and return if true - if(eval(code,name,props))return true; // else loop again to check next comma - } while(cie>=0); // loop to next comma + if (eval(code,name,props))return true; // else loop again to check next comma + } while (cie>=0); // loop to next comma return false; // didn't get even one match } 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 53511b40..9af11152 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 @@ -66,12 +66,12 @@ import org.onap.aaf.misc.env.Trans; */ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void> { public static void setEnv(Store store, String[] args) { - for(int i=0;i<args.length-1;i+=2) { // cover two parms required for each - if(CFA_WEB_PATH.equals(args[i])) { + for (int i=0;i<args.length-1;i+=2) { // cover two parms required for each + if (CFA_WEB_PATH.equals(args[i])) { store.put(store.staticSlot(CFA_WEB_PATH), args[i+1]); - } else if(CFA_CACHE_CHECK_INTERVAL.equals(args[i])) { + } else if (CFA_CACHE_CHECK_INTERVAL.equals(args[i])) { store.put(store.staticSlot(CFA_CACHE_CHECK_INTERVAL), Long.parseLong(args[i+1])); - } else if(CFA_MAX_SIZE.equals(args[i])) { + } else if (CFA_MAX_SIZE.equals(args[i])) { store.put(store.staticSlot(CFA_MAX_SIZE), Integer.parseInt(args[i+1])); } } @@ -144,11 +144,11 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void env.init().log("CachingFileAccess path: " + new File(web_path).getCanonicalPath()); Object obj; obj = env.get(env.staticSlot(CFA_CACHE_CHECK_INTERVAL),600000L); // Default is 10 mins - if(obj instanceof Long) {checkInterval=(Long)obj; + if (obj instanceof Long) {checkInterval=(Long)obj; } else {checkInterval=Long.parseLong((String)obj);} obj = env.get(env.staticSlot(CFA_MAX_SIZE), 512000); // Default is max file 500k - if(obj instanceof Integer) {maxItemSize=(Integer)obj; + if (obj instanceof Integer) {maxItemSize=(Integer)obj; } else {maxItemSize =Integer.parseInt((String)obj);} clear_command = env.getProperty(CFA_CLEAR_COMMAND,null); @@ -160,9 +160,9 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException { String key = pathParam(req, ":key"); String cmd = pathParam(req,":cmd"); - if(key.equals(clear_command)) { + if (key.equals(clear_command)) { resp.setHeader("Content-Type",typeMap.get("txt")); - if("clear".equals(cmd)) { + if ("clear".equals(cmd)) { content.clear(); resp.setStatus(200/*HttpStatus.OK_200*/); } else { @@ -171,7 +171,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void return; } Content c = load(logT , web_path,cmd!=null && cmd.length()>0?key+'/'+cmd:key, null, checkInterval); - if(c.attachmentOnly) { + if (c.attachmentOnly) { resp.setHeader("Content-disposition", "attachment"); } c.setHeader(resp); @@ -214,12 +214,12 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void */ public Content load(LogTarget logTarget, String dataRoot, String key, String mediaType, long _timeCheck) throws IOException { long timeCheck = _timeCheck; - if(timeCheck<0) { + if (timeCheck<0) { timeCheck=checkInterval; // if time < 0, then use default } boolean isRoot; String fileName; - if("-".equals(key)) { + if ("-".equals(key)) { fileName = dataRoot; isRoot = true; } else { @@ -229,30 +229,30 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void Content c = content.get(key); long systime = System.currentTimeMillis(); File f=null; - if(c!=null) { + if (c!=null) { // Don't check every hit... only after certain time value - if(c.date < systime + timeCheck) { + if (c.date < systime + timeCheck) { f = new File(fileName); - if(f.lastModified()>c.date) { + if (f.lastModified()>c.date) { c=null; } } } - if(c==null) { - if(logTarget!=null) { + if (c==null) { + if (logTarget!=null) { logTarget.log("File Read: ",key); } - if(f==null){ + if (f==null){ f = new File(fileName); } boolean cacheMe; - if(f.exists()) { - if(f.isDirectory()) { + if (f.exists()) { + if (f.isDirectory()) { cacheMe = false; c = new DirectoryContent(f,isRoot); } else { - if(f.length() > maxItemSize) { + if (f.length() > maxItemSize) { c = new DirectFileContent(f); cacheMe = false; } else { @@ -260,10 +260,10 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void cacheMe = checkInterval>0; } - if(mediaType==null) { // determine from file Ending + if (mediaType==null) { // determine from file Ending int idx = key.lastIndexOf('.'); String subkey = key.substring(++idx); - if((c.contentType = idx<0?null:typeMap.get(subkey))==null) { + if ((c.contentType = idx<0?null:typeMap.get(subkey))==null) { // if nothing else, just set to default type... c.contentType = "application/octet-stream"; } @@ -275,7 +275,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void c.date = f.lastModified(); - if(cacheMe) { + if (cacheMe) { content.put(key, c); } } @@ -283,7 +283,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void c=NULL; } } else { - if(logTarget!=null)logTarget.log("Cache Read: ",key); + if (logTarget!=null)logTarget.log("Cache Read: ",key); } // refresh hit time @@ -294,7 +294,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public Content loadOrDefault(Trans trans, String targetDir, String targetFileName, String sourcePath, String mediaType) throws IOException { try { return load(trans.info(),targetDir,targetFileName,mediaType,0); - } catch(FileNotFoundException e) { + } catch (FileNotFoundException e) { String targetPath = targetDir + '/' + targetFileName; TimeTaken tt = trans.start("File doesn't exist; copy " + sourcePath + " to " + targetPath, Env.SUB); try { @@ -374,7 +374,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void char[] buff = new char[1024]; try { int read; - while((read = fr.read(buff,0,1024))>=0) { + while ((read = fr.read(buff,0,1024))>=0) { writer.write(buff,0,read); } } finally { @@ -387,7 +387,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void byte[] buff = new byte[1024]; try { int read; - while((read = fis.read(buff,0,1024))>=0) { + while ((read = fis.read(buff,0,1024))>=0) { os.write(buff,0,read); } } finally { @@ -415,13 +415,13 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void // See if there are Numbers in the name Matcher m1 = A_NUMBER.matcher(f1.getName()); Matcher m2 = A_NUMBER.matcher(f2.getName()); - if(m1.find() && m2.find()) { + if (m1.find() && m2.find()) { // if numbers, are the numbers in the same start position int i1 = m1.start(); int i2 = m2.start(); // If same start position and the text is the same, then reverse sort - if(i1==i2 && f1.getName().startsWith(f2.getName().substring(0,i1))) { + if (i1==i2 && f1.getName().startsWith(f2.getName().substring(0,i1))) { // reverse sort files that start similarly, but have numbers in them return f2.compareTo(f1); } @@ -443,7 +443,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void w.append(H2); for (File f : files) { w.append("<li><a href=\""); - if(notRoot) { + if (notRoot) { w.append(name); w.append('/'); } @@ -490,7 +490,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public void write(Writer writer) throws IOException { synchronized(this) { // do the String Transformation once, and only if actually used - if(cdata==null) { + if (cdata==null) { cdata = new char[end]; new String(data).getChars(0, end, cdata, 0); } @@ -538,21 +538,21 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void @Override public void run() { int size = content.size(); - if(size>maxSize) { + if (size>maxSize) { ArrayList<Comp> scont = new ArrayList<>(size); Object[] entries = content.entrySet().toArray(); - for(int i=0;i<size;++i) { + for (int i=0;i<size;++i) { scont.add(i, new Comp((Map.Entry<String,Content>)entries[i])); } Collections.sort(scont); int end = size - ((maxSize/4)*3); // reduce to 3/4 of max size //System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------"); - for(int i=0;i<end;++i) { + for (int i=0;i<end;++i) { Entry<String, Content> entry = scont.get(i).entry; content.remove(entry.getKey()); //System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); } -// for(int i=end;i<size;++i) { +// for (int i=end;i<size;++i) { // Entry<String, Content> entry = scont.get(i).entry; // //System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); // } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java index f8760ada..63a2eeaa 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java @@ -80,13 +80,13 @@ public abstract class Content<TRANS extends Trans> { sis = sie+1; sie = cntnt.indexOf(';',sis); send = sie>cend || sie<0?cend:sie; - if(me==null) { + if (me==null) { String semi = new String(bytes,sis,send-sis); // trans.checkpoint(semi); // Look at first entity within comma group // Is this an acceptable Type? me=types(code, semi); - if(me==null) { + if (me==null) { sie=-1; // skip the rest of the processing... not a type } else { contType=true; @@ -95,20 +95,20 @@ public abstract class Content<TRANS extends Trans> { // If there are additional elements (more entities within Semi Colons) // apply Propertys int eq = cntnt.indexOf('=',sis); - if(eq>sis && eq<send) { + if (eq>sis && eq<send) { String tag = new String(bytes,sis,eq-sis); String value = new String(bytes,eq+1,send-(eq+1)); // trans.checkpoint(" Prop " + tag + "=" + value); boolean bool = props(me,tag,value); - if(!bool) { + if (!bool) { contProp=false; } } } // End Property - } while(sie<=cend && sie>=cis); + } while (sie<=cend && sie>=cis); // End SEMIS - } while(cie>=0); + } while (cie>=0); return contType && contProp; // for use in finds, True if a type found AND all props matched } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java index c5739e35..0768145f 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java @@ -55,8 +55,8 @@ public abstract class HttpCode<TRANS extends Trans, CONTEXT> { // Evaluate for "*" once... all = false; - for(String srole : roles) { - if("*".equals(srole)) { + for (String srole : roles) { + if ("*".equals(srole)) { all = true; break; } @@ -79,11 +79,11 @@ public abstract class HttpCode<TRANS extends Trans, CONTEXT> { */ public String pathParam(HttpServletRequest req, String key) { String rv = req.getParameter(key); - if(rv==null) { + if (rv==null) { rv = match.param(req.getPathInfo(), key); - if(rv!=null) { + if (rv!=null) { rv = rv.trim(); - if(rv.endsWith("/")) { + if (rv.endsWith("/")) { rv = rv.substring(0, rv.length()-1); } } @@ -102,10 +102,10 @@ public abstract class HttpCode<TRANS extends Trans, CONTEXT> { * @return */ public boolean isAuthorized(HttpServletRequest req) { - if(all)return true; - if(roles!=null) { - for(String srole : roles) { - if(req.isUserInRole(srole)) return true; + if (all)return true; + if (roles!=null) { + for (String srole : roles) { + if (req.isUserInRole(srole)) return true; } } return false; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java index 5a036551..599e45b2 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java @@ -52,16 +52,16 @@ public class Match { public Match(String path) { // IF DEBUG: System.out.print("\n[" + path + "]"); params = new HashMap<>(); - if(path!=null) { + if (path!=null) { String[] pa = path.split("/"); values = new byte[pa.length][]; vars = new Integer[pa.length]; int val = 0; String key; - for(int i=0;i<pa.length && !wildcard;++i) { - if(pa[i].startsWith(":")) { - if(pa[i].endsWith("*")) { + for (int i=0;i<pa.length && !wildcard;++i) { + if (pa[i].startsWith(":")) { + if (pa[i].endsWith("*")) { val = i | pa.length<<16; // load end value in high order bits key = pa[i].substring(0, pa[i].length()-1);// remove * wildcard = true; @@ -75,9 +75,9 @@ public class Match { vars[i]=val; } else { values[i]=pa[i].getBytes(); - if(pa[i].endsWith("*")) { + if (pa[i].endsWith("*")) { wildcard = true; - if(pa[i].length()>1) { + if (pa[i].length()>1) { /* remove * from value */ int newlength = values[i].length-1; byte[] real = new byte[newlength]; @@ -107,25 +107,25 @@ public class Match { */ public String param(String path,String key) { Integer val = params.get(key); // :key or key - if(val!=null) { + if (val!=null) { int start = val & 0xFFFF; int end = (val >> 16) & 0xFFFF; int idx = -1; int i; - for(i=0;i<start;++i) { + for (i=0;i<start;++i) { idx = path.indexOf('/',idx+1); - if(idx<0)break; + if (idx<0)break; } - if(i==start) { + if (i==start) { ++idx; - if(end==0) { + if (end==0) { end = path.indexOf('/',idx); - if(end<0)end=path.length(); + if (end<0)end=path.length(); } else { end=path.length(); } return path.substring(idx,end); - } else if(i==start-1) { // if last spot was left blank, i.e. :key* + } else if (i==start-1) { // if last spot was left blank, i.e. :key* return ""; } } @@ -133,8 +133,8 @@ public class Match { } public boolean match(String path) { - if(path==null|| path.length()==0 || "/".equals(path) ) { - if(values==null)return true; + if (path==null|| path.length()==0 || "/".equals(path) ) { + if (values==null)return true; switch(values.length) { case 0: return true; case 1: return values[0].length==0; @@ -150,58 +150,58 @@ public class Match { int lastByte = pabytes.length; boolean fieldMatched = false; // = lastByte>0?(pabytes[0]=='/'):false; // IF DEBUG: System.out.println("\n -- " + path + " --"); - for(int i=0;rv && i<lastByte;++i) { - if(field>=lastField) { // checking here allows there to be a non-functional ending / + for (int i=0;rv && i<lastByte;++i) { + if (field>=lastField) { // checking here allows there to be a non-functional ending / rv = false; break; } - if(values[field]==null) { // it's a variable, just look for /s - if(wildcard && field==lastField-1) return true;// we've made it this far. We accept all remaining characters + if (values[field]==null) { // it's a variable, just look for /s + if (wildcard && field==lastField-1) return true;// we've made it this far. We accept all remaining characters Integer val = vars[field]; int start = val & 0xFFFF; int end = (val >> 16) & 0xFFFF; - if(end==0)end=start+1; + if (end==0)end=start+1; int k = i; - for(int j=start; j<end && k<lastByte; ++k) { + for (int j=start; j<end && k<lastByte; ++k) { // IF DEBUG: System.out.print((char)pabytes[k]); - if(pabytes[k]=='/') { + if (pabytes[k]=='/') { ++field; ++j; } } - if(k==lastByte && pabytes[k-1]!='/')++field; - if(k>i)i=k-1; // if we've incremented, have to accommodate the outer for loop incrementing as well + if (k==lastByte && pabytes[k-1]!='/')++field; + if (k>i)i=k-1; // if we've incremented, have to accommodate the outer for loop incrementing as well fieldMatched = false; // reset fieldIdx = 0; } else { // IF DEBUG: System.out.print((char)pabytes[i]); - if(pabytes[i]=='/') { // end of field, eval if Field is matched + if (pabytes[i]=='/') { // end of field, eval if Field is matched // if double slash, check if supposed to be empty - if(fieldIdx==0 && values[field].length==0) { + if (fieldIdx==0 && values[field].length==0) { fieldMatched = true; } rv = fieldMatched && ++field<lastField; // reset fieldMatched = false; fieldIdx = 0; - } else if(values[field].length==0) { + } else if (values[field].length==0) { // double slash in path, but content in field. We check specially here to avoid // Array out of bounds issues. rv = false; } else { - if(fieldMatched) { + if (fieldMatched) { rv =false; // field is already matched, now there's too many bytes } else { rv = pabytes[i]==values[field][fieldIdx++]; // compare expected (pabytes[i]) with value for particular field fieldMatched=values[field].length==fieldIdx; // are all the bytes match in the field? - if(fieldMatched && (i==lastByte-1 || (wildcard && field==lastField-1))) + if (fieldMatched && (i==lastByte-1 || (wildcard && field==lastField-1))) return true; // last field info } } } } - if(field!=lastField || pabytes.length!=lastByte) rv = false; // have we matched all the fields and all the bytes? + if (field!=lastField || pabytes.length!=lastByte) rv = false; // have we matched all the fields and all the bytes? return rv; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java index 03264d56..c1bfd6ad 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java @@ -64,7 +64,7 @@ public abstract class RServlet<TRANS extends Trans> implements Servlet { @SuppressWarnings("unchecked") TRANS trans = (TRANS)req.getAttribute(TransFilter.TRANS_TAG); - if(trans==null) { + if (trans==null) { response.setStatus(404); // Not Found, because it didn't go through TransFilter return; } @@ -79,7 +79,7 @@ public abstract class RServlet<TRANS extends Trans> implements Servlet { CodeSetter<TRANS> codesetter = new CodeSetter<TRANS>(trans,request,response); // Find declared route route = routes.derive(request, codesetter); - if(route==null) { + if (route==null) { String method = request.getMethod(); trans.checkpoint("No Route matches "+ method + ' ' + request.getPathInfo()); response.setStatus(404); // Not Found @@ -91,12 +91,12 @@ public abstract class RServlet<TRANS extends Trans> implements Servlet { tt.done(); } - if(route!=null && code!=null) { + if (route!=null && code!=null) { StringBuilder sb = new StringBuilder(72); sb.append(route.auditText); sb.append(','); sb.append(code.desc()); - if(ct!=null) { + if (ct!=null) { sb.append(", ContentType: "); sb.append(ct); } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java index 81b3d0a2..b11916ef 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java @@ -67,18 +67,18 @@ public class Route<TRANS extends Trans> { // FYI, thought about this a long time before implementing this way. String compare; // String special[]; // todo, expose Charset (in special) to outside - if(isGet) { + if (isGet) { compare = req.getHeader("Accept"); // Accept is used for read, as we want to agree on what caller is ready to handle } else { compare = req.getContentType(); // Content type used to declare what data is being created, updated or deleted (might be used for key) } Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> hl = content.prep(trans, compare); - if(hl==null) { + if (hl==null) { resp.setStatus(406); // NOT_ACCEPTABLE } else { - if(isGet) { // Set Content Type to expected content - if("*".equals(hl.x) || "*/*".equals(hl.x)) {// if wild-card, then choose first kind of type + if (isGet) { // Set Content Type to expected content + if ("*".equals(hl.x) || "*/*".equals(hl.x)) {// if wild-card, then choose first kind of type resp.setContentType(content.first()); } else { resp.setContentType(hl.x); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java index 7c69d9b7..de42e26b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java @@ -47,12 +47,12 @@ public class Routes<TRANS extends Trans> { // Package on purpose synchronized Route<TRANS> findOrCreate(HttpMethods meth, String path) { Route<TRANS> rv = null; - for(int i=0;i<end;++i) { - if(routes[i].resolvesTo(meth,path))rv = routes[i]; + for (int i=0;i<end;++i) { + if (routes[i].resolvesTo(meth,path))rv = routes[i]; } - if(rv==null) { - if(end>=routes.length) { + if (rv==null) { + if (end>=routes.length) { @SuppressWarnings("unchecked") Route<TRANS>[] temp = new Route[end+10]; System.arraycopy(routes, 0, temp, 0, routes.length); @@ -69,9 +69,9 @@ public class Routes<TRANS extends Trans> { String path = req.getPathInfo(); String meth = req.getMethod(); //TODO a TREE would be better - for(int i=0;rv==null && i<end; ++i) { + for (int i=0;rv==null && i<end; ++i) { rv = routes[i].matches(meth,path); - if(rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code + if (rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code rv = null; // not quite, keep going } } @@ -81,7 +81,7 @@ public class Routes<TRANS extends Trans> { public List<RouteReport> routeReport() { ArrayList<RouteReport> ltr = new ArrayList<>(); - for(int i=0;i<end;++i) { + for (int i=0;i<end;++i) { ltr.add(routes[i].api()); } return ltr; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java index b36fd234..85b35ac7 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java @@ -70,7 +70,7 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { public TransFilter(Access access, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException, LocatorException { cadi = new CadiHTTPManip(access, con, tc, additionalTafLurs); String no = access.getProperty(Config.CADI_NOAUTHN, null); - if(no!=null) { + if (no!=null) { no_authn = Split.split(':', no); } else { no_authn=null; @@ -101,9 +101,9 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { try { request.setAttribute(TRANS_TAG, trans); - if(no_authn!=null) { - for(String prefix : no_authn) { - if(req.getPathInfo().startsWith(prefix)) { + if (no_authn!=null) { + for (String prefix : no_authn) { + if (req.getPathInfo().startsWith(prefix)) { chain.doFilter(request, response); return; } @@ -128,9 +128,9 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { security.done(); } - if(r==RESP.IS_AUTHENTICATED) { + if (r==RESP.IS_AUTHENTICATED) { trans.checkpoint(resp.desc()); - if(cadi.notCadi(cw, res)) { + if (cadi.notCadi(cw, res)) { chain.doFilter(cw, response); } } else { @@ -138,10 +138,10 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { // Would need Cached Counter objects that are cleaned up on // use trans.checkpoint(resp.desc(),Env.ALWAYS); - if(resp.isFailedAttempt()) + if (resp.isFailedAttempt()) trans.audit().log(resp.desc()); } - } catch(Exception e) { + } catch (Exception e) { trans.error().log(e); trans.checkpoint("Error: " + e.getClass().getSimpleName() + ": " + e.getMessage()); throw new ServletException(e); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java index 8c57838d..1a66cf7d 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java @@ -72,8 +72,8 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { public TypedCode<TRANS> add(HttpCode<TRANS,?> code, String ... others) { StringBuilder sb = new StringBuilder(); boolean first = true; - for(String str : others) { - if(first) { + for (String str : others) { + if (first) { first = false; } else { sb.append(','); @@ -94,7 +94,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>> cl = new Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>>(code, props); // // breakup "plus" stuff, i.e. application/xaml+xml // int plus = str.indexOf('+'); -// if(plus<0) { +// if (plus<0) { type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(str, cl); types.add(type); return type; @@ -102,7 +102,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { // int prev = str.indexOf('/')+1; // String first = str.substring(0,prev); // String nstr; -// while(prev!=0) { +// while (prev!=0) { // nstr = first + (plus>-1?str.substring(prev,plus):str.substring(prev)); // type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(nstr, cl); // types.add(type); @@ -115,7 +115,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { @Override protected boolean props(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type, String tag, String value) { - if(tag.equals(Q)) { // reset the Q value (first in array) + if (tag.equals(Q)) { // reset the Q value (first in array) boolean rv = true; try { type.y.y.get(0).y=Float.parseFloat(value); @@ -130,10 +130,10 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { public Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> prep(TRANS trans, String compare) throws IOException, ServletException { Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> c,rv=null; - if(types.size()==1 && "".equals((c=types.get(0)).x)) { // if there are no checks for type, skip + if (types.size()==1 && "".equals((c=types.get(0)).x)) { // if there are no checks for type, skip rv = c; } else { - if(compare==null || compare.length()==0) { + if (compare==null || compare.length()==0) { rv = types.get(0); // first code is used } else { Acceptor<TRANS> acc = new Acceptor<TRANS>(types); @@ -144,7 +144,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } finally { tt.done(); } - if(accepted) { + if (accepted) { switch(acc.acceptable.size()) { case 0: // // TODO best Status Code? @@ -156,16 +156,16 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { default: // compare Q values to get Best Match float bestQ = -1.0f; Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> bestT = null; - for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : acc.acceptable) { + for (Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : acc.acceptable) { Float f = (Float)type.y.y.get(0).y; // first property is always Q - if(f>bestQ) { + if (f>bestQ) { bestQ=f; bestT = type; } } - if(bestT!=null) { + if (bestT!=null) { // When it is a GET, the matched type is what is returned, so set ContentType -// if(isGet)resp.setContentType(bestT.x); // set ContentType of Code<TRANS,?> +// if (isGet)resp.setContentType(bestT.x); // set ContentType of Code<TRANS,?> // rv = bestT.y.x; rv = bestT; } @@ -190,17 +190,17 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { */ public StringBuilder relatedTo(HttpCode<TRANS, ?> code, StringBuilder sb) { boolean first = true; - for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) { - if(code==null || pair.y.x == code) { - if(first) { + for (Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) { + if (code==null || pair.y.x == code) { + if (first) { first = false; } else { sb.append(','); } sb.append(pair.x); - for(Pair<String,Object> prop : pair.y.y) { + for (Pair<String,Object> prop : pair.y.y) { // Don't print "Q". it's there for internal use, but it is only meaningful for "Accepts" - if(!prop.x.equals(Q) || !prop.y.equals(1f) ) { + if (!prop.x.equals(Q) || !prop.y.equals(1f) ) { sb.append(';'); sb.append(prop.x); sb.append('='); @@ -213,8 +213,8 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } public List<Pair<String, Object>> getContent(HttpCode<TRANS,?> code) { - for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) { - if(pair.y.x == code) { + for (Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) { + if (pair.y.x == code) { return pair.y.y; } } @@ -232,11 +232,11 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { tr.desc = null; // Read through Code/TypeCode trees for all accepted Typecodes - for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> tc : types) { + for (Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> tc : types) { // If new, then it's new Code set, create prefix content - if((temp=psb.get(tc.y.x))==null) { + if ((temp=psb.get(tc.y.x))==null) { psb.put(tc.y.x,temp=new StringBuilder()); - if(tr.desc==null) { + if (tr.desc==null) { tr.desc = tc.y.x.desc(); } } else { @@ -245,7 +245,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { temp.append(tc.x); // add all properties - for(Pair<String, Object> props : tc.y.y) { + for (Pair<String, Object> props : tc.y.y) { temp.append(';'); temp.append(props.x); temp.append('='); @@ -254,13 +254,13 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } // Gather all ContentType possibilities for the same code together - for(StringBuilder sb : psb.values()) { + for (StringBuilder sb : psb.values()) { tr.contextTypes.add(sb.toString()); } } public String first() { - if(types.size()>0) { + if (types.size()>0) { return types.get(0).x; } return null; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java index f4818579..adf05380 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java @@ -35,7 +35,7 @@ public class Version { String sparts[] = v.split("\\."); parts = new Object[sparts.length]; System.arraycopy(sparts, 0, parts, 0, sparts.length); - if(parts.length>1) { // has at least a minor + if (parts.length>1) { // has at least a minor try { parts[1]=Integer.decode(sparts[1]); // minor elements need to be converted to Integer for comparison } catch (NumberFormatException e) { @@ -46,20 +46,20 @@ public class Version { } public boolean equals(Object obj) { - if(obj instanceof Version) { + if (obj instanceof Version) { Version ver = (Version)obj; int length = Math.min(parts.length, ver.parts.length); - for(int i=0;i<length;++i) { // match on declared parts - if(i==1) { - if(parts[1] instanceof Integer && ver.parts[1] instanceof Integer) { + for (int i=0;i<length;++i) { // match on declared parts + if (i==1) { + if (parts[1] instanceof Integer && ver.parts[1] instanceof Integer) { // Match on Minor version if this Version is less than Version to be checked - if(((Integer)parts[1])<((Integer)ver.parts[1])) { + if (((Integer)parts[1])<((Integer)ver.parts[1])) { return false; } continue; // don't match next line } } - if(!parts[i].equals(ver.parts[i])) { + if (!parts[i].equals(ver.parts[i])) { return false; // other spots exact match } } @@ -80,8 +80,8 @@ public class Version { public String toString() { StringBuilder sb = new StringBuilder(); boolean first = true; - for(Object obj : parts) { - if(first) { + for (Object obj : parts) { + if (first) { first = false; } else { sb.append('.'); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java index 497860af..f2495440 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java @@ -65,17 +65,17 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte String component = access.getProperty(Config.AAF_COMPONENT, null); final String[] locator_deploy; - if(component == null) { + if (component == null) { locator_deploy = null; } else { locator_deploy = Split.splitTrim(':', component); } - if(component == null || locator_deploy==null || locator_deploy.length<2) { + if (component == null || locator_deploy==null || locator_deploy.length<2) { throw new CadiException("AAF Component must include the " + Config.AAF_COMPONENT + " property, <fully qualified service name>:<full deployed version (i.e. 2.1.3.13)"); } final String[] version = Split.splitTrim('.', locator_deploy[1]); - if(version==null || version.length<2) { + if (version==null || version.length<2) { throw new CadiException("AAF Component Version must have at least Major.Minor version"); } app_name = Define.varReplace(locator_deploy[0]); @@ -83,7 +83,7 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte app_interface_version = version[0]+'.'+version[1]; // Print Cipher Suites Available - if(access.willLog(Level.DEBUG)) { + if (access.willLog(Level.DEBUG)) { SSLContext context; try { context = SSLContext.getDefault(); @@ -94,11 +94,11 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte StringBuilder sb = new StringBuilder("Available Cipher Suites: "); boolean first = true; int count=0; - for( String cs : sf.getSupportedCipherSuites()) { - if(first)first = false; + for ( String cs : sf.getSupportedCipherSuites()) { + if (first)first = false; else sb.append(','); sb.append(cs); - if(++count%4==0){sb.append('\n');} + if (++count%4==0){sb.append('\n');} } access.log(Level.DEBUG,sb); } @@ -121,8 +121,8 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte // Lazy Instantiation public synchronized AAFConHttp aafCon() throws CadiException, LocatorException { - if(aafCon==null) { - if(access.getProperty(Config.AAF_URL,null)!=null) { + if (aafCon==null) { + if (access.getProperty(Config.AAF_URL,null)!=null) { aafCon = _newAAFConHttp(); } else { throw new CadiException("AAFCon cannot be constructed without " + Config.AAF_URL); @@ -137,7 +137,7 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte * @throws LocatorException */ protected synchronized AAFConHttp _newAAFConHttp() throws CadiException, LocatorException { - if(aafCon==null) { + if (aafCon==null) { aafCon = new AAFConHttp(access); } return aafCon; @@ -165,20 +165,20 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) { String tagEQ = tag + '='; String value; - for(String arg : args) { - if(arg.startsWith(tagEQ)) { + for (String arg : args) { + if (arg.startsWith(tagEQ)) { props.put(tag, value=arg.substring(tagEQ.length())); return value; } } // check System.properties value = System.getProperty(tag); - if(value!=null) { + if (value!=null) { props.put(tag, value); return value; } - if(def!=null) { + if (def!=null) { props.put(tag,def); } return def; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java index f14d6c32..29166b0b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java @@ -72,11 +72,11 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr @SafeVarargs public final synchronized void register(final Registrant<ENV> ... registrants) { - if(do_register) { - if(registrar==null) { + if (do_register) { + if (registrar==null) { registrar = new Registrar<ENV>(env(),false); } - for(Registrant<ENV> r : registrants) { + for (Registrant<ENV> r : registrants) { registrar.register(r); } } @@ -84,11 +84,11 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr @Override public void shutdown() { - if(registrar!=null) { + if (registrar!=null) { registrar.close(env()); registrar=null; } - if(service!=null) { + if (service!=null) { service.destroy(); } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java index a0dafed1..c5849d05 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java @@ -78,15 +78,15 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex // Properties props = access().getProperties(); // Object temp = null; // // Critical - if no Security Protocols set, then set it. We'll just get messed up if not -// if((temp=props.get(Config.CADI_PROTOCOLS))==null) { -// if((temp=props.get(Config.HTTPS_PROTOCOLS))==null) { +// if ((temp=props.get(Config.CADI_PROTOCOLS))==null) { +// if ((temp=props.get(Config.HTTPS_PROTOCOLS))==null) { // props.put(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT); // } else { // props.put(Config.CADI_PROTOCOLS, temp); // } // } // -// if("1.7".equals(System.getProperty("java.specification.version"))) { +// if ("1.7".equals(System.getProperty("java.specification.version"))) { // System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT); // } // System.setProperty(Config.HTTPS_CIPHER_SUITES, temp.toString()); @@ -98,15 +98,15 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex Properties props = access().getProperties(); Object httpproto = null; // Critical - if no Security Protocols set, then set it. We'll just get messed up if not - if((httpproto=props.get(Config.CADI_PROTOCOLS))==null) { - if((httpproto=props.get(Config.HTTPS_PROTOCOLS))==null) { + if ((httpproto=props.get(Config.CADI_PROTOCOLS))==null) { + if ((httpproto=props.get(Config.HTTPS_PROTOCOLS))==null) { props.put(Config.CADI_PROTOCOLS, (httpproto=SecurityInfo.HTTPS_PROTOCOLS_DEFAULT)); } else { props.put(Config.CADI_PROTOCOLS, httpproto); } } - if("1.7".equals(System.getProperty("java.specification.version")) && (httpproto==null || (httpproto instanceof String && ((String)httpproto).contains("TLSv1.2")))) { + if ("1.7".equals(System.getProperty("java.specification.version")) && (httpproto==null || (httpproto instanceof String && ((String)httpproto).contains("TLSv1.2")))) { System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT); } } @@ -114,7 +114,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex @Override public void _start(RServlet<TRANS> rserv) throws Exception { String hostname = access().getProperty(Config.HOSTNAME, null); - if(hostname==null) { + if (hostname==null) { hostname = Inet4Address.getLocalHost().getHostName(); } final int port = Integer.parseInt(access().getProperty("port","0")); @@ -124,14 +124,14 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex ServerConnector conn; String protocol; - if(!secure || keystore==null) { + if (!secure || keystore==null) { conn = new ServerConnector(server); protocol = "http"; } else { protocol = "https"; String keystorePassword = access().getProperty(Config.CADI_KEYSTORE_PASSWORD, null); - if(keystorePassword==null) { + if (keystorePassword==null) { throw new CadiException("No Keystore Password configured for " + keystore); } SslContextFactory sslContextFactory = new SslContextFactory(); @@ -142,9 +142,9 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex temp=null; // don't leave lying around String truststore = access().getProperty(Config.CADI_TRUSTSTORE, null); - if(truststore!=null) { + if (truststore!=null) { String truststorePassword = access().getProperty(Config.CADI_TRUSTSTORE_PASSWORD, null); - if(truststorePassword==null) { + if (truststorePassword==null) { throw new CadiException("No Truststore Password configured for " + truststore); } sslContextFactory.setTrustStorePath(truststore); @@ -163,7 +163,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex // sslContextFactory.setEnableCRLDP(false); // sslContextFactory.setEnableOCSP(false); String certAlias = access().getProperty(Config.CADI_ALIAS, null); - if(certAlias!=null) { + if (certAlias!=null) { sslContextFactory.setCertAlias(certAlias); } @@ -232,7 +232,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex register(service.registrants(port)); access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port); server.join(); - } catch(Exception e) { + } catch (Exception e) { access().log(e,"Error registering " + service.app_name); String doExit = access().getProperty("cadi_exitOnFailure", "true"); if (doExit == "true") { @@ -246,7 +246,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex private FilterChain buildFilterChain(final AbsService<?,?> as, final FilterChain doLast) throws CadiException, LocatorException { Filter[] filters = as.filters(); FilterChain fc = doLast; - for(int i=filters.length-1;i>=0;--i) { + for (int i=filters.length-1;i>=0;--i) { fc = new FCImpl(filters[i],fc); } return fc; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java index 31b76395..fd0691b6 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java @@ -55,14 +55,14 @@ public class Log4JLogIt implements LogIt { String etc_dir = getArgOrVM(Config.CADI_ETCDIR,args,"/opt/app/osaaf/etc"); String log_level = getArgOrVM(Config.CADI_LOGLEVEL,args,"INFO"); File logs = new File(log_dir); - if(!logs.isDirectory()) { + if (!logs.isDirectory()) { logs.delete(); } - if(!logs.exists()) { + if (!logs.exists()) { logs.mkdirs(); } - if(System.getProperty("log4j.configuration")==null) { + if (System.getProperty("log4j.configuration")==null) { System.setProperty("log4j.configuration", etc_dir+'/'+propsFile); } LogFileNamer lfn = new LogFileNamer(log_dir,root); @@ -86,14 +86,14 @@ public class Log4JLogIt implements LogIt { private static final String getArgOrVM(final String tag, final String args[], final String def) { String tagEQ = tag + '='; String value; - for(String arg : args) { - if(arg.startsWith(tagEQ)) { + for (String arg : args) { + if (arg.startsWith(tagEQ)) { return arg.substring(tagEQ.length()); } } // check System.properties value = System.getProperty(tag); - if(value!=null) { + if (value!=null) { return value; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java index eb721285..1c9f4123 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java @@ -70,16 +70,16 @@ public class Validator { } public final Validator nullOrBlank(String name, String str) { - if(str==null) { + if (str==null) { msg(name + " is null."); - } else if(str.length()==0) { + } else if (str.length()==0) { msg(name + " is blank."); } return this; } public final Validator isNull(String name, Object o) { - if(o==null) { + if (o==null) { msg(name + " is null."); } return this; @@ -93,10 +93,10 @@ public class Validator { } protected final void msg(String ... strs) { - if(msgs==null) { + if (msgs==null) { msgs=new StringBuilder(); } - for(String str : strs) { + for (String str : strs) { msgs.append(str); } msgs.append('\n'); @@ -107,23 +107,23 @@ public class Validator { } public final Validator notOK(Result<?> res) { - if(res==null) { + if (res==null) { msgs.append("Result object is blank"); - } else if(res.notOK()) { + } else if (res.notOK()) { msgs.append(res.getClass().getSimpleName()).append(" is not OK"); } return this; } protected Validator intRange(String text, int target, int start, int end) { - if(target<start || target>end) { + if (target<start || target>end) { msg(text + " is out of range (" + start + '-' + end + ')'); } return this; } protected Validator floatRange(String text, float target, float start, float end) { - if(target<start || target>end) { + if (target<start || target>end) { msg(text + " is out of range (" + start + '-' + end + ')'); } return this; @@ -137,25 +137,25 @@ public class Validator { } public final Validator permType(String type) { - if(nob(type,NAME_CHARS)) { + if (nob(type,NAME_CHARS)) { msg("Perm Type [" +type + "] is invalid."); } return this; } public final Validator permType(String type, String ns) { - if(type==null) { + if (type==null) { msg("Perm Type is null"); - } else if(ns==null) { + } else if (ns==null) { msg("Perm NS is null"); - } else if(nob(type,NAME_CHARS)) { + } else if (nob(type,NAME_CHARS)) { msg("Perm Type [" + (ns+(type.length()==0?"":'.')) + type + "] is invalid."); } return this; } public final Validator permInstance(String instance) { - if(nob(instance,instChars)) { + if (nob(instance,instChars)) { msg("Perm Instance [" + instance + "] is invalid."); } return this; @@ -163,28 +163,28 @@ public class Validator { public final Validator permAction(String action) { // TODO check for correct Splits? Type|Instance|Action ? - if(nob(action, actionChars)) { + if (nob(action, actionChars)) { msg("Perm Action [" + action + "] is invalid."); } return this; } public final Validator role(String role) { - if(nob(role, NAME_CHARS)) { + if (nob(role, NAME_CHARS)) { msg("Role [" + role + "] is invalid."); } return this; } public final Validator ns(String ns) { - if(ns==null) { + if (ns==null) { msg("NS is null"); return this; - } else if(nob(ns,NAME_CHARS)) { + } else if (nob(ns,NAME_CHARS)) { msg("NS [" + ns + "] is invalid."); } - for(String s : nsKeywords) { - if(ns.endsWith(s)) { + for (String s : nsKeywords) { + if (ns.endsWith(s)) { msg("NS [" + ns + "] may not be named with NS keywords"); break; } @@ -193,14 +193,14 @@ public class Validator { } public final Validator key(String key) { - if(nob(key,NAME_CHARS)) { + if (nob(key,NAME_CHARS)) { msg("NS Prop Key [" + key + "] is invalid"); } return this; } public final Validator value(String value) { - if(nob(value,ESSENTIAL_CHARS)) { + if (nob(value,ESSENTIAL_CHARS)) { msg("NS Prop value [" + value + "] is invalid"); } return this; diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java index a88b005d..2bc7dfa0 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java @@ -74,7 +74,7 @@ public class JU_AbsData { FileOutputStream is = new FileOutputStream(keyfile); OutputStreamWriter osw = new OutputStreamWriter(is); BufferedWriter w = new BufferedWriter(osw); - for(int i = 0; i< 10; i++) { //Write lines to file + for (int i = 0; i< 10; i++) { //Write lines to file w.write("a\nsdfasdfxasdf" + i + "\n"); } w.close(); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java index 099a9f00..b0af89ce 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java @@ -53,13 +53,13 @@ public class JU_DataFile { // Token tok = df.new Token(1024000); // Field fld = tok.new Field('|'); // -// while(tok.nextLine()) { +// while (tok.nextLine()) { // ++count; // fld.reset(); // list.add(fld.at(0)); // } //// Collections.sort(list); -// for(String s: list) { +// for (String s: list) { // System.out.println(s); // // } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java index fadc3b67..d4330296 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java @@ -83,7 +83,7 @@ public class JU_TextIndex { FileOutputStream is = new FileOutputStream(keyfile); OutputStreamWriter osw = new OutputStreamWriter(is); BufferedWriter w = new BufferedWriter(osw); - for(int i = 0; i< 10; i++) { //Write lines to file + for (int i = 0; i< 10; i++) { //Write lines to file w.write("a\nsdfasdfxasdf" + i + "\n"); } w.close(); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java index acbaa9c8..0786c134 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java @@ -59,10 +59,10 @@ public class NSAttribCompare extends RosettaCompare<NsAttribRequest> { @Override public void compare(NsAttribRequest t1, NsAttribRequest t2) { assertEquals(t1.getNs(),t2.getNs()); - for(Attrib a1 : t1.getAttrib()) { + for (Attrib a1 : t1.getAttrib()) { boolean ok = false; - for(Attrib a2 : t2.getAttrib()) { - if(a1.getKey().equals(a2.getKey()) && + for (Attrib a2 : t2.getAttrib()) { + if (a1.getKey().equals(a2.getKey()) && a1.getValue().equals(a2.getValue())) { ok = true; break; @@ -70,10 +70,10 @@ public class NSAttribCompare extends RosettaCompare<NsAttribRequest> { } assertTrue("a2 Attribs in a1",ok); } - for(Attrib a2 : t2.getAttrib()) { + for (Attrib a2 : t2.getAttrib()) { boolean ok = false; - for(Attrib a1 : t1.getAttrib()) { - if(a1.getKey().equals(a2.getKey()) && + for (Attrib a1 : t1.getAttrib()) { + if (a1.getKey().equals(a2.getKey()) && a1.getValue().equals(a2.getValue())) { ok = true; break; diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java index 53f78b7c..c3504216 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java @@ -56,10 +56,10 @@ public class NSCompare extends RosettaCompare<NsRequest> { public void compare(NsRequest t1, NsRequest t2) { assertEquals(t1.getName(),t2.getName()); assertEquals(t1.getDescription(),t2.getDescription()); - for(String s : t1.getAdmin()) { + for (String s : t1.getAdmin()) { assertTrue(t2.getAdmin().contains(s)); } - for(String s : t2.getAdmin()) { + for (String s : t2.getAdmin()) { assertTrue(t1.getAdmin().contains(s)); } assertEquals(t1.getType(),t2.getType()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java index 5a581edc..c809c55f 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/validation/test/JU_Validator.java @@ -286,7 +286,7 @@ public class JU_Validator { assertFalse(Validator.INST_CHARS.matcher("").matches()); - for( char c=0x20;c<0x7F;++c) { + for ( char c=0x20;c<0x7F;++c) { boolean b; switch(c) { case '?': |