From 7e966914050e66219689001ff4ab601a49eef0ac Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 7 Sep 2018 13:43:23 -0500 Subject: Mass whitespace changes (Style Warnings) Issue-ID: AAF-473 Change-Id: Ia1b3825a527bd56299949b5962bb9354dffbeef8 Signed-off-by: Instrumental --- .../main/java/org/onap/aaf/auth/cache/Cache.java | 18 +++--- .../main/java/org/onap/aaf/auth/common/Define.java | 14 ++--- .../main/java/org/onap/aaf/auth/env/AuthzEnv.java | 20 +++---- .../org/onap/aaf/auth/env/AuthzTransFilter.java | 24 ++++---- .../java/org/onap/aaf/auth/env/AuthzTransImpl.java | 18 +++--- .../onap/aaf/auth/env/AuthzTransOnlyFilter.java | 2 +- .../main/java/org/onap/aaf/auth/env/NullTrans.java | 2 +- .../main/java/org/onap/aaf/auth/layer/Result.java | 10 ++-- .../main/java/org/onap/aaf/auth/local/AbsData.java | 14 ++--- .../java/org/onap/aaf/auth/local/DataFile.java | 34 +++++------ .../java/org/onap/aaf/auth/local/TextIndex.java | 36 +++++------ .../java/org/onap/aaf/auth/org/Organization.java | 4 +- .../org/onap/aaf/auth/org/OrganizationFactory.java | 32 +++++----- .../java/org/onap/aaf/auth/rserv/Acceptor.java | 46 +++++++------- .../org/onap/aaf/auth/rserv/CachingFileAccess.java | 70 +++++++++++----------- .../main/java/org/onap/aaf/auth/rserv/Content.java | 12 ++-- .../java/org/onap/aaf/auth/rserv/HttpCode.java | 18 +++--- .../main/java/org/onap/aaf/auth/rserv/Match.java | 60 +++++++++---------- .../java/org/onap/aaf/auth/rserv/RServlet.java | 8 +-- .../main/java/org/onap/aaf/auth/rserv/Route.java | 8 +-- .../main/java/org/onap/aaf/auth/rserv/Routes.java | 14 ++--- .../java/org/onap/aaf/auth/rserv/TransFilter.java | 16 ++--- .../java/org/onap/aaf/auth/rserv/TypedCode.java | 50 ++++++++-------- .../main/java/org/onap/aaf/auth/rserv/Version.java | 18 +++--- .../java/org/onap/aaf/auth/server/AbsService.java | 28 ++++----- .../onap/aaf/auth/server/AbsServiceStarter.java | 10 ++-- .../onap/aaf/auth/server/JettyServiceStarter.java | 28 ++++----- .../java/org/onap/aaf/auth/server/Log4JLogIt.java | 12 ++-- .../org/onap/aaf/auth/validation/Validator.java | 44 +++++++------- .../org/onap/aaf/auth/local/test/JU_AbsData.java | 2 +- .../org/onap/aaf/auth/local/test/JU_DataFile.java | 4 +- .../org/onap/aaf/auth/local/test/JU_TextIndex.java | 2 +- .../aaf/auth/request/test/NSAttribCompare.java | 12 ++-- .../org/onap/aaf/auth/request/test/NSCompare.java | 4 +- .../aaf/auth/validation/test/JU_Validator.java | 2 +- 35 files changed, 348 insertions(+), 348 deletions(-) (limited to 'auth/auth-core') 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 { public static Map obtain(String key) { Map 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 { Date now = new Date(System.currentTimeMillis() + advance); - for(String name : set) { + for (String name : set) { Map map = cacheMap.get(name); - if(map==null) { + if (map==null) { continue; } - for(Map.Entry me : map.entrySet()) { + for (Map.Entry me : map.entrySet()) { ++total; if (me.getValue().timestamp.before(now)) { map.remove(me.getKey()); @@ -152,13 +152,13 @@ public class Cache { } } - 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 { } 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 es : access.getProperties().entrySet()) { - if(es.getKey().toString().startsWith(ROOT_NS_TAG_DOT)) { + for ( Entry 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;i0) { - if(prev>0) { + for (int i=idx;i0) { + if (prev>0) { ++count; pot += times[i]-prev; } prev = times[i]; } } - for(int i=0;i0) { - if(prev>0) { + for (int i=0;i0) { + 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 { 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 { 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 { // Add current Metrics to total metrics serviceMetric.total+= m.total; - for(int i=0;i { 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 { 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 { 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 { 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 { @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 { 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 { } 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 { } 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 { @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)return null; + if (idx>=end)return null; int start = idx; byte c=0; int endStr = -1; - while(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(lhashhash) { + } else if (lhash>hash) { max=curr-1; } else { min=curr-40; @@ -90,20 +90,20 @@ public class TextIndex { } List 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 es : env.getProperties().entrySet()) { + for (Entry 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 cls = (Class) Class.forName(orgClass); Constructor 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 { private boolean eval(HttpCode code, String str, List props) { // int plus = str.indexOf('+'); -// if(plus<0) { +// if (plus<0) { boolean ok = false; boolean any = false; - for(Pair, List>>> type : types) { + for (Pair, List>>> type : types) { ok = true; - if(type.x.equals(str)) { - for(Iterator iter = props.iterator();ok && iter.hasNext();) { + if (type.x.equals(str)) { + for (Iterator 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 { // 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, List>>> type : types) { -// if(type.x.equals(nstr)) { +// for (Pair, List>>> type : types) { +// if (type.x.equals(nstr)) { // acceptable.add(type); // return type; // } @@ -90,14 +90,14 @@ class Acceptor { */ private boolean props(Pair, List>>> type, String tag, String value) { boolean rv = false; - if(type.y!=null) { - for(Pair prop : type.y.y){ - if(tag.equals(prop.x)) { - if(tag.equals("charset")) { + if (type.y!=null) { + for (Pair 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 { name=null; cis = cie+1; // find comma start - while(ciscis && 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(siscend || 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 && eqsis && eq=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 extends HttpCode { public static void setEnv(Store store, String[] args) { - for(int i=0;i extends HttpCode extends HttpCode extends HttpCode0?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 extends HttpCode extends HttpCodec.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 extends HttpCode0; } - 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 extends HttpCode extends HttpCode extends HttpCode extends HttpCode=0) { + while ((read = fr.read(buff,0,1024))>=0) { writer.write(buff,0,read); } } finally { @@ -387,7 +387,7 @@ public class CachingFileAccess extends HttpCode=0) { + while ((read = fis.read(buff,0,1024))>=0) { os.write(buff,0,read); } } finally { @@ -415,13 +415,13 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCodemaxSize) { + if (size>maxSize) { ArrayList scont = new ArrayList<>(size); Object[] entries = content.entrySet().toArray(); - for(int i=0;i)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 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 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 { 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 { // If there are additional elements (more entities within Semi Colons) // apply Propertys int eq = cntnt.indexOf('=',sis); - if(eq>sis && eqsis && eq { */ 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 { * @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;i1) { + 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;i0?(pabytes[0]=='/'):false; // IF DEBUG: System.out.println("\n -- " + path + " --"); - for(int i=0;rv && i=lastField) { // checking here allows there to be a non-functional ending / + for (int i=0;rv && i=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; ji)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 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 implements Servlet { CodeSetter codesetter = new CodeSetter(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 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 { // 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, List>>> 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 { // Package on purpose synchronized Route findOrCreate(HttpMethods meth, String path) { Route rv = null; - for(int i=0;i=routes.length) { + if (rv==null) { + if (end>=routes.length) { @SuppressWarnings("unchecked") Route[] temp = new Route[end+10]; System.arraycopy(routes, 0, temp, 0, routes.length); @@ -69,9 +69,9 @@ public class Routes { String path = req.getPathInfo(); String meth = req.getMethod(); //TODO a TREE would be better - for(int i=0;rv==null && i { public List routeReport() { ArrayList ltr = new ArrayList<>(); - for(int i=0;i 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 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 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 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 extends Content { public TypedCode add(HttpCode 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 extends Content { Pair, List>> cl = new Pair, List>>(code, props); // // breakup "plus" stuff, i.e. application/xaml+xml // int plus = str.indexOf('+'); -// if(plus<0) { +// if (plus<0) { type = new Pair,List>>>(str, cl); types.add(type); return type; @@ -102,7 +102,7 @@ public class TypedCode extends Content { // 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,List>>>(nstr, cl); // types.add(type); @@ -115,7 +115,7 @@ public class TypedCode extends Content { @Override protected boolean props(Pair, List>>> 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 extends Content { public Pair, List>>> prep(TRANS trans, String compare) throws IOException, ServletException { Pair, List>>> 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 acc = new Acceptor(types); @@ -144,7 +144,7 @@ public class TypedCode extends Content { } finally { tt.done(); } - if(accepted) { + if (accepted) { switch(acc.acceptable.size()) { case 0: // // TODO best Status Code? @@ -156,16 +156,16 @@ public class TypedCode extends Content { default: // compare Q values to get Best Match float bestQ = -1.0f; Pair, List>>> bestT = null; - for(Pair, List>>> type : acc.acceptable) { + for (Pair, List>>> 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 +// if (isGet)resp.setContentType(bestT.x); // set ContentType of Code // rv = bestT.y.x; rv = bestT; } @@ -190,17 +190,17 @@ public class TypedCode extends Content { */ public StringBuilder relatedTo(HttpCode code, StringBuilder sb) { boolean first = true; - for(Pair, List>>> pair : types) { - if(code==null || pair.y.x == code) { - if(first) { + for (Pair, List>>> pair : types) { + if (code==null || pair.y.x == code) { + if (first) { first = false; } else { sb.append(','); } sb.append(pair.x); - for(Pair prop : pair.y.y) { + for (Pair 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 extends Content { } public List> getContent(HttpCode code) { - for(Pair, List>>> pair : types) { - if(pair.y.x == code) { + for (Pair, List>>> pair : types) { + if (pair.y.x == code) { return pair.y.y; } } @@ -232,11 +232,11 @@ public class TypedCode extends Content { tr.desc = null; // Read through Code/TypeCode trees for all accepted Typecodes - for(Pair, List>>> tc : types) { + for (Pair, List>>> 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 extends Content { temp.append(tc.x); // add all properties - for(Pair props : tc.y.y) { + for (Pair props : tc.y.y) { temp.append(';'); temp.append(props.x); temp.append('='); @@ -254,13 +254,13 @@ public class TypedCode extends Content { } // 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 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, : 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 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 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 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 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 ... registrants) { - if(do_register) { - if(registrar==null) { + if (do_register) { + if (registrar==null) { registrar = new Registrar(env(),false); } - for(Registrant r : registrants) { + for (Registrant r : registrants) { registrar.register(r); } } @@ -84,11 +84,11 @@ public abstract class AbsServiceStarter 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 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 ex @Override public void _start(RServlet 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 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 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 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 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 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(targetend) { + if (targetend) { msg(text + " is out of range (" + start + '-' + end + ')'); } return this; } protected Validator floatRange(String text, float target, float start, float end) { - if(targetend) { + if (targetend) { 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 { @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 { } 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 { 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 '?': -- cgit 1.2.3-korg