summaryrefslogtreecommitdiffstats
path: root/cadi/core
diff options
context:
space:
mode:
Diffstat (limited to 'cadi/core')
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/AES.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java60
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Access.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/BufferedServletInputStream.java24
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java48
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java84
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Hash.java34
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java70
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/ServletContextAccess.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java94
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/User.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java152
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Get.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/GetAccess.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/MultiGet.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java28
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java56
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java24
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/lur/ConfigPrincipal.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/lur/EpiLur.java34
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/lur/LocalLur.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/BasicPrincipal.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/CachedBasicPrincipal.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/Kind.java8
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/OAuth2FormPrincipal.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/TaggedPrincipal.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/TrustPrincipal.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/principal/X509Principal.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/EpiTaf.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java32
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java52
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java76
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/JsonOutputStream.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/NetMask.java12
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java24
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/TheConsole.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/UserChainManip.java18
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java30
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/wsse/Match.java20
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java70
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/filter/test/JU_AUTHZServlet.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/principal/test/JU_X509Principal.java6
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/taf/dos/test/JU_DenialOfServiceTaf.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java8
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java16
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_PropAccess.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_ServletContextAccess.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSEParser.java4
56 files changed, 609 insertions, 609 deletions
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/AES.java b/cadi/core/src/main/java/org/onap/aaf/cadi/AES.java
index 142dde26..c4f3d504 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/AES.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/AES.java
@@ -100,7 +100,7 @@ public class AES implements Encryption {
public CipherOutputStream outputStream(OutputStream os, boolean encrypt) {
try {
Cipher c = Cipher.getInstance(AES);
- if(encrypt) {
+ if (encrypt) {
c.init(Cipher.ENCRYPT_MODE,aeskeySpec);
} else {
c.init(Cipher.DECRYPT_MODE,aeskeySpec);
@@ -116,7 +116,7 @@ public class AES implements Encryption {
public CipherInputStream inputStream(InputStream is, boolean encrypt) {
try {
Cipher c = Cipher.getInstance(AES);
- if(encrypt) {
+ if (encrypt) {
c.init(Cipher.ENCRYPT_MODE,aeskeySpec);
} else {
c.init(Cipher.DECRYPT_MODE,aeskeySpec);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java b/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
index d9d4474d..e6d24dab 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/AbsUserCache.java
@@ -76,10 +76,10 @@ public abstract class AbsUserCache<PERM extends Permission> {
userMap = new ConcurrentHashMap<>();
- if(cleanInterval>0) {
+ if (cleanInterval>0) {
cleanInterval = Math.max(MIN_INTERVAL, cleanInterval);
synchronized(AbsUserCache.class) { // Lazy instantiate.. in case there is no cleanup needed
- if(timer==null) {
+ if (timer==null) {
timer = new Timer("CADI Cleanup Timer",true);
}
@@ -96,14 +96,14 @@ public abstract class AbsUserCache<PERM extends Permission> {
missEncrypt = cache.missEncrypt;
synchronized(AbsUserCache.class) {
- if(cache.clean!=null && cache.clean.lur==null && this instanceof CachingLur) {
+ if (cache.clean!=null && cache.clean.lur==null && this instanceof CachingLur) {
cache.clean.lur=(CachingLur<PERM>)this;
}
}
}
protected void setLur(CachingLur<PERM> lur) {
- if(clean!=null)clean.lur = lur;
+ if (clean!=null)clean.lur = lur;
}
@@ -111,11 +111,11 @@ public abstract class AbsUserCache<PERM extends Permission> {
Principal p = user.principal;
String key;
try {
- if(p instanceof GetCred) {
+ if (p instanceof GetCred) {
key = missKey(p.getName(), ((GetCred)p).getCred());
} else {
byte[] cred;
- if((cred=user.getCred())==null) {
+ if ((cred=user.getCred())==null) {
key = user.name + NO_CRED;
} else {
key = missKey(user.name,cred);
@@ -152,7 +152,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
return false;
}
Miss miss = missMap.get(mkey);
- if(miss==null) {
+ if (miss==null) {
missMap.put(mkey, new Miss(bs,clean==null?MIN_INTERVAL:clean.timeInterval,key));
return true;
}
@@ -165,7 +165,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
protected User<PERM> getUser(Principal principal) {
String key;
- if(principal instanceof GetCred) {
+ if (principal instanceof GetCred) {
GetCred gc = (GetCred)principal;
try {
key = missKey(principal.getName(), gc.getCred());
@@ -177,7 +177,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
key = principal.getName()+NO_CRED;
}
User<PERM> u = userMap.get(key);
- if(u!=null) {
+ if (u!=null) {
u.incCount();
}
return u;
@@ -197,8 +197,8 @@ public abstract class AbsUserCache<PERM extends Permission> {
return null;
}
u = userMap.get(key);
- if(u!=null) {
- if(u.permExpired()) {
+ if (u!=null) {
+ if (u.permExpired()) {
userMap.remove(key);
u=null;
} else {
@@ -223,7 +223,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
*/
public void remove(String user) {
Object o = userMap.remove(user);
- if(o!=null) {
+ if (o!=null) {
access.log(Level.INFO, user,"removed from Client Cache by Request");
}
}
@@ -237,7 +237,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
public final List<DumpInfo> dumpInfo() {
List<DumpInfo> rv = new ArrayList<>();
- for(User<PERM> user : userMap.values()) {
+ for (User<PERM> user : userMap.values()) {
rv.add(new DumpInfo(user));
}
return rv;
@@ -256,7 +256,7 @@ public abstract class AbsUserCache<PERM extends Permission> {
* If overloading in Derived class, be sure to call "super.destroy()"
*/
public void destroy() {
- if(timer!=null) {
+ if (timer!=null) {
timer.purge();
timer.cancel();
}
@@ -318,13 +318,13 @@ public abstract class AbsUserCache<PERM extends Permission> {
ArrayList<User<PERM>> al = new ArrayList<>(userMap.values().size());
al.addAll(0, userMap.values());
long now = System.currentTimeMillis() + advance;
- for(User<PERM> user : al) {
+ for (User<PERM> user : al) {
++total;
- if(user.count>usageTriggerCount) {
+ if (user.count>usageTriggerCount) {
boolean touched = false, removed=false;
- if(user.principal instanceof CachedPrincipal) {
+ if (user.principal instanceof CachedPrincipal) {
CachedPrincipal cp = (CachedPrincipal)user.principal;
- if(cp.expires() < now) {
+ if (cp.expires() < now) {
switch(cp.revalidate(null)) {
case INACCESSIBLE:
access.log(Level.AUDIT, "AAF Inaccessible. Keeping credentials");
@@ -343,20 +343,20 @@ public abstract class AbsUserCache<PERM extends Permission> {
}
}
- if(!removed && lur!=null && user.permExpires<= now ) {
- if(lur.reload(user).equals(Resp.REVALIDATED)) {
+ if (!removed && lur!=null && user.permExpires<= now ) {
+ if (lur.reload(user).equals(Resp.REVALIDATED)) {
user.renewPerm();
access.log(Level.DEBUG, "Reloaded Perms for",user);
touched = true;
}
}
user.resetCount();
- if(touched) {
+ if (touched) {
++renewed;
}
} else {
- if(user.permExpired()) {
+ if (user.permExpired()) {
remove(user);
++count;
}
@@ -366,14 +366,14 @@ public abstract class AbsUserCache<PERM extends Permission> {
// Clean out Misses
int missTotal = missMap.keySet().size();
int miss = 0;
- if(missTotal>0) {
+ if (missTotal>0) {
ArrayList<String> keys = new ArrayList<>(missTotal);
keys.addAll(missMap.keySet());
- for(String key : keys) {
+ for (String key : keys) {
Miss m = missMap.get(key);
- if(m!=null) {
+ if (m!=null) {
long timeLeft = m.timestamp - System.currentTimeMillis();
- if(timeLeft<0) {
+ if (timeLeft<0) {
synchronized(missMap) {
missMap.remove(key);
}
@@ -386,14 +386,14 @@ public abstract class AbsUserCache<PERM extends Permission> {
}
}
- if(count+renewed+miss>0) {
+ if (count+renewed+miss>0) {
access.log(Level.INFO, (lur==null?"Cache":lur.getClass().getSimpleName()), "removed",count,
"and renewed",renewed,"expired Permissions out of", total,"and removed", miss, "password misses out of",missTotal);
}
// 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 {
@@ -432,10 +432,10 @@ public abstract class AbsUserCache<PERM extends Permission> {
public synchronized boolean mayContinue() {
long ts = System.currentTimeMillis();
- if(ts>timestamp) {
+ if (ts>timestamp) {
tries = 0;
timestamp = ts + timetolive;
- } else if(MAX_TRIES <= ++tries) {
+ } else if (MAX_TRIES <= ++tries) {
return false;
}
return true;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java
index 76d9bb2a..a673ab4f 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java
@@ -57,7 +57,7 @@ public interface Access {
}
public int toggle(int mask) {
- if(inMask(mask)) {
+ if (inMask(mask)) {
return delFromMask(mask);
} else {
return addToMask(mask);
@@ -67,8 +67,8 @@ public interface Access {
public int maskOf() {
int mask=0;
- for(Level l : values()) {
- if(ordinal()<=l.ordinal() && l!=NONE) {
+ for (Level l : values()) {
+ if (ordinal()<=l.ordinal() && l!=NONE) {
mask|=l.bit;
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/BufferedServletInputStream.java b/cadi/core/src/main/java/org/onap/aaf/cadi/BufferedServletInputStream.java
index 3f47351b..8202183d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/BufferedServletInputStream.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/BufferedServletInputStream.java
@@ -63,19 +63,19 @@ public class BufferedServletInputStream extends ServletInputStream {
public int read() throws IOException {
int value=-1;
- if(capacitor==null) {
+ if (capacitor==null) {
value=is.read();
} else {
switch(state) {
case STORE:
value = is.read();
- if(value>=0) {
+ if (value>=0) {
capacitor.put((byte)value);
}
break;
case READ:
value = capacitor.read();
- if(value<0) {
+ if (value<0) {
capacitor.done();
capacitor=null; // all done with buffer
value = is.read();
@@ -92,27 +92,27 @@ public class BufferedServletInputStream extends ServletInputStream {
public int read(byte[] b, int off, int len) throws IOException {
int count = -1;
- if(capacitor==null) {
+ if (capacitor==null) {
count = is.read(b,off,len);
} else {
switch(state) {
case STORE:
count = is.read(b, off, len);
- if(count>0) {
+ if (count>0) {
capacitor.put(b, off, count);
}
break;
case READ:
count = capacitor.read(b, off, len);
- if(count<=0) {
+ if (count<=0) {
capacitor.done();
capacitor=null; // all done with buffer
}
- if(count<len) {
+ if (count<len) {
int temp = is.read(b, count, len-count);
- if(temp>0) { // watch for -1
+ if (temp>0) { // watch for -1
count+=temp;
- } else if(count<=0) {
+ } else if (count<=0) {
count = temp; // must account for Stream coming back -1
}
}
@@ -124,7 +124,7 @@ public class BufferedServletInputStream extends ServletInputStream {
public long skip(long n) throws IOException {
long skipped = capacitor.skip(n);
- if(skipped<n) {
+ if (skipped<n) {
skipped += is.skip(n-skipped);
}
return skipped;
@@ -133,7 +133,7 @@ public class BufferedServletInputStream extends ServletInputStream {
public int available() throws IOException {
int count = is.available();
- if(capacitor!=null)count+=capacitor.available();
+ if (capacitor!=null)count+=capacitor.available();
return count;
}
@@ -147,7 +147,7 @@ public class BufferedServletInputStream extends ServletInputStream {
public void close() throws IOException {
- if(capacitor!=null) {
+ if (capacitor!=null) {
capacitor.done();
capacitor=null;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java b/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
index 647cd8a6..34d11623 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/CadiWrap.java
@@ -118,13 +118,13 @@ public class CadiWrap extends HttpServletRequestWrapper implements HttpServletRe
}
public static boolean checkPerm(Access access, String caller, Principal principal, PermConverter pconv, Lur lur, String perm) {
- if(principal== null) {
+ if (principal== null) {
access.log(Level.AUDIT,caller, "No Principal in Transaction");
return false;
} else {
final long start = System.nanoTime();
perm = pconv.convert(perm);
- if(lur.fish(principal,lur.createPerm(perm))) {
+ if (lur.fish(principal,lur.createPerm(perm))) {
access.printf(Level.DEBUG,"%s: %s has %s, %f ms", caller, principal.getName(), perm, Timing.millis(start));
return true;
} else {
@@ -158,7 +158,7 @@ public class CadiWrap extends HttpServletRequestWrapper implements HttpServletRe
}
public String getUser() {
- if(user==null && principal!=null) {
+ if (user==null && principal!=null) {
user = principal.getName();
}
return user;
@@ -183,9 +183,9 @@ public class CadiWrap extends HttpServletRequestWrapper implements HttpServletRe
// Add a feature
public void invalidate(String id) {
- if(lur instanceof EpiLur) {
+ if (lur instanceof EpiLur) {
((EpiLur)lur).remove(id);
- } else if(lur instanceof CachingLur) {
+ } else if (lur instanceof CachingLur) {
((CachingLur<?>)lur).remove(id);
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
index 5ca1ce30..f3a2a7fa 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Capacitor.java
@@ -46,7 +46,7 @@ public class Capacitor {
public void put(byte b) {
- if(curr == null || curr.remaining()==0) { // ensure we have a "curr" buffer ready for data
+ if (curr == null || curr.remaining()==0) { // ensure we have a "curr" buffer ready for data
curr = ringGet();
bbs.add(curr);
}
@@ -54,10 +54,10 @@ public class Capacitor {
}
public int read() {
- if(curr!=null) {
- if(curr.remaining()>0) { // have a buffer, use it!
+ if (curr!=null) {
+ if (curr.remaining()>0) { // have a buffer, use it!
return curr.get();
- } else if(idx<bbs.size()){ // Buffer not enough, get next one from array
+ } else if (idx<bbs.size()){ // Buffer not enough, get next one from array
curr=bbs.get(idx++);
return curr.get();
}
@@ -74,11 +74,11 @@ public class Capacitor {
* @return
*/
public int read(byte[] array, int offset, int length) {
- if(curr==null)return -1;
+ if (curr==null)return -1;
int len;
int count=0;
- while(length>0) { // loop through while there's data needed
- if((len=curr.remaining())>length) { // if enough data in curr buffer, use this code
+ while (length>0) { // loop through while there's data needed
+ if ((len=curr.remaining())>length) { // if enough data in curr buffer, use this code
curr.get(array,offset,length);
count+=length;
length=0;
@@ -87,7 +87,7 @@ public class Capacitor {
count+=len;
offset+=len;
length-=len;
- if(idx<bbs.size()) {
+ if (idx<bbs.size()) {
curr=bbs.get(idx++);
} else {
length=0; // stop, and return the count of how many we were able to load
@@ -105,14 +105,14 @@ public class Capacitor {
* @param length
*/
public void put(byte[] array, int offset, int length) {
- if(curr == null || curr.remaining()==0) {
+ if (curr == null || curr.remaining()==0) {
curr = ringGet();
bbs.add(curr);
}
int len;
- while(length>0) {
- if((len=curr.remaining())>length) {
+ while (length>0) {
+ if ((len=curr.remaining())>length) {
curr.put(array,offset,length);
length=0;
} else {
@@ -130,10 +130,10 @@ public class Capacitor {
* Move state from Storage mode into Read mode, changing all internal buffers to read mode, etc
*/
public void setForRead() {
- for(ByteBuffer bb : bbs) {
+ for (ByteBuffer bb : bbs) {
bb.flip();
}
- if(bbs.isEmpty()) {
+ if (bbs.isEmpty()) {
curr = null;
idx = 0;
} else {
@@ -146,7 +146,7 @@ public class Capacitor {
* reuse all the buffers
*/
public void done() {
- for(ByteBuffer bb : bbs) {
+ for (ByteBuffer bb : bbs) {
ringPut(bb);
}
bbs.clear();
@@ -160,7 +160,7 @@ public class Capacitor {
*/
public int available() {
int count = 0;
- for(ByteBuffer bb : bbs) {
+ for (ByteBuffer bb : bbs) {
count+=bb.remaining();
}
return count;
@@ -174,11 +174,11 @@ public class Capacitor {
public long skip(long n) {
long skipped=0L;
int skip;
- if(curr==null) {
+ if (curr==null) {
return 0;
}
- while(n>0) {
- if(n<(skip=curr.remaining())) {
+ while (n>0) {
+ if (n<(skip=curr.remaining())) {
curr.position(curr.position()+(int)n);
skipped+=skip;
n=0;
@@ -186,7 +186,7 @@ public class Capacitor {
curr.position(curr.limit());
skipped-=skip;
- if(idx<bbs.size()) {
+ if (idx<bbs.size()) {
curr=bbs.get(idx++);
n-=skip;
} else {
@@ -201,10 +201,10 @@ public class Capacitor {
* in a standalone mode.
*/
public void reset() {
- for(ByteBuffer bb : bbs) {
+ for (ByteBuffer bb : bbs) {
bb.position(0);
}
- if(bbs.isEmpty()) {
+ if (bbs.isEmpty()) {
curr = null;
idx = 0;
} else {
@@ -221,9 +221,9 @@ public class Capacitor {
synchronized(ring) {
bb=ring[start];
ring[start]=null;
- if(bb!=null && ++start>15)start=0;
+ if (bb!=null && ++start>15)start=0;
}
- if(bb==null) {
+ if (bb==null) {
bb=ByteBuffer.allocate(DEFAULT_CHUNK);
} else {
bb.clear();// refresh reused buffer
@@ -234,7 +234,7 @@ public class Capacitor {
private void ringPut(ByteBuffer bb) {
synchronized(ring) {
ring[end]=bb; // if null or not, BB will just be Garbage collected
- if(++end>15)end=0;
+ if (++end>15)end=0;
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
index 7ca9fac2..68a8db05 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
@@ -48,18 +48,18 @@ public class CmdLine {
* @param args
*/
public static void main(String[] args) {
- if(args.length>0) {
- if("digest".equalsIgnoreCase(args[0]) && (args.length>2 || (args.length>1 && System.console()!=null))) {
+ if (args.length>0) {
+ if ("digest".equalsIgnoreCase(args[0]) && (args.length>2 || (args.length>1 && System.console()!=null))) {
String keyfile;
String password;
- if(args.length>2) {
+ if (args.length>2) {
password = args[1];
keyfile = args[2];
- if("-i".equals(password)) {
+ if ("-i".equals(password)) {
int c;
StringBuilder sb = new StringBuilder();
try {
- while((c=System.in.read())>=0) {
+ while ((c=System.in.read())>=0) {
sb.append((char)c);
}
} catch (IOException e) {
@@ -86,7 +86,7 @@ public class CmdLine {
return;
/* testing code... don't want it exposed
System.out.println(" ******** Testing *********");
- for(int i=0;i<100000;++i) {
+ for (int i=0;i<100000;++i) {
System.out.println(args[1]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
b64.enpass(args[1], baos);
@@ -96,7 +96,7 @@ public class CmdLine {
b64.depass(pass, reconstituted);
String r = reconstituted.toString();
System.out.println(r);
- if(!r.equals(args[1])) {
+ if (!r.equals(args[1])) {
System.err.println("!!!!! STOP - ERROR !!!!!");
return;
}
@@ -113,7 +113,7 @@ public class CmdLine {
// Jonathan. Oh, well, Deployment services need this behavior. I will put this code in, but leave it undocumented.
// One still needs access to the keyfile to read.
// July 2016 - thought of a tool "CMPass" to regurgitate from properties, but only if allowed.
- } else if("regurgitate".equalsIgnoreCase(args[0]) && args.length>2) {
+ } else if ("regurgitate".equalsIgnoreCase(args[0]) && args.length>2) {
try {
Symm symm;
FileInputStream fis = new FileInputStream(args[2]);
@@ -123,10 +123,10 @@ public class CmdLine {
fis.close();
}
boolean isFile = false;
- if("-i".equals(args[1]) || (isFile="-f".equals(args[1]))) {
+ if ("-i".equals(args[1]) || (isFile="-f".equals(args[1]))) {
BufferedReader br;
- if(isFile) {
- if(args.length<4) {
+ if (isFile) {
+ if (args.length<4) {
System.err.println("Filename in 4th position");
return;
}
@@ -139,10 +139,10 @@ public class CmdLine {
boolean cont = false;
StringBuffer sb = new StringBuffer();
JsonOutputStream jw = new JsonOutputStream(System.out);
- while((line=br.readLine())!=null) {
- if(cont) {
+ while ((line=br.readLine())!=null) {
+ if (cont) {
int end;
- if((end=line.indexOf('"'))>=0) {
+ if ((end=line.indexOf('"'))>=0) {
sb.append(line,0,end);
cont=false;
} else {
@@ -150,34 +150,34 @@ public class CmdLine {
}
} else {
int idx;
- if((idx = line.indexOf(' '))>=0
+ if ((idx = line.indexOf(' '))>=0
&& (idx = line.indexOf(' ',++idx))>0
&& (idx = line.indexOf('=',++idx))>0
) {
System.out.println(line.substring(0, idx-5));
int start = idx+2;
int end;
- if((end=line.indexOf('"',start))<0) {
+ if ((end=line.indexOf('"',start))<0) {
end = line.length();
cont = true;
}
sb.append(line,start,end);
}
}
- if(sb.length()>0) {
+ if (sb.length()>0) {
symm.depass(sb.toString(),jw);
- if(!cont) {
+ if (!cont) {
System.out.println();
}
}
System.out.flush();
sb.setLength(0);
- if(!cont) {
+ if (!cont) {
jw.resetIndent();
}
}
} finally {
- if(isFile) {
+ if (isFile) {
br.close();
}
}
@@ -191,7 +191,7 @@ public class CmdLine {
System.err.println("Cannot regurgitate password");
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("encode64".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("encode64".equalsIgnoreCase(args[0]) && args.length>1) {
try {
Symm.base64.encode(args[1], System.out);
System.out.println();
@@ -201,7 +201,7 @@ public class CmdLine {
System.err.println("Cannot encode Base64 with " + args[1]);
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("decode64".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("decode64".equalsIgnoreCase(args[0]) && args.length>1) {
try {
Symm.base64.decode(args[1], System.out);
System.out.println();
@@ -211,7 +211,7 @@ public class CmdLine {
System.err.println("Cannot decode Base64 text from " + args[1]);
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("encode64url".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("encode64url".equalsIgnoreCase(args[0]) && args.length>1) {
try {
Symm.base64url.encode(args[1], System.out);
System.out.println();
@@ -221,7 +221,7 @@ public class CmdLine {
System.err.println("Cannot encode Base64url with " + args[1]);
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("decode64url".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("decode64url".equalsIgnoreCase(args[0]) && args.length>1) {
try {
Symm.base64url.decode(args[1], System.out);
System.out.println();
@@ -231,7 +231,7 @@ public class CmdLine {
System.err.println("Cannot decode Base64url text from " + args[1]);
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("md5".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("md5".equalsIgnoreCase(args[0]) && args.length>1) {
try {
System.out.println(Hash.hashMD5asStringHex(args[1]));
System.out.flush();
@@ -240,11 +240,11 @@ public class CmdLine {
System.err.println(" \""+ e.getMessage() + '"');
}
return;
- } else if("sha256".equalsIgnoreCase(args[0]) && args.length>1) {
+ } else if ("sha256".equalsIgnoreCase(args[0]) && args.length>1) {
try {
- if(args.length>2) {
+ if (args.length>2) {
int max = args.length>7?7:args.length;
- for(int i=2;i<max;++i) {
+ for (int i=2;i<max;++i) {
int salt = Integer.parseInt(args[i]);
System.out.println(Hash.hashSHA256asStringHex(args[1],salt));
}
@@ -257,9 +257,9 @@ public class CmdLine {
}
System.out.flush();
return;
- } else if("keygen".equalsIgnoreCase(args[0])) {
+ } else if ("keygen".equalsIgnoreCase(args[0])) {
try {
- if(args.length>1) {
+ if (args.length>1) {
File f = new File(args[1]);
FileOutputStream fos = new FileOutputStream(f);
try {
@@ -280,13 +280,13 @@ public class CmdLine {
System.err.println(" \""+ e.getMessage() + '"');
}
- } else if("passgen".equalsIgnoreCase(args[0])) {
+ } else if ("passgen".equalsIgnoreCase(args[0])) {
int numDigits;
- if(args.length <= 1) {
+ if (args.length <= 1) {
numDigits = 24;
} else {
numDigits = Integer.parseInt(args[1]);
- if(numDigits<8)numDigits = 8;
+ if (numDigits<8)numDigits = 8;
}
String pass;
boolean noLower,noUpper,noDigits,noSpecial,repeatingChars,missingChars;
@@ -295,33 +295,33 @@ public class CmdLine {
missingChars=noLower=noUpper=noDigits=noSpecial=true;
repeatingChars=false;
int c=-1,last;
- for(int i=0;i<numDigits;++i) {
+ for (int i=0;i<numDigits;++i) {
last = c;
c = pass.charAt(i);
- if(c==last) {
+ if (c==last) {
repeatingChars=true;
break;
}
- if(noLower) {
+ if (noLower) {
noLower=!(c>=0x61 && c<=0x7A);
}
- if(noUpper) {
+ if (noUpper) {
noUpper=!(c>=0x41 && c<=0x5A);
}
- if(noDigits) {
+ if (noDigits) {
noDigits=!(c>=0x30 && c<=0x39);
}
- if(noSpecial) {
+ if (noSpecial) {
noSpecial = "+!@#$%^&*(){}[]?:;,.".indexOf(c)<0;
}
missingChars = (noLower || noUpper || noDigits || noSpecial);
}
- } while(missingChars || repeatingChars);
+ } while (missingChars || repeatingChars);
System.out.println(pass.substring(0,numDigits));
- } else if("urlgen".equalsIgnoreCase(args[0])) {
+ } else if ("urlgen".equalsIgnoreCase(args[0])) {
int numDigits;
- if(args.length <= 1) {
+ if (args.length <= 1) {
numDigits = 24;
} else {
numDigits = Integer.parseInt(args[1]);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Hash.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Hash.java
index acd45019..3027fd74 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Hash.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Hash.java
@@ -132,9 +132,9 @@ public class Hash {
* @return
*/
public static boolean isEqual(byte ba1[], byte ba2[]) {
- if(ba1.length!=ba2.length)return false;
- for(int i = 0;i<ba1.length; ++i) {
- if(ba1[i]!=ba2[i])return false;
+ if (ba1.length!=ba2.length)return false;
+ for (int i = 0;i<ba1.length; ++i) {
+ if (ba1[i]!=ba2[i])return false;
}
return true;
}
@@ -142,10 +142,10 @@ public class Hash {
public static int compareTo(byte[] a, byte[] b) {
int end = Math.min(a.length, b.length);
int compare = 0;
- for(int i=0;compare == 0 && i<end;++i) {
+ for (int i=0;compare == 0 && i<end;++i) {
compare = a[i]-b[i];
}
- if(compare==0)compare=a.length-b.length;
+ if (compare==0)compare=a.length-b.length;
return compare;
}
@@ -178,7 +178,7 @@ public class Hash {
public static byte[] fromHex(String s) throws CadiException{
- if(!s.startsWith("0x")) {
+ if (!s.startsWith("0x")) {
throw new CadiException("HexString must start with \"0x\"");
}
boolean high = true;
@@ -186,19 +186,19 @@ public class Hash {
byte b;
byte[] ba = new byte[(s.length()-2)/2];
int idx;
- for(int i=2;i<s.length();++i) {
+ for (int i=2;i<s.length();++i) {
c = s.charAt(i);
- if(c>=0x30 && c<=0x39) {
+ if (c>=0x30 && c<=0x39) {
b=(byte)(c-0x30);
- } else if(c>=0x61 && c<=0x66) {
+ } else if (c>=0x61 && c<=0x66) {
b=(byte)(c-0x57); // account for "A"
- } else if(c>=0x41 && c<=0x46) {
+ } else if (c>=0x41 && c<=0x46) {
b=(byte)(c-0x37);
} else {
throw new CadiException("Invalid char '" + c + "' in HexString");
}
idx = (i-2)/2;
- if(high) {
+ if (high) {
ba[idx]=(byte)(b<<4);
high = false;
} else {
@@ -222,7 +222,7 @@ public class Hash {
byte[] ba;
boolean high;
int start;
- if(s.length()%2==0) {
+ if (s.length()%2==0) {
ba = new byte[s.length()/2];
high=true;
start=0;
@@ -232,19 +232,19 @@ public class Hash {
start=1;
}
int idx;
- for(int i=start;i<s.length();++i) {
+ for (int i=start;i<s.length();++i) {
c = s.charAt((i-start));
- if(c>=0x30 && c<=0x39) {
+ if (c>=0x30 && c<=0x39) {
b=(byte)(c-0x30);
- } else if(c>=0x61 && c<=0x66) {
+ } else if (c>=0x61 && c<=0x66) {
b=(byte)(c-0x57); // account for "A"
- } else if(c>=0x41 && c<=0x46) {
+ } else if (c>=0x41 && c<=0x46) {
b=(byte)(c-0x37);
} else {
return null;
}
idx = i/2;
- if(high) {
+ if (high) {
ba[idx]=(byte)(b<<4);
high = false;
} else {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
index a35777f8..8467c7c6 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
@@ -89,8 +89,8 @@ public class PropAccess implements Access {
this.logIt = logIt;
Properties nprops=new Properties();
int eq;
- for(String arg : args) {
- if((eq=arg.indexOf('='))>0) {
+ for (String arg : args) {
+ if ((eq=arg.indexOf('='))>0) {
nprops.setProperty(arg.substring(0, eq),arg.substring(eq+1));
}
}
@@ -104,16 +104,16 @@ public class PropAccess implements Access {
props = new Properties();
// First, load related System Properties
- for(Entry<Object,Object> es : System.getProperties().entrySet()) {
+ for (Entry<Object,Object> es : System.getProperties().entrySet()) {
String key = es.getKey().toString();
- for(String start : new String[] {"cadi_","aaf_","cm_"}) {
- if(key.startsWith(start)) {
+ for (String start : new String[] {"cadi_","aaf_","cm_"}) {
+ if (key.startsWith(start)) {
props.put(key, es.getValue());
}
}
}
// Second, overlay or fill in with Passed in Props
- if(p!=null) {
+ if (p!=null) {
props.putAll(p);
}
@@ -121,11 +121,11 @@ public class PropAccess implements Access {
load(props.getProperty(Config.CADI_PROP_FILES));
String sLevel = props.getProperty(Config.CADI_LOGLEVEL);
- if(sLevel!=null) {
+ if (sLevel!=null) {
level=Level.valueOf(sLevel).maskOf();
}
// Setup local Symmetrical key encryption
- if(symm==null) {
+ if (symm==null) {
try {
symm = Symm.obtain(this);
} catch (CadiException e) {
@@ -142,18 +142,18 @@ public class PropAccess implements Access {
private void specialConversions() {
// Critical - if no Security Protocols set, then set it. We'll just get messed up if not
- if(props.get(Config.CADI_PROTOCOLS)==null) {
+ if (props.get(Config.CADI_PROTOCOLS)==null) {
props.setProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
}
Object temp;
temp=props.get(Config.CADI_PROTOCOLS);
- if(props.get(Config.HTTPS_PROTOCOLS)==null && temp!=null) {
+ if (props.get(Config.HTTPS_PROTOCOLS)==null && temp!=null) {
props.put(Config.HTTPS_PROTOCOLS, temp);
}
- if(temp!=null) {
- if("1.7".equals(System.getProperty("java.specification.version"))
+ if (temp!=null) {
+ if ("1.7".equals(System.getProperty("java.specification.version"))
&& (temp==null || (temp instanceof String && ((String)temp).contains("TLSv1.2")))) {
System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT);
}
@@ -161,20 +161,20 @@ public class PropAccess implements Access {
}
private void load(String cadi_prop_files) {
- if(cadi_prop_files==null) {
+ if (cadi_prop_files==null) {
return;
}
String prevKeyFile = props.getProperty(Config.CADI_KEYFILE);
int prev = 0, end = cadi_prop_files.length();
int idx;
String filename;
- while(prev<end) {
+ while (prev<end) {
idx = cadi_prop_files.indexOf(File.pathSeparatorChar,prev);
- if(idx<0) {
+ if (idx<0) {
idx = end;
}
File file = new File(filename=cadi_prop_files.substring(prev,idx));
- if(file.exists()) {
+ if (file.exists()) {
printf(Level.INIT,"Loading CADI Properties from %s",file.getAbsolutePath());
try {
FileInputStream fis = new FileInputStream(file);
@@ -182,12 +182,12 @@ public class PropAccess implements Access {
props.load(fis);
// Recursively Load
String chainProp = props.getProperty(Config.CADI_PROP_FILES);
- if(chainProp!=null) {
- if(recursionProtection==null) {
+ if (chainProp!=null) {
+ if (recursionProtection==null) {
recursionProtection = new ArrayList<>();
recursionProtection.add(cadi_prop_files);
}
- if(!recursionProtection.contains(chainProp)) {
+ if (!recursionProtection.contains(chainProp)) {
recursionProtection.add(chainProp);
load(chainProp); // recurse
}
@@ -205,23 +205,23 @@ public class PropAccess implements Access {
}
// Trim
- for(Entry<Object, Object> es : props.entrySet()) {
+ for (Entry<Object, Object> es : props.entrySet()) {
Object value = es.getValue();
- if(value instanceof String) {
+ if (value instanceof String) {
String trim = ((String)value).trim();
// Remove Beginning/End Quotes, which might be there if mixed with Bash Props
int s = 0, e=trim.length()-1;
- if(s<e && trim.charAt(s)=='"' && trim.charAt(e)=='"') {
+ if (s<e && trim.charAt(s)=='"' && trim.charAt(e)=='"') {
trim=trim.substring(s+1,e);
}
- if(trim!=value) { // Yes, I want OBJECT equals
+ if (trim!=value) { // Yes, I want OBJECT equals
props.setProperty((String)es.getKey(), trim);
}
}
}
// Reset Symm if Keyfile Changes:
String newKeyFile = props.getProperty(Config.CADI_KEYFILE);
- if((prevKeyFile!=null && newKeyFile!=null) || (newKeyFile!=null && !newKeyFile.equals(prevKeyFile))) {
+ if ((prevKeyFile!=null && newKeyFile!=null) || (newKeyFile!=null && !newKeyFile.equals(prevKeyFile))) {
try {
symm = Symm.obtain(this);
} catch (CadiException e) {
@@ -234,7 +234,7 @@ public class PropAccess implements Access {
}
String loglevel = props.getProperty(Config.CADI_LOGLEVEL);
- if(loglevel!=null) {
+ if (loglevel!=null) {
try {
level=Level.valueOf(loglevel).maskOf();
} catch (IllegalArgumentException e) {
@@ -253,7 +253,7 @@ public class PropAccess implements Access {
@Override
public void log(Level level, Object ... elements) {
- if(willLog(level)) {
+ if (willLog(level)) {
logIt.push(level,elements);
}
}
@@ -270,11 +270,11 @@ public class PropAccess implements Access {
sb.append(name);
int end = elements.length;
- if(end<=0) {
+ if (end<=0) {
sb.append("] ");
} else {
int idx = 0;
- if(elements[idx] instanceof Integer) {
+ if (elements[idx] instanceof Integer) {
sb.append('-');
sb.append(elements[idx]);
++idx;
@@ -282,14 +282,14 @@ public class PropAccess implements Access {
sb.append("] ");
String s;
boolean first = true;
- for(Object o : elements) {
- if(o!=null) {
+ for (Object o : elements) {
+ if (o!=null) {
s=o.toString();
- if(first) {
+ if (first) {
first = false;
} else {
int l = s.length();
- if(l>0) {
+ if (l>0) {
switch(s.charAt(l-1)) {
case ' ':
break;
@@ -313,7 +313,7 @@ public class PropAccess implements Access {
@Override
public void printf(Level level, String fmt, Object... elements) {
- if(willLog(level)) {
+ if (willLog(level)) {
log(level,String.format(fmt, elements));
}
}
@@ -362,9 +362,9 @@ public class PropAccess implements Access {
}
public void setProperty(String tag, String value) {
- if(value!=null) {
+ if (value!=null) {
props.put(tag, value);
- if(Config.CADI_KEYFILE.equals(tag)) {
+ if (Config.CADI_KEYFILE.equals(tag)) {
// reset decryption too
try {
symm = Symm.obtain(this);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/ServletContextAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/ServletContextAccess.java
index 518ea6dd..998b87c9 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/ServletContextAccess.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/ServletContextAccess.java
@@ -34,7 +34,7 @@ public class ServletContextAccess extends PropAccess {
super(filterConfig); // protected constructor... does not have "init" called.
context = filterConfig.getServletContext();
- for(Enumeration<?> en = filterConfig.getInitParameterNames();en.hasMoreElements();) {
+ for (Enumeration<?> en = filterConfig.getInitParameterNames();en.hasMoreElements();) {
String name = (String)en.nextElement();
setProperty(name, filterConfig.getInitParameter(name));
}
@@ -46,7 +46,7 @@ public class ServletContextAccess extends PropAccess {
*/
@Override
public void log(Level level, Object... elements) {
- if(willLog(level)) {
+ if (willLog(level)) {
StringBuilder sb = buildMsg(level, elements);
context.log(sb.toString());
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
index fd60b0c1..28af03cd 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
@@ -139,12 +139,12 @@ public class Symm {
// data (i.e. abcde...). Therefore, we'll quickly analyze the keyset. If it proves to have
// too much entropy, the "Unordered" algorithm, which is faster in such cases is used.
ArrayList<int[]> la = new ArrayList<>();
- for(int i=0;i<codeset.length;++i) {
+ for (int i=0;i<codeset.length;++i) {
curr = codeset[i];
- if(prev+1==curr) { // is next character in set
+ if (prev+1==curr) { // is next character in set
prev = curr;
} else {
- if(offset!=Integer.SIZE) { // add previous range
+ if (offset!=Integer.SIZE) { // add previous range
la.add(new int[]{first,prev,offset});
}
first = prev = curr;
@@ -152,7 +152,7 @@ public class Symm {
}
}
la.add(new int[]{first,curr,offset});
- if(la.size()>codeset.length/3) {
+ if (la.size()>codeset.length/3) {
convert = new Unordered(codeset);
} else { // too random to get speed enhancement from range algorithm
int[][] range = new int[la.size()][];
@@ -210,10 +210,10 @@ public class Symm {
public <T> T exec(SyncExec<T> exec) throws Exception {
synchronized(LOCK) {
- if(keyBytes == null) {
+ if (keyBytes == null) {
keyBytes = new byte[AES.AES_KEY_SIZE/8];
int offset = (Math.abs(codeset[0])+47)%(codeset.length-keyBytes.length);
- for(int i=0;i<keyBytes.length;++i) {
+ for (int i=0;i<keyBytes.length;++i) {
keyBytes[i] = (byte)codeset[i+offset];
}
}
@@ -231,7 +231,7 @@ public class Symm {
}
public byte[] encode(byte[] toEncrypt) throws IOException {
- if(toEncrypt==null) {
+ if (toEncrypt==null) {
return EMPTY;
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream((int)(toEncrypt.length*1.25));
@@ -344,8 +344,8 @@ public class Symm {
boolean go;
do {
read = is.read();
- if(go = read>=0) {
- if(line>=splitLinesAt) {
+ if (go = read>=0) {
+ if (line>=splitLinesAt) {
os.write('\n');
line = 0;
}
@@ -362,7 +362,7 @@ public class Symm {
// Char 1 is last 4 bits of prev plus the first 2 bits of read
// Char 2 is the last 6 bits of read
os.write(codeset[(((prev & 0xF)<<2) | (read>>6))]);
- if(line==splitLinesAt) { // deal with line splitting for two characters
+ if (line==splitLinesAt) { // deal with line splitting for two characters
os.write('\n');
line=0;
}
@@ -376,21 +376,21 @@ public class Symm {
switch(idx) {
case 1: // just the last 2 bits of prev
os.write(codeset[(prev & 0x03)<<4]);
- if(endEquals)os.write(DOUBLE_EQ);
+ if (endEquals)os.write(DOUBLE_EQ);
break;
case 2: // just the last 4 bits of prev
os.write(codeset[(prev & 0xF)<<2]);
- if(endEquals)os.write('=');
+ if (endEquals)os.write('=');
break;
}
idx = 0;
}
- } while(go);
+ } while (go);
}
public void decode(InputStream is, OutputStream os, int skip) throws IOException {
- if(is.skip(skip)!=skip) {
+ if (is.skip(skip)!=skip) {
throw new IOException("Error skipping on IOStream in Symm");
}
decode(is,os);
@@ -405,9 +405,9 @@ public class Symm {
public void decode(InputStream is, OutputStream os) throws IOException {
int read, idx=0;
int prev=0, index;
- while((read = is.read())>=0) {
+ while ((read = is.read())>=0) {
index = convert.convert(read);
- if(index>=0) {
+ if (index>=0) {
switch(++idx) { // 1 based cases, slightly faster ++
case 1: // index goes into first 6 bits of prev
prev = index<<2;
@@ -459,8 +459,8 @@ public class Symm {
case '\r':
return -1;
}
- for(int i=0;i<range.length;++i) {
- if(read >= range[i][0] && read<=range[i][1]) {
+ for (int i=0;i<range.length;++i) {
+ if (read >= range[i][0] && read<=range[i][1]) {
return read-range[i][2];
}
}
@@ -487,8 +487,8 @@ public class Symm {
case '\r':
return -1;
}
- for(int i=0;i<codec.length;++i) {
- if(codec[i]==read)return i;
+ for (int i=0;i<codec.length;++i) {
+ if (codec[i]==read)return i;
}
// don't give clue in Encryption mode
throw new IOException("Unacceptable Character in Stream");
@@ -519,7 +519,7 @@ public class Symm {
private Obtain(Symm b64, byte[] key) {
skip = Math.abs(key[key.length-13]%key.length);
- if((key.length&0x1) == (skip&0x1)) { // if both are odd or both are even
+ if ((key.length&0x1) == (skip&0x1)) { // if both are odd or both are even
++skip;
}
length = b64.codeset.length;
@@ -542,7 +542,7 @@ public class Symm {
*/
public static Symm obtain(Access access) throws CadiException {
String keyfile = access.getProperty(Config.CADI_KEYFILE,null);
- if(keyfile!=null) {
+ if (keyfile!=null) {
Symm symm = Symm.baseCrypt();
File file = new File(keyfile);
@@ -551,7 +551,7 @@ public class Symm {
} catch (IOException e1) {
access.log(Level.INIT, Config.CADI_KEYFILE,"points to",file.getAbsolutePath());
}
- if(file.exists()) {
+ if (file.exists()) {
try {
FileInputStream fis = new FileInputStream(file);
try {
@@ -619,7 +619,7 @@ public class Symm {
throw new IOException("Invalid Key");
}
byte[] bkey = baos.toByteArray();
- if(bkey.length<0x88) { // 2048 bit key
+ if (bkey.length<0x88) { // 2048 bit key
throw new IOException("Invalid key");
}
return baseCrypt().obtain(bkey);
@@ -663,37 +663,37 @@ public class Symm {
* @throws IOException
*/
public void enpass(final String password, final OutputStream os) throws IOException {
- if(password==null) {
+ if (password==null) {
throw new IOException("Invalid password passed");
}
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
byte[] bytes = password.getBytes();
- if(this.getClass().getSimpleName().startsWith("base64")) { // don't expose randomization
+ if (this.getClass().getSimpleName().startsWith("base64")) { // don't expose randomization
dos.write(bytes);
} else {
Random r = new SecureRandom();
int start = 0;
byte b;
- for(int i=0;i<3;++i) {
+ for (int i=0;i<3;++i) {
dos.writeByte(b=(byte)r.nextInt());
start+=Math.abs(b);
}
start%=0x7;
- for(int i=0;i<start;++i) {
+ for (int i=0;i<start;++i) {
dos.writeByte(r.nextInt());
}
dos.writeInt((int)System.currentTimeMillis());
int minlength = Math.min(0x9,bytes.length);
dos.writeByte(minlength); // expect truncation
- if(bytes.length<0x9) {
- for(int i=0;i<bytes.length;++i) {
+ if (bytes.length<0x9) {
+ for (int i=0;i<bytes.length;++i) {
dos.writeByte(r.nextInt());
dos.writeByte(bytes[i]);
}
// make sure it's long enough
- for(int i=bytes.length;i<0x9;++i) {
+ for (int i=bytes.length;i<0x9;++i) {
dos.writeByte(r.nextInt());
}
} else {
@@ -733,7 +733,7 @@ public class Symm {
* @throws IOException
*/
public String depass(String password) throws IOException {
- if(password==null)return null;
+ if (password==null)return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
depass(password,baos);
return new String(baos.toByteArray());
@@ -772,23 +772,23 @@ public class Symm {
byte[] bytes = baos.toByteArray();
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes));
long time;
- if(this.getClass().getSimpleName().startsWith("base64")) { // don't expose randomization
+ if (this.getClass().getSimpleName().startsWith("base64")) { // don't expose randomization
os.write(bytes);
time = 0L;
} else {
int start=0;
- for(int i=0;i<3;++i) {
+ for (int i=0;i<3;++i) {
start+=Math.abs(dis.readByte());
}
start%=0x7;
- for(int i=0;i<start;++i) {
+ for (int i=0;i<start;++i) {
dis.readByte();
}
time = (dis.readInt() & 0xFFFF)|(System.currentTimeMillis()&0xFFFF0000);
int minlength = dis.readByte();
- if(minlength<0x9){
+ if (minlength<0x9){
DataOutputStream dos = new DataOutputStream(os);
- for(int i=0;i<minlength;++i) {
+ for (int i=0;i<minlength;++i) {
dis.readByte();
dos.writeByte(dis.readByte());
}
@@ -807,7 +807,7 @@ public class Symm {
public static String randomGen(char[] chars ,int numBytes) {
int rint;
StringBuilder sb = new StringBuilder(numBytes);
- for(int i=0;i<numBytes;++i) {
+ for (int i=0;i<numBytes;++i) {
rint = random.nextInt(chars.length);
sb.append(chars[rint]);
}
@@ -829,14 +829,14 @@ public class Symm {
int index;
Obtain o = new Obtain(this,key);
- while(filled>=0) {
+ while (filled>=0) {
index = o.next();
- if(index<0 || index>=codeset.length) {
+ if (index<0 || index>=codeset.length) {
System.out.println("uh, oh");
}
- if(right) { // alternate going left or right to find the next open slot (keeps it from taking too long to hit something)
- for(int j=index;j<end;++j) {
- if(seq[j]==0) {
+ if (right) { // alternate going left or right to find the next open slot (keeps it from taking too long to hit something)
+ for (int j=index;j<end;++j) {
+ if (seq[j]==0) {
seq[j]=codeset[filled];
--filled;
break;
@@ -844,8 +844,8 @@ public class Symm {
}
right = false;
} else {
- for(int j=index;j>=0;--j) {
- if(seq[j]==0) {
+ for (int j=index;j>=0;--j) {
+ if (seq[j]==0) {
seq[j]=codeset[filled];
--filled;
break;
@@ -859,7 +859,7 @@ public class Symm {
try {
newSymm.keyBytes = new byte[AES.AES_KEY_SIZE/8];
int offset = (Math.abs(key[(47%key.length)])+137)%(key.length-newSymm.keyBytes.length);
- for(int i=0;i<newSymm.keyBytes.length;++i) {
+ for (int i=0;i<newSymm.keyBytes.length;++i) {
newSymm.keyBytes[i] = key[i+offset];
}
} catch (Exception e) {
@@ -876,7 +876,7 @@ public class Symm {
* @throws IOException
*/
public static synchronized Symm internalOnly() throws IOException {
- if(internalOnly==null) {
+ if (internalOnly==null) {
ByteArrayInputStream baos = new ByteArrayInputStream(keygen());
try {
internalOnly = Symm.obtain(baos);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
index 512f2e6a..4848e504 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
@@ -125,7 +125,7 @@ public final class User<PERM extends Permission> {
}
public void add(LocalPermission permission) {
- if(perms==NULL_MAP) {
+ if (perms==NULL_MAP) {
perms=newMap();
}
perms.put(permission.getKey(),permission);
@@ -157,8 +157,8 @@ public final class User<PERM extends Permission> {
sb.append('|');
boolean first = true;
synchronized(perms) {
- for(Permission gp : perms.values()) {
- if(first) {
+ for (Permission gp : perms.values()) {
+ if (first) {
first = false;
sb.append(':');
} else {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
index 4784d1ee..088227ed 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
@@ -233,9 +233,9 @@ public class Config {
/////////////////////////////////////////////////////
Class<?> aafConClass = loadClass(access,CADI_AAF_CON_DEF);
Object aafcon = null;
- if(con!=null && aafConClass!=null && aafConClass.isAssignableFrom(con.getClass())) {
+ if (con!=null && aafConClass!=null && aafConClass.isAssignableFrom(con.getClass())) {
aafcon = con;
- } else if(lur != null) {
+ } else if (lur != null) {
Field f;
try {
f = lur.getClass().getField("aaf");
@@ -248,14 +248,14 @@ public class Config {
boolean hasDirectAAF = hasDirect("DirectAAFLur",additionalTafLurs);
// IMPORTANT! Don't attempt to load AAF Connector if there is no AAF URL
String aafURL = access.getProperty(AAF_URL,null);
- if(!hasDirectAAF && aafcon==null && aafURL!=null) {
+ if (!hasDirectAAF && aafcon==null && aafURL!=null) {
aafcon = loadAAFConnector(si, aafURL);
}
HttpTaf taf;
// Setup Host, in case Network reports an unusable Hostname (i.e. VTiers, VPNs, etc)
String hostname = logProp(access, HOSTNAME,null);
- if(hostname==null) {
+ if (hostname==null) {
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e1) {
@@ -279,10 +279,10 @@ public class Config {
/////////////////////////////////////////////////////
X509Taf x509TAF = null;
String truststore = logProp(access, CADI_TRUSTSTORE,null);
- if(truststore!=null) {
+ if (truststore!=null) {
String truststorePwd = access.getProperty(CADI_TRUSTSTORE_PASSWORD,null);
- if(truststorePwd!=null) {
- if(truststorePwd.startsWith(Symm.ENC)) {
+ if (truststorePwd!=null) {
+ if (truststorePwd.startsWith(Symm.ENC)) {
try {
access.decrypt(truststorePwd,false);
} catch (IOException e) {
@@ -314,17 +314,17 @@ public class Config {
long userExp = Long.parseLong(aafCleanup);
boolean basicWarn = "TRUE".equals(access.getProperty(BASIC_WARN,"FALSE"));
- if(!hasDirectAAF) {
+ if (!hasDirectAAF) {
HttpTaf aaftaf=null;
- if(!hasOAuthDirectTAF) {
- if(basicRealm!=null) {
+ if (!hasOAuthDirectTAF) {
+ if (basicRealm!=null) {
@SuppressWarnings("unchecked")
Class<HttpTaf> obasicCls = (Class<HttpTaf>)loadClass(access,CADI_OBASIC_HTTP_TAF_DEF);
- if(obasicCls!=null) {
+ if (obasicCls!=null) {
try {
String tokenurl = logProp(access,Config.AAF_OAUTH2_TOKEN_URL, null);
String introspecturl = logProp(access,Config.AAF_OAUTH2_INTROSPECT_URL, null);
- if(tokenurl==null || introspecturl==null) {
+ if (tokenurl==null || introspecturl==null) {
access.log(Level.INIT,"Both tokenurl and introspecturl are required. Oauth Authorization is disabled.");
}
Constructor<HttpTaf> obasicConst = obasicCls.getConstructor(PropAccess.class,String.class, String.class, String.class);
@@ -333,20 +333,20 @@ public class Config {
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
access.log(Level.INIT, e);
}
- } else if(up!=null) {
+ } else if (up!=null) {
access.log(Level.INIT,"Basic Authorization is enabled using realm",basicRealm);
// Allow warning about insecure channel to be turned off
- if(!basicWarn) {
+ if (!basicWarn) {
access.log(Level.INIT, "WARNING! The basicWarn property has been set to false.",
" There will be no additional warning if Basic Auth is used on an insecure channel");
}
BasicHttpTaf bht = new BasicHttpTaf(access, up, basicRealm, userExp, basicWarn);
- for(Object o : additionalTafLurs) {
- if(o instanceof CredValDomain) {
+ for (Object o : additionalTafLurs) {
+ if (o instanceof CredValDomain) {
bht.add((CredValDomain)o);
}
}
- if(x509TAF!=null) {
+ if (x509TAF!=null) {
x509TAF.add(bht);
}
htlist.add(bht);
@@ -359,28 +359,28 @@ public class Config {
/////////////////////////////////////////////////////
// Configure AAF Driven Basic Auth
/////////////////////////////////////////////////////
- if(aafcon==null) {
+ if (aafcon==null) {
access.log(Level.INIT,"AAF Connection (AAFcon) is null. Cannot create an AAF TAF");
- } else if(aafURL==null) {
+ } else if (aafURL==null) {
access.log(Level.INIT,"No AAF URL in properties, Cannot create an AAF TAF");
} else {// There's an AAF_URL... try to configure an AAF
String aafTafClassName = logProp(access, AAF_TAF_CLASS,AAF_TAF_CLASS_DEF);
// Only 2.0 available at this time
- if(AAF_TAF_CLASS_DEF.equals(aafTafClassName)) {
+ if (AAF_TAF_CLASS_DEF.equals(aafTafClassName)) {
try {
Class<?> aafTafClass = loadClass(access,aafTafClassName);
- if(aafTafClass!=null) {
+ if (aafTafClass!=null) {
Constructor<?> cstr = aafTafClass.getConstructor(Connector.class,boolean.class,AbsUserCache.class);
- if(cstr!=null) {
- if(lur instanceof AbsUserCache) {
+ if (cstr!=null) {
+ if (lur instanceof AbsUserCache) {
aaftaf = (HttpTaf)cstr.newInstance(aafcon,basicWarn,lur);
} else {
cstr = aafTafClass.getConstructor(Connector.class,boolean.class);
- if(cstr!=null) {
+ if (cstr!=null) {
aaftaf = (HttpTaf)cstr.newInstance(aafcon,basicWarn);
}
}
- if(aaftaf==null) {
+ if (aaftaf==null) {
access.log(Level.INIT,"ERROR! AAF TAF Failed construction. NOT Configured");
} else {
access.log(Level.INIT,"AAF TAF Configured to ",aafURL);
@@ -390,7 +390,7 @@ public class Config {
} else {
access.log(Level.INIT, "There is no AAF TAF class available: %s. AAF TAF not configured.",aafTafClassName);
}
- } catch(Exception e) {
+ } catch (Exception e) {
access.log(Level.INIT,"ERROR! AAF TAF Failed construction. NOT Configured",e);
}
}
@@ -400,7 +400,7 @@ public class Config {
/////////////////////////////////////////////////////
// Configure OAuth TAF
/////////////////////////////////////////////////////
- if(!hasOAuthDirectTAF) {
+ if (!hasOAuthDirectTAF) {
String oauthTokenUrl = logProp(access,Config.AAF_OAUTH2_TOKEN_URL,null);
Class<?> oadtClss;
try {
@@ -409,21 +409,21 @@ public class Config {
oadtClss = null;
access.log(Level.INIT, e1);
}
- if(additionalTafLurs!=null && additionalTafLurs.length>0 && (oadtClss!=null && additionalTafLurs[0].getClass().isAssignableFrom(oadtClss))) {
+ if (additionalTafLurs!=null && additionalTafLurs.length>0 && (oadtClss!=null && additionalTafLurs[0].getClass().isAssignableFrom(oadtClss))) {
htlist.add((HttpTaf)additionalTafLurs[0]);
String[] array= new String[additionalTafLurs.length-1];
- if(array.length>0) {
+ if (array.length>0) {
System.arraycopy(htlist, 1, array, 0, array.length);
}
additionalTafLurs = array;
access.log(Level.INIT,"OAuth2 Direct is enabled");
- } else if(oauthTokenUrl!=null) {
+ } else if (oauthTokenUrl!=null) {
String oauthIntrospectUrl = logProp(access,Config.AAF_OAUTH2_INTROSPECT_URL,null);
@SuppressWarnings("unchecked")
Class<HttpTaf> oaTCls = (Class<HttpTaf>)loadClass(access,OAUTH_HTTP_TAF);
- if(oaTCls!=null) {
+ if (oaTCls!=null) {
Class<?> oaTTmgrCls = loadClass(access, OAUTH_TOKEN_MGR);
- if(oaTTmgrCls!=null) {
+ if (oaTTmgrCls!=null) {
try {
Method oaTTmgrGI = oaTTmgrCls.getMethod("getInstance",PropAccess.class,String.class,String.class);
Object oaTTmgr = oaTTmgrGI.invoke(null /*this is static method*/,access,oauthTokenUrl,oauthIntrospectUrl);
@@ -444,7 +444,7 @@ public class Config {
// Adding BasicAuth (AAF) last, after other primary Cookie Based
// Needs to be before Cert... see below
/////////////////////////////////////////////////////
- if(aaftaf!=null) {
+ if (aaftaf!=null) {
htlist.add(aaftaf);
}
}
@@ -452,22 +452,22 @@ public class Config {
/////////////////////////////////////////////////////
// Any Additional Lurs passed in Constructor
/////////////////////////////////////////////////////
- if(additionalTafLurs!=null) {
- for(Object additional : additionalTafLurs) {
- if(additional instanceof BasicHttpTaf) {
+ if (additionalTafLurs!=null) {
+ for (Object additional : additionalTafLurs) {
+ if (additional instanceof BasicHttpTaf) {
BasicHttpTaf ht = (BasicHttpTaf)additional;
- for(Object cv : additionalTafLurs) {
- if(cv instanceof CredValDomain) {
+ for (Object cv : additionalTafLurs) {
+ if (cv instanceof CredValDomain) {
ht.add((CredValDomain)cv);
access.printf(Level.INIT,"%s Authentication is enabled",cv);
}
}
htlist.add(ht);
- } else if(additional instanceof HttpTaf) {
+ } else if (additional instanceof HttpTaf) {
HttpTaf ht = (HttpTaf)additional;
htlist.add(ht);
access.printf(Level.INIT,"%s Authentication is enabled",additional.getClass().getSimpleName());
- } else if(hasOAuthDirectTAF) {
+ } else if (hasOAuthDirectTAF) {
Class<?> daupCls;
try {
daupCls = Class.forName("org.onap.aaf.auth.direct.DirectAAFUserPass");
@@ -475,7 +475,7 @@ public class Config {
daupCls = null;
access.log(Level.INIT, e);
}
- if(daupCls != null && additional.getClass().isAssignableFrom(daupCls)) {
+ if (daupCls != null && additional.getClass().isAssignableFrom(daupCls)) {
htlist.add(new BasicHttpTaf(access, (CredVal)additional , basicRealm, userExp, basicWarn));
access.printf(Level.INIT,"Direct BasicAuth Authentication is enabled",additional.getClass().getSimpleName());
}
@@ -484,9 +484,9 @@ public class Config {
}
// Add BasicAuth, if any, to x509Taf
- if(x509TAF!=null) {
- for( HttpTaf ht : htlist) {
- if(ht instanceof BasicHttpTaf) {
+ if (x509TAF!=null) {
+ for ( HttpTaf ht : htlist) {
+ if (ht instanceof BasicHttpTaf) {
x509TAF.add((BasicHttpTaf)ht);
}
}
@@ -494,7 +494,7 @@ public class Config {
/////////////////////////////////////////////////////
// Create EpiTaf from configured TAFs
/////////////////////////////////////////////////////
- if(htlist.size()==1) {
+ if (htlist.size()==1) {
// just return the one
taf = htlist.get(0);
} else {
@@ -504,7 +504,7 @@ public class Config {
taf = new HttpEpiTaf(access,locator, tc, htarray); // ok to pass locator == null
String level = logProp(access, CADI_LOGLEVEL, null);
- if(level!=null) {
+ if (level!=null) {
access.setLogLevel(Level.valueOf(level));
}
}
@@ -514,7 +514,7 @@ public class Config {
public static String logProp(Access access,String tag, String def) {
String rv = access.getProperty(tag, def);
- if(rv == null) {
+ if (rv == null) {
access.log(Level.INIT,tag,"is not explicitly set");
} else {
access.log(Level.INIT,tag,"is set to",rv);
@@ -533,14 +533,14 @@ public class Config {
String users = access.getProperty(USERS,null);
String groups = access.getProperty(GROUPS,null);
- if(groups!=null || users!=null) {
+ if (groups!=null || users!=null) {
LocalLur ll = new LocalLur(access, users, groups); // note b64==null is ok.. just means no encryption.
lurs.add(ll);
String writeto = access.getProperty(WRITE_TO,null);
- if(writeto!=null) {
+ if (writeto!=null) {
String msg = UsersDump.updateUsers(writeto, ll);
- if(msg!=null) {
+ if (msg!=null) {
access.log(Level.INIT,"ERROR! Error Updating ",writeto,"with roles and users:",msg);
}
}
@@ -554,10 +554,10 @@ public class Config {
/////////////////////////////////////////////////////
String tokenUrl = logProp(access,AAF_OAUTH2_TOKEN_URL, null);
String introspectUrl = logProp(access,AAF_OAUTH2_INTROSPECT_URL, null);
- if(tokenUrl!=null && introspectUrl !=null) {
+ if (tokenUrl!=null && introspectUrl !=null) {
try {
Class<?> olurCls = loadClass(access, CADI_OLUR_CLASS_DEF);
- if(olurCls!=null) {
+ if (olurCls!=null) {
Constructor<?> olurCnst = olurCls.getConstructor(PropAccess.class,String.class,String.class);
Lur olur = (Lur)olurCnst.newInstance(access,tokenUrl,introspectUrl);
lurs.add(olur);
@@ -567,7 +567,7 @@ public class Config {
}
} catch (NoSuchMethodException| SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
String msg = e.getMessage();
- if(msg==null && e.getCause()!=null) {
+ if (msg==null && e.getCause()!=null) {
msg = e.getCause().getMessage();
}
access.log(Level.INIT,"AAF/OAuth LUR is not instantiated.",msg,e);
@@ -576,7 +576,7 @@ public class Config {
access.log(Level.INIT, "OAuth2 Lur disabled");
}
- if(con!=null) { // try to reutilize connector
+ if (con!=null) { // try to reutilize connector
lurs.add(con.newLur());
} else {
/////////////////////////////////////////////////////
@@ -584,12 +584,12 @@ public class Config {
/////////////////////////////////////////////////////
String aafURL = logProp(access,AAF_URL,null); // Trigger Property
String aafEnv = access.getProperty(AAF_ENV,null);
- if(aafEnv == null && aafURL!=null && access instanceof PropAccess) { // set AAF_ENV from AAF_URL
+ if (aafEnv == null && aafURL!=null && access instanceof PropAccess) { // set AAF_ENV from AAF_URL
int ec = aafURL.indexOf("envContext=");
- if(ec>0) {
+ if (ec>0) {
ec += 11; // length of envContext=
int slash = aafURL.indexOf('/', ec);
- if(slash>0) {
+ if (slash>0) {
aafEnv = aafURL.substring(ec, slash);
((PropAccess)access).setProperty(AAF_ENV, aafEnv);
access.printf(Level.INIT, "Setting aafEnv to %s from aaf_url value",aafEnv);
@@ -598,30 +598,30 @@ public class Config {
}
// Don't configure AAF if it is using DirectAccess
- if(!hasDirect("DirectAAFLur",additionalTafLurs)) {
- if(aafURL==null) {
+ if (!hasDirect("DirectAAFLur",additionalTafLurs)) {
+ if (aafURL==null) {
access.log(Level.INIT,"No AAF LUR properties, AAF will not be loaded");
} else {// There's an AAF_URL... try to configure an AAF
String aafLurClassStr = logProp(access,AAF_LUR_CLASS,AAF_V2_0_AAF_LUR_PERM);
////////////AAF Lur 2.0 /////////////
- if(aafLurClassStr!=null && aafLurClassStr.startsWith(AAF_V2_0)) {
+ if (aafLurClassStr!=null && aafLurClassStr.startsWith(AAF_V2_0)) {
try {
Object aafcon = loadAAFConnector(si, aafURL);
- if(aafcon==null) {
+ if (aafcon==null) {
access.log(Level.INIT,"AAF LUR class,",aafLurClassStr,"cannot be constructed without valid AAFCon object.");
} else {
Class<?> aafAbsAAFCon = loadClass(access, AAF_V2_0_AAFCON);
- if(aafAbsAAFCon!=null) {
+ if (aafAbsAAFCon!=null) {
Method mNewLur = aafAbsAAFCon.getMethod("newLur");
Object aaflur = mNewLur.invoke(aafcon);
- if(aaflur==null) {
+ if (aaflur==null) {
access.log(Level.INIT,"ERROR! AAF LUR Failed construction. NOT Configured");
} else {
access.log(Level.INIT,"AAF LUR Configured to ",aafURL);
lurs.add((Lur)aaflur);
String debugIDs = logProp(access,Config.AAF_DEBUG_IDS, null);
- if(debugIDs !=null && aaflur instanceof CachingLur) {
+ if (debugIDs !=null && aaflur instanceof CachingLur) {
((CachingLur<?>)aaflur).setDebug(debugIDs);
}
}
@@ -638,9 +638,9 @@ public class Config {
/////////////////////////////////////////////////////
// Any Additional passed in Constructor
/////////////////////////////////////////////////////
- if(additionalTafLurs!=null) {
- for(Object additional : additionalTafLurs) {
- if(additional instanceof Lur) {
+ if (additionalTafLurs!=null) {
+ for (Object additional : additionalTafLurs) {
+ if (additional instanceof Lur) {
lurs.add((Lur)additional);
access.log(Level.INIT, additional);
}
@@ -666,9 +666,9 @@ public class Config {
}
private static boolean hasDirect(String simpleClassName, Object[] additionalTafLurs) {
- if(additionalTafLurs!=null) {
- for(Object tf : additionalTafLurs) {
- if(tf.getClass().getSimpleName().equals(simpleClassName)) {
+ if (additionalTafLurs!=null) {
+ for (Object tf : additionalTafLurs) {
+ if (tf.getClass().getSimpleName().equals(simpleClassName)) {
return true;
}
}
@@ -746,15 +746,15 @@ public class Config {
public static Locator<URI> loadLocator(SecurityInfoC<HttpURLConnection> si, final String _url) throws LocatorException {
Access access = si.access;
Locator<URI> locator = null;
- if(_url==null) {
+ if (_url==null) {
access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled");
} else {
String url = _url;
String replacement;
int idxAAFLocateUrl;
- if((idxAAFLocateUrl=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
+ if ((idxAAFLocateUrl=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
StringBuilder sb = new StringBuilder(replacement);
- if(!replacement.endsWith("/locate")) {
+ if (!replacement.endsWith("/locate")) {
sb.append("/locate");
}
sb.append(_url,idxAAFLocateUrl+AAF_LOCATE_URL_TAG.length(),_url.length());
@@ -763,7 +763,7 @@ public class Config {
try {
Class<?> lcls = loadClass(access,AAF_LOCATOR_CLASS_DEF);
- if(lcls==null) {
+ if (lcls==null) {
throw new CadiException("Need to include aaf-cadi-aaf jar for AAFLocator");
}
// First check for preloaded
@@ -773,7 +773,7 @@ public class Config {
} catch (Exception e) {
access.log(Level.INIT, e);
}
- if(locator==null) {
+ if (locator==null) {
URI locatorURI = new URI(url);
Constructor<?> cnst = lcls.getConstructor(SecurityInfoC.class,URI.class);
locator = (Locator<URI>)cnst.newInstance(new Object[] {si,locatorURI});
@@ -785,7 +785,7 @@ public class Config {
access.log(Level.INFO, "AAFLocator enabled using preloaded " + locator.getClass().getSimpleName());
}
} catch (InvocationTargetException e) {
- if(e.getTargetException() instanceof LocatorException) {
+ if (e.getTargetException() instanceof LocatorException) {
throw (LocatorException)e.getTargetException();
}
access.log(Level.INIT,e.getTargetException().getMessage(),"AAFLocator for",url,"could not be created.",e);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Get.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Get.java
index 56ac4dd5..b48dd74d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Get.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Get.java
@@ -59,7 +59,7 @@ public interface Get {
}
// Take def if nothing else
- if(str==null) {
+ if (str==null) {
str = def;
// don't log defaults
} else {
@@ -83,8 +83,8 @@ public interface Get {
}
public String get(String name, String def, boolean print) {
String gotten = access.getProperty(name, def);
- if(print) {
- if(gotten == null) {
+ if (print) {
+ if (gotten == null) {
access.log(Level.INIT,name, "is not set");
} else {
access.log(Level.INIT,name, "is set to", gotten);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/GetAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/GetAccess.java
index 4655dfa1..30adcc97 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/GetAccess.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/GetAccess.java
@@ -38,7 +38,7 @@ public class GetAccess extends PropAccess {
public String getProperty(String tag, String def) {
String rv;
rv = super.getProperty(tag, null);
- if(rv==null && getter!=null) {
+ if (rv==null && getter!=null) {
rv = getter.get(tag, null, true);
}
return rv==null?def:rv;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/MultiGet.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/MultiGet.java
index a73df14e..c5e5a50e 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/MultiGet.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/MultiGet.java
@@ -31,9 +31,9 @@ public class MultiGet implements Get {
@Override
public String get(String name, String def, boolean print) {
String str;
- for(Get getter : getters) {
+ for (Get getter : getters) {
str = getter.get(name, null, print);
- if(str!=null)
+ if (str!=null)
return str;
}
return def;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
index 45e1dd1c..4e365fba 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfoC.java
@@ -44,7 +44,7 @@ public class SecurityInfoC<CLIENT> extends SecurityInfo {
@SuppressWarnings("unchecked")
public static synchronized <CLIENT> SecurityInfoC<CLIENT> instance(Access access, Class<CLIENT> cls) throws CadiException {
SecurityInfoInit<CLIENT> sii;
- if(cls.isAssignableFrom(HttpURLConnection.class)) {
+ if (cls.isAssignableFrom(HttpURLConnection.class)) {
try {
@SuppressWarnings("rawtypes")
Class<SecurityInfoInit> initCls = (Class<SecurityInfoInit>)Class.forName("org.onap.aaf.cadi.http.HSecurityInfoInit");
@@ -62,7 +62,7 @@ public class SecurityInfoC<CLIENT> extends SecurityInfo {
}
SecurityInfoC<CLIENT> sic = (SecurityInfoC<CLIENT>) sicMap.get(cls);
- if(sic==null) {
+ if (sic==null) {
sic = new SecurityInfoC<CLIENT>(access);
sic.set(sii.bestDefault(sic));
sicMap.put(cls, sic);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
index de25cb7f..98ab4706 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
@@ -41,7 +41,7 @@ public class UsersDump {
*/
public static boolean write(OutputStream os, AbsUserCache<?> lur) {
PrintStream ps;
- if(os instanceof PrintStream) {
+ if (os instanceof PrintStream) {
ps = (PrintStream)os;
} else {
ps = new PrintStream(os);
@@ -59,14 +59,14 @@ public class UsersDump {
// Obtain all unique role names
HashSet<String> groups = new HashSet<>();
- for(AbsUserCache<?>.DumpInfo di : lur.dumpInfo()) {
+ for (AbsUserCache<?>.DumpInfo di : lur.dumpInfo()) {
sb.append("\n <user username=\"");
sb.append(di.user);
sb.append("\" roles=\"");
boolean first = true;
- for(String role : di.perms) {
+ for (String role : di.perms) {
groups.add(role);
- if(first)first = false;
+ if (first)first = false;
else sb.append(',');
sb.append(role);
}
@@ -75,7 +75,7 @@ public class UsersDump {
}
// Print roles
- for(String group : groups) {
+ for (String group : groups) {
ps.print(" <role rolename=\"");
ps.print(group);
ps.println("\"/>");
@@ -104,15 +104,15 @@ public class UsersDump {
*/
public static String updateUsers(String writeto, LocalLur up) {
// Dump a Tomcat-user.xml lookalike (anywhere)
- if(writeto!=null) {
+ if (writeto!=null) {
// First read content
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- if(UsersDump.write(baos, up)) {
+ if (UsersDump.write(baos, up)) {
byte[] postulate = baos.toByteArray();
// now get contents of file
File file = new File(writeto);
boolean writeIt;
- if(file.exists()) {
+ if (file.exists()) {
try {
FileInputStream fis = new FileInputStream(file);
byte[] orig = new byte[(int)file.length()];
@@ -122,17 +122,17 @@ public class UsersDump {
} finally {
fis.close();
}
- if(read<=0) {
+ if (read<=0) {
writeIt = false;
} else {
// Starting at third "<" (<tomcat-users> line)
int startA=0, startB=0;
- for(int i=0;startA<orig.length && i<3;++startA) if(orig[startA]=='<')++i;
- for(int i=0;startB<orig.length && i<3;++startB) if(postulate[startB]=='<')++i;
+ for (int i=0;startA<orig.length && i<3;++startA) if (orig[startA]=='<')++i;
+ for (int i=0;startB<orig.length && i<3;++startB) if (postulate[startB]=='<')++i;
writeIt=orig.length-startA!=postulate.length-startB; // first, check if remaining length is the same
- while(!writeIt && startA<orig.length && startB<postulate.length) {
- if(orig[startA++]!=postulate[startB++])writeIt = true;
+ while (!writeIt && startA<orig.length && startB<postulate.length) {
+ if (orig[startA++]!=postulate[startB++])writeIt = true;
}
}
} catch (Exception e) {
@@ -142,7 +142,7 @@ public class UsersDump {
writeIt = true;
}
- if(writeIt) {
+ if (writeIt) {
try {
FileOutputStream fos = new FileOutputStream(file);
try {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
index affb8f96..cd48556b 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
@@ -113,7 +113,7 @@ public class CadiFilter implements Filter {
public CadiFilter(boolean init, PropAccess access, Object ... moreTafLurs) throws ServletException {
this.access = access;
additionalTafLurs = moreTafLurs;
- if(init) {
+ if (init) {
init(new AccessGetter(access));
}
}
@@ -129,7 +129,7 @@ public class CadiFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
// need the Context for Logging, instantiating ClassLoader, etc
ServletContextAccess sca=new ServletContextAccess(filterConfig);
- if(access==null) {
+ if (access==null) {
access = sca;
}
@@ -144,9 +144,9 @@ public class CadiFilter implements Filter {
TrustChecker tc = TrustChecker.NOTRUST; // default position
try {
Class<TrustChecker> ctc = (Class<TrustChecker>) Class.forName("org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker");
- if(ctc!=null) {
+ if (ctc!=null) {
Constructor<TrustChecker> contc = ctc.getConstructor(Access.class);
- if(contc!=null) {
+ if (contc!=null) {
tc = contc.newInstance(access);
}
}
@@ -184,8 +184,8 @@ public class CadiFilter implements Filter {
// In this case, the epiTaf will be changed to a non-NullTaf, and thus not instantiate twice.
synchronized(CadiHTTPManip.noAdditional /*will always remain same Object*/) {
++count;
- if(httpChecker == null) {
- if(access==null) {
+ if (httpChecker == null) {
+ if (access==null) {
access = new PropAccess();
}
try {
@@ -193,16 +193,16 @@ public class CadiFilter implements Filter {
} catch (CadiException | LocatorException e1) {
throw new ServletException(e1);
}
- } else if(access==null) {
+ } else if (access==null) {
access= httpChecker.getAccess();
}
/*
* Setup Authn Path Exceptions
*/
- if(pathExceptions==null) {
+ if (pathExceptions==null) {
String str = getter.get(Config.CADI_NOAUTHN, null, true);
- if(str!=null) {
+ if (str!=null) {
pathExceptions = str.split("\\s*:\\s*");
}
}
@@ -210,22 +210,22 @@ public class CadiFilter implements Filter {
/*
* SETUP Permission Converters... those that can take Strings from a Vendor Product, and convert to appropriate AAF Permissions
*/
- if(mapPairs==null) {
+ if (mapPairs==null) {
String str = getter.get(Config.AAF_PERM_MAP, null, true);
- if(str!=null) {
+ if (str!=null) {
String mstr = getter.get(Config.AAF_PERM_MAP, null, true);
- if(mstr!=null) {
+ if (mstr!=null) {
String map[] = mstr.split("\\s*:\\s*");
- if(map.length>0) {
+ if (map.length>0) {
MapPermConverter mpc=null;
int idx;
mapPairs = new ArrayList<>();
- for(String entry : map) {
- if((idx=entry.indexOf('='))<0) { // it's a Path, so create a new converter
+ for (String entry : map) {
+ if ((idx=entry.indexOf('='))<0) { // it's a Path, so create a new converter
access.log(Level.INIT,"Loading Perm Conversions for:",entry);
mapPairs.add(new Pair(entry,mpc=new MapPermConverter()));
} else {
- if(mpc!=null) {
+ if (mpc!=null) {
mpc.map().put(entry.substring(0,idx),entry.substring(idx+1));
} else {
access.log(Level.ERROR,"cadi_perm_map is malformed; ",entry, "is skipped");
@@ -248,7 +248,7 @@ public class CadiFilter implements Filter {
public void destroy() {
// Synchronize, in case multiCadiFilters are used.
synchronized(CadiHTTPManip.noAdditional) {
- if(--count<=0 && httpChecker!=null) {
+ if (--count<=0 && httpChecker!=null) {
httpChecker.destroy();
httpChecker=null;
access=null;
@@ -272,7 +272,7 @@ public class CadiFilter implements Filter {
String tag = "";
try {
HttpServletRequest hreq = (HttpServletRequest)request;
- if(noAuthn(hreq)) {
+ if (noAuthn(hreq)) {
startCode=System.nanoTime();
chain.doFilter(request, response);
code = Timing.millis(startCode);
@@ -281,11 +281,11 @@ public class CadiFilter implements Filter {
startValidate=System.nanoTime();
TafResp tresp = httpChecker.validate(hreq, hresp, hreq);
validate = Timing.millis(startValidate);
- if(tresp.isAuthenticated()==RESP.IS_AUTHENTICATED) {
+ if (tresp.isAuthenticated()==RESP.IS_AUTHENTICATED) {
user = tresp.getPrincipal().personalName();
tag = tresp.getPrincipal().tag();
CadiWrap cw = new CadiWrap(hreq, tresp, httpChecker.getLur(),getConverter(hreq));
- if(httpChecker.notCadi(cw, hresp)) {
+ if (httpChecker.notCadi(cw, hresp)) {
startCode=System.nanoTime();
oauthFilter.doFilter(cw,response,chain);
code = Timing.millis(startCode);
@@ -308,11 +308,11 @@ public class CadiFilter implements Filter {
* @return
*/
private boolean noAuthn(HttpServletRequest hreq) {
- if(pathExceptions!=null) {
+ if (pathExceptions!=null) {
String pi = hreq.getPathInfo();
- if(pi==null) return false; // JBoss sometimes leaves null
- for(String pe : pathExceptions) {
- if(pi.startsWith(pe))return true;
+ if (pi==null) return false; // JBoss sometimes leaves null
+ for (String pe : pathExceptions) {
+ if (pi.startsWith(pe))return true;
}
}
return false;
@@ -322,11 +322,11 @@ public class CadiFilter implements Filter {
* Get Converter by Path
*/
private PermConverter getConverter(HttpServletRequest hreq) {
- if(mapPairs!=null) {
+ if (mapPairs!=null) {
String pi = hreq.getPathInfo();
- if(pi !=null) {
- for(Pair p: mapPairs) {
- if(pi.startsWith(p.name))return p.pc;
+ if (pi !=null) {
+ for (Pair p: mapPairs) {
+ if (pi.startsWith(p.name))return p.pc;
}
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
index 3c0f139b..bab758ec 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
@@ -78,18 +78,18 @@ public class CadiHTTPManip {
Config.setDefaultRealm(access);
aaf_id = access.getProperty(Config.CADI_ALIAS,access.getProperty(Config.AAF_APPID, null));
- if(aaf_id==null) {
+ if (aaf_id==null) {
access.printf(Level.INIT, "%s is not set. %s can be used instead",Config.AAF_APPID,Config.CADI_ALIAS);
} else {
access.printf(Level.INIT, "%s is set to %s",Config.AAF_APPID,aaf_id);
}
String ns = aaf_id==null?null:UserChainManip.idToNS(aaf_id);
- if(ns!=null) {
+ if (ns!=null) {
thisPerm = ns+ACCESS_CADI_CONTROL;
int dot = ns.indexOf('.');
- if(dot>=0) {
+ if (dot>=0) {
int dot2=ns.indexOf('.',dot+1);
- if(dot2<0) {
+ if (dot2<0) {
dot2=dot;
}
companyPerm = ns.substring(0, dot2)+ACCESS_CADI_CONTROL;
@@ -105,9 +105,9 @@ public class CadiHTTPManip {
lur = Config.configLur(si, con, additionalTafLurs);
tc.setLur(lur);
- if(lur instanceof EpiLur) {
+ if (lur instanceof EpiLur) {
up = ((EpiLur)lur).getUserPassImpl();
- } else if(lur instanceof CredVal) {
+ } else if (lur instanceof CredVal) {
up = (CredVal)lur;
} else {
up = null;
@@ -160,20 +160,20 @@ public class CadiHTTPManip {
public boolean notCadi(CadiWrap req, HttpServletResponse resp) {
String pathInfo = req.getPathInfo();
- if(METH.equalsIgnoreCase(req.getMethod()) && pathInfo!=null && pathInfo.contains(CADI)) {
- if(req.getUser().equals(aaf_id) || req.isUserInRole(thisPerm) || req.isUserInRole(companyPerm)) {
+ if (METH.equalsIgnoreCase(req.getMethod()) && pathInfo!=null && pathInfo.contains(CADI)) {
+ if (req.getUser().equals(aaf_id) || req.isUserInRole(thisPerm) || req.isUserInRole(companyPerm)) {
try {
- if(pathInfo.contains(CADI_CACHE_PRINT)) {
+ if (pathInfo.contains(CADI_CACHE_PRINT)) {
resp.getOutputStream().println(lur.toString());
resp.setStatus(200);
return false;
- } else if(pathInfo.contains(CADI_CACHE_CLEAR)) {
+ } else if (pathInfo.contains(CADI_CACHE_CLEAR)) {
StringBuilder report = new StringBuilder();
lur.clear(req.getUserPrincipal(), report);
resp.getOutputStream().println(report.toString());
resp.setStatus(200);
return false;
- } else if(pathInfo.contains(CADI_LOG_SET)) {
+ } else if (pathInfo.contains(CADI_LOG_SET)) {
Level l;
int slash = pathInfo.lastIndexOf('/');
String level = pathInfo.substring(slash+1);
@@ -200,7 +200,7 @@ public class CadiHTTPManip {
public void destroy() {
access.log(Level.INFO,"CadiHttpChecker destroyed.");
- if(lur!=null) {
+ if (lur!=null) {
lur.destroy();
lur=null;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
index f56cbf27..cf7c922d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
@@ -49,25 +49,25 @@ class FCGet implements Get {
public String get(String name, String def, boolean print) {
String str = null;
// Try Server Context First
- if(context!=null) {
+ if (context!=null) {
str = context.getInitParameter(name);
}
// Try Filter Context next
- if(str==null && filterConfig != null) {
+ if (str==null && filterConfig != null) {
str = filterConfig.getInitParameter(name);
}
- if(str==null) {
+ if (str==null) {
str = access.getProperty(name, def);
}
// Take def if nothing else
- if(str==null) {
+ if (str==null) {
str = def;
// don't log defaults
} else {
str = str.trim(); // this is vital in Property File based values, as spaces can hide easily
- if(print) {
+ if (print) {
access.log(Level.INFO,"Setting", name, "to", str);
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/ConfigPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/ConfigPrincipal.java
index c1b477b1..a41c5eb7 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/ConfigPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/ConfigPrincipal.java
@@ -57,10 +57,10 @@ public class ConfigPrincipal implements Principal, GetCred {
}
public String getAsBasicAuthHeader() throws IOException {
- if(content ==null) {
+ if (content ==null) {
String s = name + ':' + new String(cred);
content = "Basic " + Symm.base64.encode(s);
- } else if(!content.startsWith("Basic ")) { // content is the saved password from construction
+ } else if (!content.startsWith("Basic ")) { // content is the saved password from construction
String s = name + ':' + content;
content = "Basic " + Symm.base64.encode(s);
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/EpiLur.java b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/EpiLur.java
index 2c5e1957..5443dec2 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/EpiLur.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/EpiLur.java
@@ -57,30 +57,30 @@ public final class EpiLur implements Lur {
*/
public EpiLur(Lur ... lurs) throws CadiException{
this.lurs = lurs;
- if(lurs.length==0) throw new CadiException("Need at least one Lur implementation in constructor");
+ if (lurs.length==0) throw new CadiException("Need at least one Lur implementation in constructor");
}
public boolean fish(Principal bait, Permission ... pond) {
- if(pond==null) {
+ if (pond==null) {
return false;
}
boolean rv = false;
Lur lur;
- for(int i=0;!rv && i<lurs.length;++i) {
+ for (int i=0;!rv && i<lurs.length;++i) {
rv = (lur = lurs[i]).fish(bait, pond);
- if(!rv && lur.handlesExclusively(pond)) break;
+ if (!rv && lur.handlesExclusively(pond)) break;
}
return rv;
}
public void fishAll(Principal bait, List<Permission> permissions) {
- for(Lur lur : lurs) {
+ for (Lur lur : lurs) {
lur.fishAll(bait, permissions);
}
}
public void destroy() {
- for(Lur lur : lurs) {
+ for (Lur lur : lurs) {
lur.destroy();
}
}
@@ -90,8 +90,8 @@ public final class EpiLur implements Lur {
* @return
*/
public CredVal getUserPassImpl() {
- for(Lur lur : lurs) {
- if(lur instanceof CredVal) {
+ for (Lur lur : lurs) {
+ if (lur instanceof CredVal) {
return (CredVal)lur;
}
}
@@ -109,15 +109,15 @@ public final class EpiLur implements Lur {
* @return
*/
public Lur get(int idx) {
- if(idx>=0 && idx<lurs.length) {
+ if (idx>=0 && idx<lurs.length) {
return lurs[idx];
}
return null;
}
public boolean handles(Principal p) {
- for(Lur l : lurs) {
- if(l.handles(p)) {
+ for (Lur l : lurs) {
+ if (l.handles(p)) {
return true;
}
}
@@ -125,16 +125,16 @@ public final class EpiLur implements Lur {
}
public void remove(String id) {
- for(Lur l : lurs) {
- if(l instanceof CachingLur) {
+ for (Lur l : lurs) {
+ if (l instanceof CachingLur) {
((CachingLur<?>)l).remove(id);
}
}
}
public Lur subLur(Class<? extends Lur> cls ) {
- for(Lur l : lurs) {
- if(l.getClass().isAssignableFrom(cls)) {
+ for (Lur l : lurs) {
+ if (l.getClass().isAssignableFrom(cls)) {
return l;
}
}
@@ -151,14 +151,14 @@ public final class EpiLur implements Lur {
*/
@Override
public void clear(Principal p, StringBuilder report) {
- for(Lur lur : lurs) {
+ for (Lur lur : lurs) {
lur.clear(p, report);
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
- for(Lur lur : lurs) {
+ for (Lur lur : lurs) {
sb.append(lur.getClass().getSimpleName());
sb.append(": Report\n");
sb.append(lur.toString());
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/LocalLur.java b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/LocalLur.java
index d2b6f1aa..f8fa02e5 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/lur/LocalLur.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/lur/LocalLur.java
@@ -98,7 +98,7 @@ public final class LocalLur extends AbsUserCache<LocalPermission> implements Lur
if (pond == null) {
return false;
}
- for(Permission p : pond) {
+ for (Permission p : pond) {
if (handles(bait) && p instanceof LocalPermission) { // local Users only have LocalPermissions
User<LocalPermission> user = getUser(bait);
if (user != null) {
@@ -134,7 +134,7 @@ public final class LocalLur extends AbsUserCache<LocalPermission> implements Lur
public boolean handlesExclusively(Permission ... pond) {
boolean rv = false;
for (Permission p : pond) {
- if(rv=supportingGroups.contains(p.getKey())) {
+ if (rv=supportingGroups.contains(p.getKey())) {
break;
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/BasicPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/BasicPrincipal.java
index d3c1e236..746e67d8 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/BasicPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/BasicPrincipal.java
@@ -45,8 +45,8 @@ public class BasicPrincipal extends BearerPrincipal implements GetCred {
created = System.currentTimeMillis();
ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes());
// Read past "Basic ", ensuring it starts with it.
- for(int i=0;i<basic.length;++i) {
- if(bis.read()!=basic[i]) {
+ for (int i=0;i<basic.length;++i) {
+ if (bis.read()!=basic[i]) {
name=content;
cred = null;
return;
@@ -54,10 +54,10 @@ public class BasicPrincipal extends BearerPrincipal implements GetCred {
}
BasicOS bos = new BasicOS(content.length());
Symm.base64.decode(bis,bos); // note: writes directly to name until ':'
- if(name==null) throw new IOException("Invalid Coding");
+ if (name==null) throw new IOException("Invalid Coding");
else cred = bos.toCred();
int at;
- if((at=name.indexOf('@'))>0) {
+ if ((at=name.indexOf('@'))>0) {
domain=name.substring(at+1);
shortName=name.substring(0, at);
} else {
@@ -83,7 +83,7 @@ public class BasicPrincipal extends BearerPrincipal implements GetCred {
@Override
public void write(int b) throws IOException {
- if(b==':' && first) {
+ if (b==':' && first) {
first = false;
name = new String(baos.toByteArray());
baos.reset(); //
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/CachedBasicPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/CachedBasicPrincipal.java
index f81e160d..4a6e4cda 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/CachedBasicPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/CachedBasicPrincipal.java
@@ -54,7 +54,7 @@ public class CachedBasicPrincipal extends BasicPrincipal implements CachedPrinci
public CachedPrincipal.Resp revalidate(Object state) {
Resp resp = creator.revalidate(this, state);
- if(resp.equals(Resp.REVALIDATED))expires = System.currentTimeMillis()+timeToLive;
+ if (resp.equals(Resp.REVALIDATED))expires = System.currentTimeMillis()+timeToLive;
return resp;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/Kind.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/Kind.java
index 8c75701f..20f22846 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/Kind.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/Kind.java
@@ -33,19 +33,19 @@ public class Kind {
public static char getKind(final Principal principal) {
Principal check;
- if(principal instanceof TrustPrincipal) {
+ if (principal instanceof TrustPrincipal) {
check = ((TrustPrincipal)principal).original();
} else {
check = principal;
}
- if(check instanceof X509Principal) {
+ if (check instanceof X509Principal) {
return X509;
}
- if(check instanceof OAuth2FormPrincipal) {
+ if (check instanceof OAuth2FormPrincipal) {
// Note: if AAF, will turn into 'A'
return OAUTH;
}
- if(check instanceof BasicPrincipal) {
+ if (check instanceof BasicPrincipal) {
return BASIC_AUTH;
}
return UNKNOWN;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/OAuth2FormPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/OAuth2FormPrincipal.java
index 4d13de87..01326054 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/OAuth2FormPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/OAuth2FormPrincipal.java
@@ -49,7 +49,7 @@ public class OAuth2FormPrincipal extends TaggedPrincipal {
@Override
public String personalName() {
- if(username!=null && username!=client_id) {
+ if (username!=null && username!=client_id) {
StringBuilder sb = new StringBuilder();
sb.append(username);
sb.append('|');
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TaggedPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TaggedPrincipal.java
index 9dddcd63..7bb4ff52 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TaggedPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TaggedPrincipal.java
@@ -47,7 +47,7 @@ public abstract class TaggedPrincipal implements Principal {
}
public String personalName() {
- if(tagLookup == null) {
+ if (tagLookup == null) {
return getName();
}
try {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TrustPrincipal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TrustPrincipal.java
index 5d4a0586..7e92aaca 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TrustPrincipal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/TrustPrincipal.java
@@ -33,10 +33,10 @@ public class TrustPrincipal extends BearerPrincipal implements UserChain {
public TrustPrincipal(final Principal actual, final String asName) {
this.original = actual;
name = asName.trim();
- if(actual instanceof UserChain) {
+ if (actual instanceof UserChain) {
UserChain uc = (UserChain)actual;
userChain = uc.userChain();
- } else if(actual instanceof TaggedPrincipal) {
+ } else if (actual instanceof TaggedPrincipal) {
userChain=((TaggedPrincipal)actual).tag();
} else {
userChain = actual.getClass().getSimpleName();
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/X509Principal.java b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/X509Principal.java
index 1cd114a0..0348cd1f 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/principal/X509Principal.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/principal/X509Principal.java
@@ -55,17 +55,17 @@ public class X509Principal extends BearerPrincipal implements GetCred {
String _name = null;
String subj = cert.getSubjectDN().getName();
int cn = subj.indexOf("OU=");
- if(cn>=0) {
+ if (cn>=0) {
cn+=3;
int space = subj.indexOf(',',cn);
- if(space>=0) {
+ if (space>=0) {
String id = subj.substring(cn, space);
- if(pattern.matcher(id).matches()) {
+ if (pattern.matcher(id).matches()) {
_name = id;
}
}
}
- if(_name==null) {
+ if (_name==null) {
throw new IOException("X509 does not have Identity as CN");
}
name = _name;
@@ -74,7 +74,7 @@ public class X509Principal extends BearerPrincipal implements GetCred {
public String getAsHeader() throws IOException {
try {
- if(content==null) {
+ if (content==null) {
content=cert.getEncoded();
}
} catch (CertificateEncodingException e) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/EpiTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/EpiTaf.java
index b248e553..d2cbf3fa 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/EpiTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/EpiTaf.java
@@ -47,7 +47,7 @@ public class EpiTaf implements Taf {
*/
public EpiTaf(Taf ... tafs) throws CadiException{
this.tafs = tafs;
- if(tafs.length==0) throw new CadiException("Need at least one Taf implementation in constructor");
+ if (tafs.length==0) throw new CadiException("Need at least one Taf implementation in constructor");
}
/**
@@ -63,13 +63,13 @@ public class EpiTaf implements Taf {
*/
public TafResp validate(LifeForm reading, String... info) {
TafResp tresp,firstTryAuth=null;
- for(Taf taf : tafs) {
+ for (Taf taf : tafs) {
tresp = taf.validate(reading, info);
switch(tresp.isAuthenticated()) {
case TRY_ANOTHER_TAF:
break;
case TRY_AUTHENTICATING:
- if(firstTryAuth==null)firstTryAuth=tresp;
+ if (firstTryAuth==null)firstTryAuth=tresp;
break;
default:
return tresp;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
index b0f56603..6334164e 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/HttpEpiTaf.java
@@ -94,7 +94,7 @@ public class HttpEpiTaf implements HttpTaf {
TafResp firstTry = null;
List<Redirectable> redirectables = null;
List<TafResp> log;
- if(access.willLog(Level.DEBUG)) {
+ if (access.willLog(Level.DEBUG)) {
log = new ArrayList<>();
} else {
log = null;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
index 21830b01..d5f6b032 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
@@ -85,23 +85,23 @@ public class BasicHttpTaf implements HttpTaf {
*/
public TafResp validate(Taf.LifeForm reading, HttpServletRequest req, HttpServletResponse resp) {
// See if Request implements BasicCred (aka CadiWrap or other), and if User/Pass has already been set separately
- if(req instanceof BasicCred) {
+ if (req instanceof BasicCred) {
BasicCred bc = (BasicCred)req;
- if(bc.getUser()!=null) { // CadiWrap, if set, makes sure User & Password are both valid, or both null
- if(DenialOfServiceTaf.isDeniedID(bc.getUser())!=null) {
+ if (bc.getUser()!=null) { // CadiWrap, if set, makes sure User & Password are both valid, or both null
+ if (DenialOfServiceTaf.isDeniedID(bc.getUser())!=null) {
return DenialOfServiceTaf.respDenyID(access,bc.getUser());
}
CachedBasicPrincipal bp = new CachedBasicPrincipal(this,bc,realm,timeToLive);
// Be able to do Organizational specific lookups by Domain
CredVal cv = rbacs.get(bp.getDomain());
- if(cv==null) {
+ if (cv==null) {
cv = rbac;
}
// ONLY FOR Last Ditch DEBUGGING...
// access.log(Level.WARN,bp.getName() + ":" + new String(bp.getCred()));
- if(cv.validate(bp.getName(),Type.PASSWORD,bp.getCred(),req)) {
+ if (cv.validate(bp.getName(),Type.PASSWORD,bp.getCred(),req)) {
return new BasicHttpTafResp(access,bp,bp.getName()+" authenticated by password",RESP.IS_AUTHENTICATED,resp,realm,false);
} else {
//TODO may need timed retries in a given time period
@@ -112,25 +112,25 @@ public class BasicHttpTaf implements HttpTaf {
}
// Get User/Password from Authorization Header value
String authz = req.getHeader("Authorization");
- if(authz != null && authz.startsWith("Basic ")) {
- if(warn&&!req.isSecure()) {
+ if (authz != null && authz.startsWith("Basic ")) {
+ if (warn&&!req.isSecure()) {
access.log(Level.WARN,"WARNING! BasicAuth has been used over an insecure channel");
}
try {
CachedBasicPrincipal ba = new CachedBasicPrincipal(this,authz,realm,timeToLive);
- if(DenialOfServiceTaf.isDeniedID(ba.getName())!=null) {
+ if (DenialOfServiceTaf.isDeniedID(ba.getName())!=null) {
return DenialOfServiceTaf.respDenyID(access,ba.getName());
}
final int at = ba.getName().indexOf('@');
CredVal cv = rbacs.get(ba.getName().substring(at+1));
- if(cv==null) {
+ if (cv==null) {
cv = rbac; // default
}
// ONLY FOR Last Ditch DEBUGGING...
// access.log(Level.WARN,ba.getName() + ":" + new String(ba.getCred()));
- if(cv.validate(ba.getName(), Type.PASSWORD, ba.getCred(), req)) {
+ if (cv.validate(ba.getName(), Type.PASSWORD, ba.getCred(), req)) {
return new BasicHttpTafResp(access,ba, ba.getName()+" authenticated by BasicAuth password",RESP.IS_AUTHENTICATED,resp,realm,false);
} else {
//TODO may need timed retries in a given time period
@@ -148,7 +148,7 @@ public class BasicHttpTaf implements HttpTaf {
protected String buildMsg(Principal pr, HttpServletRequest req, Object ... msg) {
StringBuilder sb = new StringBuilder();
- if(pr!=null) {
+ if (pr!=null) {
sb.append("user=");
sb.append(pr.getName());
sb.append(',');
@@ -157,9 +157,9 @@ public class BasicHttpTaf implements HttpTaf {
sb.append(req.getRemoteAddr());
sb.append(",port=");
sb.append(req.getRemotePort());
- if(msg.length>0) {
+ if (msg.length>0) {
sb.append(",msg=\"");
- for(Object s : msg) {
+ for (Object s : msg) {
sb.append(s.toString());
}
sb.append('"');
@@ -173,7 +173,7 @@ public class BasicHttpTaf implements HttpTaf {
public CredVal getCredVal(String key) {
CredVal cv = rbacs.get(key);
- if(cv==null) {
+ if (cv==null) {
cv = rbac;
}
return cv;
@@ -181,9 +181,9 @@ public class BasicHttpTaf implements HttpTaf {
@Override
public Resp revalidate(CachedPrincipal prin, Object state) {
- if(prin instanceof BasicPrincipal) {
+ if (prin instanceof BasicPrincipal) {
BasicPrincipal ba = (BasicPrincipal)prin;
- if(DenialOfServiceTaf.isDeniedID(ba.getName())!=null) {
+ if (DenialOfServiceTaf.isDeniedID(ba.getName())!=null) {
return Resp.UNVALIDATED;
}
return rbac.validate(ba.getName(), Type.PASSWORD, ba.getCred(), state)?Resp.REVALIDATED:Resp.UNVALIDATED;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
index d0034c76..0f252e39 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
@@ -81,18 +81,18 @@ public class X509Taf implements HttpTaf {
public X509Taf(Access access, Lur lur, CertIdentity ... cis) throws CertificateException, NoSuchAlgorithmException, CadiException {
this.access = access;
env = access.getProperty(Config.AAF_ENV,null);
- if(env==null) {
+ if (env==null) {
throw new CadiException("X509Taf requires Environment ("+Config.AAF_ENV+") to be set.");
}
// this.lur = lur;
this.cadiIssuers = new ArrayList<>();
- for(String ci : access.getProperty(Config.CADI_X509_ISSUERS, "").split(":")) {
+ for (String ci : access.getProperty(Config.CADI_X509_ISSUERS, "").split(":")) {
access.printf(Level.INIT, "Trusting Identity for Certificates signed by \"%s\"",ci);
cadiIssuers.add(ci);
}
try {
Class<?> dci = access.classLoader().loadClass("org.onap.aaf.auth.direct.DirectCertIdentity");
- if(dci==null) {
+ if (dci==null) {
certIdents = cis;
} else {
CertIdentity temp[] = new CertIdentity[cis.length+1];
@@ -129,28 +129,28 @@ public class X509Taf implements HttpTaf {
// Check for Mutual SSL
try {
X509Certificate[] certarr = (X509Certificate[])req.getAttribute("javax.servlet.request.X509Certificate");
- if(certarr!=null && certarr.length>0) {
+ if (certarr!=null && certarr.length>0) {
si.checkClientTrusted(certarr);
// Note: If the Issuer is not in the TrustStore, it's not added to the Cert list
String issuer = certarr[0].getIssuerDN().toString();
- if(cadiIssuers.contains(issuer)) {
+ if (cadiIssuers.contains(issuer)) {
String subject = certarr[0].getSubjectDN().getName();
// avoiding extra object creation, since this is validated EVERY transaction with a Cert
int at = subject.indexOf('@');
- if(at>=0) {
+ if (at>=0) {
int start = subject.lastIndexOf(',', at);
- if(start<0) {
+ if (start<0) {
start = 0;
}
int end = subject.indexOf(',', at);
- if(end<0) {
+ if (end<0) {
end=subject.length();
}
int temp;
- if(((temp=subject.indexOf("OU=",start))>=0 && temp<end) ||
+ if (((temp=subject.indexOf("OU=",start))>=0 && temp<end) ||
((temp=subject.indexOf("CN=",start))>=0 && temp<end)) {
String[] sa = Split.splitTrim(':', subject, temp+3,end);
- if(sa.length==1 || (sa.length>1 && env!=null && env.equals(sa[1]))) { // Check Environment
+ if (sa.length==1 || (sa.length>1 && env!=null && env.equals(sa[1]))) { // Check Environment
return new X509HttpTafResp(access,
new X509Principal(sa[0], certarr[0],(byte[])null,bht),
"X509Taf validated " + sa[0] + (sa.length<2?"":" for aaf_env " + env ), RESP.IS_AUTHENTICATED);
@@ -168,10 +168,10 @@ public class X509Taf implements HttpTaf {
String responseText=null;
String authHeader = req.getHeader("Authorization");
- if(certarr!=null) { // If cert !=null, Cert is Tested by Mutual Protocol.
- if(authHeader!=null) { // This is only intended to be a Secure Connection, not an Identity
- for(String auth : Split.split(',',authHeader)) {
- if(auth.startsWith("Bearer ")) { // Bearer = OAuth... Don't use as Authenication
+ if (certarr!=null) { // If cert !=null, Cert is Tested by Mutual Protocol.
+ if (authHeader!=null) { // This is only intended to be a Secure Connection, not an Identity
+ for (String auth : Split.split(',',authHeader)) {
+ if (auth.startsWith("Bearer ")) { // Bearer = OAuth... Don't use as Authenication
return new X509HttpTafResp(access, null, "Certificate verified, but Bearer Token is presented", RESP.TRY_ANOTHER_TAF);
}
}
@@ -179,9 +179,9 @@ public class X509Taf implements HttpTaf {
cert = certarr[0];
responseText = ", validated by Mutual SSL Protocol";
} else { // If cert == null, Get Declared Cert (in header), but validate by having them sign something
- if(authHeader != null) {
- for(String auth : Split.splitTrim(',',authHeader)) {
- if(auth.startsWith("x509 ")) {
+ if (authHeader != null) {
+ for (String auth : Split.splitTrim(',',authHeader)) {
+ if (auth.startsWith("x509 ")) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(auth.length());
try {
array = auth.getBytes();
@@ -197,10 +197,10 @@ public class X509Taf implements HttpTaf {
// cert.checkValidity();
// cert.--- GET FINGERPRINT?
String stuff = req.getHeader("Signature");
- if(stuff==null)
+ if (stuff==null)
return new X509HttpTafResp(access, null, "Header entry 'Signature' required to validate One way X509 Certificate", RESP.TRY_ANOTHER_TAF);
String data = req.getHeader("Data");
- // if(data==null)
+ // if (data==null)
// return new X509HttpTafResp(access, null, "No signed Data to validate with X509 Certificate", RESP.TRY_ANOTHER_TAF);
// Note: Data Pos shows is "<signatureType> <data>"
@@ -215,7 +215,7 @@ public class X509Taf implements HttpTaf {
Signature sig = Signature.getInstance(cert.getSigAlgName());
sig.initVerify(cert.getPublicKey());
sig.update(data.getBytes());
- if(!sig.verify(array)) {
+ if (!sig.verify(array)) {
access.log(Level.ERROR, "Signature doesn't Match");
return new X509HttpTafResp(access, null, CERTIFICATE_NOT_VALID_FOR_AUTHENTICATION, RESP.TRY_ANOTHER_TAF);
}
@@ -227,21 +227,21 @@ public class X509Taf implements HttpTaf {
}
}
}
- if(cert==null) {
+ if (cert==null) {
return new X509HttpTafResp(access, null, "No Certificate Info on Transaction", RESP.TRY_ANOTHER_TAF);
}
// A cert has been found, match Identify
TaggedPrincipal prin=null;
- for(int i=0;prin==null && i<certIdents.length;++i) {
- if((prin=certIdents[i].identity(req, cert, certBytes))!=null) {
+ for (int i=0;prin==null && i<certIdents.length;++i) {
+ if ((prin=certIdents[i].identity(req, cert, certBytes))!=null) {
responseText = prin.getName() + " matches Certificate " + cert.getSubjectX500Principal().getName() + responseText;
}
}
// if Principal is found, check for "AS_USER" and whether this entity is trusted to declare
- if(prin!=null) {
+ if (prin!=null) {
return new X509HttpTafResp(
access,
prin,
@@ -249,7 +249,7 @@ public class X509Taf implements HttpTaf {
RESP.IS_AUTHENTICATED);
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
return new X509HttpTafResp(access, null, e.getMessage(), RESP.TRY_ANOTHER_TAF);
}
@@ -266,7 +266,7 @@ public class X509Taf implements HttpTaf {
}
public CredVal getCredVal(final String key) {
- if(bht==null) {
+ if (bht==null) {
return null;
} else {
return bht.getCredVal(key);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
index 4154e50e..f083e5aa 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/dos/DenialOfServiceTaf.java
@@ -62,9 +62,9 @@ public class DenialOfServiceTaf implements HttpTaf {
public DenialOfServiceTaf(Access access) throws CadiException {
puntNotDenied = new PuntTafResp("DenialOfServiceTaf", "This Transaction is not denied");
this.access = access;
- if(dosIP==null || dosID == null) {
+ if (dosIP==null || dosID == null) {
String dirStr;
- if((dirStr = access.getProperty(Config.AAF_DATA_DIR, null))!=null) {
+ if ((dirStr = access.getProperty(Config.AAF_DATA_DIR, null))!=null) {
dosIP = new File(dirStr+"/dosIP");
readIP();
dosID = new File(dirStr+"/dosID");
@@ -76,10 +76,10 @@ public class DenialOfServiceTaf implements HttpTaf {
@Override
public TafResp validate(LifeForm reading, HttpServletRequest req, final HttpServletResponse resp) {
// Performance, when not needed
- if(deniedIP != null) {
+ if (deniedIP != null) {
String ip;
Counter c = deniedIP.get(ip=req.getRemoteAddr());
- if(c!=null) {
+ if (c!=null) {
c.inc();
return respDenyIP(access,ip);
}
@@ -100,7 +100,7 @@ public class DenialOfServiceTaf implements HttpTaf {
* for use in Other TAFs, before they attempt backend validation of
*/
public static Counter isDeniedID(String identity) {
- if(deniedID!=null) {
+ if (deniedID!=null) {
return deniedID.get(identity);
}
return null;
@@ -110,7 +110,7 @@ public class DenialOfServiceTaf implements HttpTaf {
*
*/
public static Counter isDeniedIP(String ipvX) {
- if(deniedIP!=null) {
+ if (deniedIP!=null) {
return deniedIP.get(ipvX);
}
return null;
@@ -125,24 +125,24 @@ public class DenialOfServiceTaf implements HttpTaf {
*/
public static synchronized boolean denyIP(String ip) {
boolean rv = false;
- if(deniedIP==null) {
+ if (deniedIP==null) {
deniedIP = new HashMap<>();
deniedIP.put(ip, new Counter(ip)); // Noted duplicated for minimum time spent
rv= true;
- } else if(deniedIP.get(ip)==null) {
+ } else if (deniedIP.get(ip)==null) {
deniedIP.put(ip, new Counter(ip));
rv = true;
}
- if(rv) {
+ if (rv) {
writeIP();
}
return rv;
}
private static void writeIP() {
- if(dosIP!=null && deniedIP!=null) {
- if(deniedIP.isEmpty()) {
- if(dosIP.exists()) {
+ if (dosIP!=null && deniedIP!=null) {
+ if (deniedIP.isEmpty()) {
+ if (dosIP.exists()) {
dosIP.delete();
}
} else {
@@ -150,7 +150,7 @@ public class DenialOfServiceTaf implements HttpTaf {
try {
fos = new PrintStream(new FileOutputStream(dosIP,false));
try {
- for(String ip: deniedIP.keySet()) {
+ for (String ip: deniedIP.keySet()) {
fos.println(ip);
}
} finally {
@@ -164,17 +164,17 @@ public class DenialOfServiceTaf implements HttpTaf {
}
private static void readIP() {
- if(dosIP!=null && dosIP.exists()) {
+ if (dosIP!=null && dosIP.exists()) {
BufferedReader br;
try {
br = new BufferedReader(new FileReader(dosIP));
try {
- if(deniedIP==null) {
+ if (deniedIP==null) {
deniedIP=new HashMap<>();
}
String line;
- while((line=br.readLine())!=null) {
+ while ((line=br.readLine())!=null) {
deniedIP.put(line, new Counter(line));
}
} finally {
@@ -195,9 +195,9 @@ public class DenialOfServiceTaf implements HttpTaf {
* @return
*/
public static synchronized boolean removeDenyIP(String ip) {
- if(deniedIP!=null && deniedIP.remove(ip)!=null) {
+ if (deniedIP!=null && deniedIP.remove(ip)!=null) {
writeIP();
- if(deniedIP.isEmpty()) {
+ if (deniedIP.isEmpty()) {
deniedIP=null;
}
return true;
@@ -214,15 +214,15 @@ public class DenialOfServiceTaf implements HttpTaf {
*/
public static synchronized boolean denyID(String id) {
boolean rv = false;
- if(deniedID==null) {
+ if (deniedID==null) {
deniedID = new HashMap<>();
deniedID.put(id, new Counter(id)); // Noted duplicated for minimum time spent
rv = true;
- } else if(deniedID.get(id)==null) {
+ } else if (deniedID.get(id)==null) {
deniedID.put(id, new Counter(id));
rv = true;
}
- if(rv) {
+ if (rv) {
writeID();
}
return rv;
@@ -230,9 +230,9 @@ public class DenialOfServiceTaf implements HttpTaf {
}
private static void writeID() {
- if(dosID!=null && deniedID!=null) {
- if(deniedID.isEmpty()) {
- if(dosID.exists()) {
+ if (dosID!=null && deniedID!=null) {
+ if (deniedID.isEmpty()) {
+ if (dosID.exists()) {
dosID.delete();
}
} else {
@@ -240,7 +240,7 @@ public class DenialOfServiceTaf implements HttpTaf {
try {
fos = new PrintStream(new FileOutputStream(dosID,false));
try {
- for(String ip: deniedID.keySet()) {
+ for (String ip: deniedID.keySet()) {
fos.println(ip);
}
} finally {
@@ -254,17 +254,17 @@ public class DenialOfServiceTaf implements HttpTaf {
}
private static void readID() {
- if(dosID!=null && dosID.exists()) {
+ if (dosID!=null && dosID.exists()) {
BufferedReader br;
try {
br = new BufferedReader(new FileReader(dosID));
try {
- if(deniedID==null) {
+ if (deniedID==null) {
deniedID=new HashMap<>();
}
String line;
- while((line=br.readLine())!=null) {
+ while ((line=br.readLine())!=null) {
deniedID.put(line, new Counter(line));
}
} finally {
@@ -284,9 +284,9 @@ public class DenialOfServiceTaf implements HttpTaf {
* @return
*/
public static synchronized boolean removeDenyID(String id) {
- if(deniedID!=null && deniedID.remove(id)!=null) {
+ if (deniedID!=null && deniedID.remove(id)!=null) {
writeID();
- if(deniedID.isEmpty()) {
+ if (deniedID.isEmpty()) {
deniedID=null;
}
@@ -297,16 +297,16 @@ public class DenialOfServiceTaf implements HttpTaf {
public List<String> report() {
int initSize = 0;
- if(deniedIP!=null)initSize+=deniedIP.size();
- if(deniedID!=null)initSize+=deniedID.size();
+ if (deniedIP!=null)initSize+=deniedIP.size();
+ if (deniedID!=null)initSize+=deniedID.size();
ArrayList<String> al = new ArrayList<>(initSize);
- if(deniedID!=null) {
- for(Counter c : deniedID.values()) {
+ if (deniedID!=null) {
+ for (Counter c : deniedID.values()) {
al.add(c.toString());
}
}
- if(deniedIP!=null) {
- for(Counter c : deniedIP.values()) {
+ if (deniedIP!=null) {
+ for (Counter c : deniedIP.values()) {
al.add(c.toString());
}
}
@@ -344,13 +344,13 @@ public class DenialOfServiceTaf implements HttpTaf {
private synchronized void inc() {
++count;
last = System.currentTimeMillis();
- if(first==null) {
+ if (first==null) {
first = new Date(last);
}
}
public String toString() {
- if(count==0)
+ if (count==0)
return name + " is on the denied list, but has not attempted Access";
else
return
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java
index f0b8d38d..07389aad 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FQI.java
@@ -31,14 +31,14 @@ public class FQI {
StringBuilder sb = null;
String[] split = Split.split('.',fqi);
int at;
- for(int i=split.length-1;i>=0;--i) {
- if(sb == null) {
+ for (int i=split.length-1;i>=0;--i) {
+ if (sb == null) {
sb = new StringBuilder();
} else {
sb.append('.');
}
- if((at = split[i].indexOf('@'))>0) {
+ if ((at = split[i].indexOf('@'))>0) {
sb.append(split[i].subSequence(at+1, split[i].length()));
} else {
sb.append(split[i]);
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/JsonOutputStream.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/JsonOutputStream.java
index 7c3ac30d..e790766b 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/JsonOutputStream.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/JsonOutputStream.java
@@ -39,11 +39,11 @@ public class JsonOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
- if(ret=='\n') {
+ if (ret=='\n') {
ret = 0;
- if(prev!=',' || (b!='{' && b!='[')) {
+ if (prev!=',' || (b!='{' && b!='[')) {
os.write('\n');
- for(int i=0;i<indent;++i) {
+ for (int i=0;i<indent;++i) {
os.write(TWO_SPACE);
}
}
@@ -58,7 +58,7 @@ public class JsonOutputStream extends OutputStream {
case ']':
--indent;
os.write('\n');
- for(int i=0;i<indent;++i) {
+ for (int i=0;i<indent;++i) {
os.write(TWO_SPACE);
}
break;
@@ -81,7 +81,7 @@ public class JsonOutputStream extends OutputStream {
@Override
public void close() throws IOException {
- if(closeable) {
+ if (closeable) {
os.close();
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/NetMask.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/NetMask.java
index 2a3d75ff..19fd1e2d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/NetMask.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/NetMask.java
@@ -56,7 +56,7 @@ public class NetMask {
public static long derive(byte[] inBytes) {
long addr = 0L;
int offset = inBytes.length*8;
- for(int i=0;i<inBytes.length;++i) {
+ for (int i=0;i<inBytes.length;++i) {
addr&=(inBytes[i]<<offset);
offset-=8;
}
@@ -68,22 +68,22 @@ public class NetMask {
int idx=str.indexOf(':');
int slash = str.indexOf('/');
- if(idx<0) { // Not IPV6, so it's IPV4... Is there a mask of 123/254?
+ if (idx<0) { // Not IPV6, so it's IPV4... Is there a mask of 123/254?
idx=str.indexOf('.');
int offset = 24;
int end = slash>=0?slash:str.length();
int bits = slash>=0?Integer.parseInt(str.substring(slash+1)):32;
- if(check && bits>32) {
+ if (check && bits>32) {
throw new MaskFormatException("Invalid Mask Offset in IPV4 Address");
}
int prev = 0;
long lbyte;
- while(prev<end) {
- if(idx<0) {
+ while (prev<end) {
+ if (idx<0) {
idx = end;
}
lbyte = Long.parseLong(str.substring(prev, idx));
- if(check && (lbyte>255 || lbyte<0)) {
+ if (check && (lbyte>255 || lbyte<0)) {
throw new MaskFormatException("Invalid Byte in IPV4 Address");
}
rv|=lbyte<<offset;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
index a2c76967..4bb1d3b8 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
@@ -36,20 +36,20 @@ public class Split {
}
public static String[] split(char c, String value, int start, int end) {
- if(value==null) {
+ if (value==null) {
return new String[0];
}
// Count items to preallocate Array (memory alloc is more expensive than counting twice)
int count,idx;
- for(count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+ for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
String[] rv = new String[count];
- if(count==1) {
+ if (count==1) {
rv[0]=value.substring(start,end);
} else {
int last=0;
count=-1;
- for(idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+ for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
rv[++count]=value.substring(last,idx);
last = ++idx;
}
@@ -59,20 +59,20 @@ public class Split {
}
public static String[] splitTrim(char c, String value, int start, int end) {
- if(value==null) {
+ if (value==null) {
return new String[0];
}
// Count items to preallocate Array (memory alloc is more expensive than counting twice)
int count,idx;
- for(count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+ for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
String[] rv = new String[count];
- if(count==1) {
+ if (count==1) {
rv[0]=value.substring(start,end).trim();
} else {
int last=0;
count=-1;
- for(idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+ for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
rv[++count]=value.substring(last,idx).trim();
last = ++idx;
}
@@ -86,23 +86,23 @@ public class Split {
}
public static String[] splitTrim(char c, String value, int size) {
- if(value==null) {
+ if (value==null) {
return new String[0];
}
int idx;
String[] rv = new String[size];
- if(size==1) {
+ if (size==1) {
rv[0]=value.trim();
} else {
int last=0;
int count=-1;
size-=2;
- for(idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
+ for (idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
rv[++count]=value.substring(last,idx).trim();
last = ++idx;
}
- if(idx>0) {
+ if (idx>0) {
rv[++count]=value.substring(last,idx).trim();
} else {
rv[++count]=value.substring(last).trim();
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
index 5cab15f6..a85020ff 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
@@ -40,7 +40,7 @@ public class SubStandardConsole implements MyConsole {
try {
System.out.printf(fmt,args);
rv = br.readLine();
- if(args.length==1 && rv.length()==0) {
+ if (args.length==1 && rv.length()==0) {
rv = args[0].toString();
}
} catch (IOException e) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/TheConsole.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/TheConsole.java
index 9ddd0626..da99d06d 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/TheConsole.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/TheConsole.java
@@ -25,7 +25,7 @@ public class TheConsole implements MyConsole {
@Override
public String readLine(String fmt, Object... args) {
String rv = System.console().readLine(fmt, args);
- if(args.length>0 && args[0]!=null && rv.length()==0) {
+ if (args.length>0 && args[0]!=null && rv.length()==0) {
rv = args[0].toString();
}
return rv;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/UserChainManip.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/UserChainManip.java
index ff74f39c..d42aaf55 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/UserChainManip.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/UserChainManip.java
@@ -31,7 +31,7 @@ public class UserChainManip {
*/
public static StringBuilder build(StringBuilder sb, String app, String id, UserChain.Protocol proto, boolean as) {
boolean mayAs;
- if(!(mayAs=sb.length()==0)) {
+ if (!(mayAs=sb.length()==0)) {
sb.append(',');
}
sb.append(app);
@@ -39,34 +39,34 @@ public class UserChainManip {
sb.append(id);
sb.append(':');
sb.append(proto.name());
- if(as && mayAs) {
+ if (as && mayAs) {
sb.append(":AS");
}
return sb;
}
public static String idToNS(String id) {
- if(id==null) {
+ if (id==null) {
return "";
} else {
StringBuilder sb = new StringBuilder();
char c;
int end;
boolean first = true;
- for(int idx = end = id.length()-1;idx>=0;--idx) {
- if((c = id.charAt(idx))=='@' || c=='.') {
- if(idx<end) {
- if(first) {
+ for (int idx = end = id.length()-1;idx>=0;--idx) {
+ if ((c = id.charAt(idx))=='@' || c=='.') {
+ if (idx<end) {
+ if (first) {
first = false;
} else {
sb.append('.');
}
- for(int i=idx+1;i<=end;++i) {
+ for (int i=idx+1;i<=end;++i) {
sb.append(id.charAt(i));
}
}
end=idx-1;
- if(c=='@') {
+ if (c=='@') {
break;
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
index b8468129..9751969e 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
@@ -48,28 +48,28 @@ public class Vars {
StringBuilder sb = null;
int idx,index=0,prev = 0;
- if(text.contains("%s")) {
+ if (text.contains("%s")) {
sb = new StringBuilder();
}
StringBuilder[] sbs = new StringBuilder[] {sb,holder};
boolean replace, clearIndex = false;
int c;
- while((idx=text.indexOf('%',prev))>=0) {
+ while ((idx=text.indexOf('%',prev))>=0) {
replace = false;
- if(clearIndex) {
+ if (clearIndex) {
index=0;
}
- if(sb!=null) {
+ if (sb!=null) {
sb.append(text,prev,idx);
}
- if(holder!=null) {
+ if (holder!=null) {
holder.append(text,prev,idx);
}
boolean go = true;
- while(go) {
- if(text.length()>++idx) {
+ while (go) {
+ if (text.length()>++idx) {
switch(c=text.charAt(idx)) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -87,19 +87,19 @@ public class Vars {
}
prev = idx;
go=false;
- if(replace) {
- if(sb!=null) {
+ if (replace) {
+ if (sb!=null) {
sb.append('%');
sb.append(index);
}
- if(index<=vars.length) {
- if(holder!=null) {
+ if (index<=vars.length) {
+ if (holder!=null) {
holder.append(vars[index-1]);
}
}
} else {
- for(StringBuilder s : sbs) {
- if(s!=null) {
+ for (StringBuilder s : sbs) {
+ if (s!=null) {
s.append("%");
}
}
@@ -107,10 +107,10 @@ public class Vars {
}
}
- if(sb!=null) {
+ if (sb!=null) {
sb.append(text,prev,text.length());
}
- if(holder!=null) {
+ if (holder!=null) {
holder.append(text,prev,text.length());
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/Match.java b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/Match.java
index 38322307..d0a7da47 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/Match.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/Match.java
@@ -57,42 +57,42 @@ public class Match<OUTPUT> {
this.qname = new QName(ns,name);
this.next = next;
stopAfter = exclusive = false;
- for(Match<OUTPUT> m : next) { // add the possible tags to look for
- if(!m.stopAfter)m.prev = this;
+ for (Match<OUTPUT> m : next) { // add the possible tags to look for
+ if (!m.stopAfter)m.prev = this;
}
}
public Match<OUTPUT> onMatch(OUTPUT output, XReader reader) throws XMLStreamException {
- while(reader.hasNext()) {
+ while (reader.hasNext()) {
XEvent event = reader.nextEvent();
switch(event.getEventType()) {
case XMLEvent.START_ELEMENT:
QName e_qname = event.asStartElement().getName();
//System.out.println("Start - " + e_qname);
boolean match = false;
- for(Match<OUTPUT> m : next) {
- if(e_qname.equals(m.qname)) {
+ for (Match<OUTPUT> m : next) {
+ if (e_qname.equals(m.qname)) {
match=true;
- if(m.onMatch(output, reader)==null) {
+ if (m.onMatch(output, reader)==null) {
return null; // short circuit Parsing
}
break;
}
}
- if(exclusive && !match) // When Tag MUST be present, i.e. the Root Tag, versus info we're not interested in
+ if (exclusive && !match) // When Tag MUST be present, i.e. the Root Tag, versus info we're not interested in
return null;
break;
case XMLEvent.CHARACTERS:
//System.out.println("Data - " +event.asCharacters().getData());
- if(action!=null) {
- if(!action.content(output,event.asCharacters().getData())) {
+ if (action!=null) {
+ if (!action.content(output,event.asCharacters().getData())) {
return null;
}
}
break;
case XMLEvent.END_ELEMENT:
//System.out.println("End - " + event.asEndElement().getName());
- if(event.asEndElement().getName().equals(qname)) {
+ if (event.asEndElement().getName().equals(qname)) {
return prev;
}
break;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
index b7cc40ad..aa46bec5 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/wsse/XReader.java
@@ -66,7 +66,7 @@ public class XReader {
}
public boolean hasNext() throws XMLStreamException {
- if(curr==null) {
+ if (curr==null) {
curr = parse();
}
return curr!=null;
@@ -106,7 +106,7 @@ public class XReader {
Map<String,String> nss = nsses.isEmpty()?null:nsses.peek();
XEvent rv;
- if((rv=another)!=null) { // "another" is a tag that may have needed to be created, but not
+ if ((rv=another)!=null) { // "another" is a tag that may have needed to be created, but not
// immediately returned. Save for next parse. If necessary, this could be turned into
// a FIFO storage, but a single reference is enough for now.
another = null; // "rv" is now set for the Event, and will be returned. Set to Null.
@@ -115,15 +115,15 @@ public class XReader {
int c=0;
try {
- while(go && (c=is.read())>=0) {
+ while (go && (c=is.read())>=0) {
++count;
switch(c) {
case '<': // Tag is opening
state|=~BEGIN_DOC; // remove BEGIN_DOC flag, this is possibly an XML Doc
XEvent cxe = null;
- if(baos.size()>0) { // If there are any characters between tags, we send as Character Event
+ if (baos.size()>0) { // If there are any characters between tags, we send as Character Event
String chars = baos.toString().trim(); // Trim out WhiteSpace before and after
- if(chars.length()>0) { // don't send if Characters were only whitespace
+ if (chars.length()>0) { // don't send if Characters were only whitespace
cxe = new XEvent.Characters(chars);
baos.reset();
go = false;
@@ -145,7 +145,7 @@ public class XReader {
default:
ns = "";
}
- if(ns==null)
+ if (ns==null)
throw new XMLStreamException("Invalid Namespace Prefix at " + count);
go = false;
switch(t.state) { // based on
@@ -165,9 +165,9 @@ public class XReader {
break;
case START_TAG|END_TAG: // This tag is both start/end aka <myTag/>
rv = new XEvent.StartElement(ns,t.name);
- if(last=='/')another = new XEvent.EndElement(ns,t.name);
+ if (last=='/')another = new XEvent.EndElement(ns,t.name);
}
- if(cxe!=null) { // if there is a Character Event, it actually should go first. ow.
+ if (cxe!=null) { // if there is a Character Event, it actually should go first. ow.
another = rv; // Make current Event the "another" or next event, and
rv = cxe; // send Character Event now
}
@@ -175,12 +175,12 @@ public class XReader {
case ' ':
case '\t':
case '\n':
- if((state&BEGIN_DOC)==BEGIN_DOC) { // if Whitespace before doc, just ignore
+ if ((state&BEGIN_DOC)==BEGIN_DOC) { // if Whitespace before doc, just ignore
break;
}
// fallthrough on purpose
default:
- if((state&BEGIN_DOC)==BEGIN_DOC) { // if there is any data at the start other than XML Tag, it's not XML
+ if ((state&BEGIN_DOC)==BEGIN_DOC) { // if there is any data at the start other than XML Tag, it's not XML
throw new XMLStreamException("Parse Error: This is not an XML Doc");
}
baos.write(c); // save off Characters
@@ -190,7 +190,7 @@ public class XReader {
} catch (IOException e) {
throw new XMLStreamException(e); // all errors parsing will be treated as XMLStreamErrors (like StAX)
}
- if(c==-1 && (state&BEGIN_DOC)==BEGIN_DOC) { // Normally, end of stream is ok, however, we need to know if the
+ if (c==-1 && (state&BEGIN_DOC)==BEGIN_DOC) { // Normally, end of stream is ok, however, we need to know if the
throw new XMLStreamException("Premature End of File"); // document isn't an XML document, so we throw exception if it
} // hasn't yet been determined to be an XML Doc
}
@@ -214,15 +214,15 @@ public class XReader {
String prefix=null,name=null,value=null;
baos.reset();
- while(go && (c=is.read())>=0) {
+ while (go && (c=is.read())>=0) {
++count;
- if(quote!=0) { // If we're in a quote, we only end if we hit another quote of the same time, not preceded by \
- if(c==quote && last!='\\') {
+ if (quote!=0) { // If we're in a quote, we only end if we hit another quote of the same time, not preceded by \
+ if (c==quote && last!='\\') {
quote=0;
} else {
baos.write(c);
}
- } else if((state&COMMENT)==COMMENT) { // similar to Quote is being in a comment
+ } else if ((state&COMMENT)==COMMENT) { // similar to Quote is being in a comment
switch(c) {
case '-':
switch(state) { // XML has a complicated Quote set... <!-- --> ... we keep track if each has been met with flags.
@@ -244,7 +244,7 @@ public class XReader {
}
break;
case '>': // Tag indicator has been found, do we have all the comment characters in line?
- if((state&COMPLETE_COMMENT)==COMPLETE_COMMENT) {
+ if ((state&COMPLETE_COMMENT)==COMPLETE_COMMENT) {
byte ba[] = baos.toByteArray();
tag = new Tag(null,null, new String(ba,0,ba.length-2));
baos.reset();
@@ -254,7 +254,7 @@ public class XReader {
// fall through on purpose
default:
state&=~(COMMENT_D3|COMMENT_D4);
- if((state&IN_COMMENT)!=IN_COMMENT) state&=~IN_COMMENT; // false alarm, it's not actually a comment
+ if ((state&IN_COMMENT)!=IN_COMMENT) state&=~IN_COMMENT; // false alarm, it's not actually a comment
baos.write(c);
}
} else { // Normal Tag Processing loop
@@ -273,7 +273,7 @@ public class XReader {
}
break;
case '!':
- if(last=='<') {
+ if (last=='<') {
state|=COMMENT|COMMENT_E; // likely a comment, continue processing in Comment Loop
}
baos.write(c);
@@ -296,15 +296,15 @@ public class XReader {
case ' ':
case '\t':
case '\n': // white space indicates change in internal tag state, ex between name and between attributes
- if((state&VALUE)==VALUE) {
+ if ((state&VALUE)==VALUE) {
value = baos.toString(); // we're in VALUE state, add characters to Value
- } else if(name==null) {
+ } else if (name==null) {
name = baos.toString(); // we're in Name state (default) add characters to Name
}
baos.reset(); // we've assigned chars, reset buffer
- if(name!=null) { // Name is not null, there's a tag in the offing here...
+ if (name!=null) { // Name is not null, there's a tag in the offing here...
Tag t = new Tag(prefix,name,value);
- if(tag==null) { // Set as the tag to return, if not exists
+ if (tag==null) { // Set as the tag to return, if not exists
tag = t;
} else { // if we already have a Tag, then we'll treat this one as an attribute
tag.add(t);
@@ -314,7 +314,7 @@ public class XReader {
break;
case '\'': // is the character one of two kinds of quote?
case '"':
- if(last!='\\') {
+ if (last!='\\') {
quote=c;
break;
}
@@ -327,10 +327,10 @@ public class XReader {
last = c;
}
int type = state&(DOC_TYPE|COMMENT|END_TAG|START_TAG); // get just the Tag states and turn into Type for Tag
- if(type==0) {
+ if (type==0) {
type=START_TAG;
}
- if(tag!=null) {
+ if (tag!=null) {
tag.state|=type; // add the appropriate Tag States
}
return tag;
@@ -350,20 +350,20 @@ public class XReader {
*/
private Map<String, String> getNss(Map<String, String> nss, Tag t) {
Map<String,String> newnss = null;
- if(t.attribs!=null) {
- for(Tag tag : t.attribs) {
- if("xmlns".equals(tag.prefix)) {
- if(newnss==null) {
+ if (t.attribs!=null) {
+ for (Tag tag : t.attribs) {
+ if ("xmlns".equals(tag.prefix)) {
+ if (newnss==null) {
newnss = new HashMap<>();
- if(nss!=null)newnss.putAll(nss);
+ if (nss!=null)newnss.putAll(nss);
}
newnss.put(tag.name, tag.value);
}
}
}
//return newnss==null?(nss==null?new HashMap<String,String>():nss):newnss;
- if(newnss==null) {
- if(nss==null) {
+ if (newnss==null) {
+ if (nss==null) {
newnss = new HashMap<>();
} else {
newnss = nss;
@@ -399,7 +399,7 @@ public class XReader {
* @param tag
*/
public void add(Tag attrib) {
- if(attribs == null) {
+ if (attribs == null) {
attribs = new ArrayList<>();
}
attribs.add(attrib);
@@ -407,14 +407,14 @@ public class XReader {
public String toString() {
StringBuffer sb = new StringBuffer();
- if(prefix!=null) {
+ if (prefix!=null) {
sb.append(prefix);
sb.append(':');
}
sb.append(name==null?"!!ERROR!!":name);
char quote = ((state&DOC_TYPE)==DOC_TYPE)?'\'':'"';
- if(value!=null) {
+ if (value!=null) {
sb.append('=');
sb.append(quote);
sb.append(value);
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/filter/test/JU_AUTHZServlet.java b/cadi/core/src/test/java/org/onap/aaf/cadi/filter/test/JU_AUTHZServlet.java
index f57bb93e..22ce8abf 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/filter/test/JU_AUTHZServlet.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/filter/test/JU_AUTHZServlet.java
@@ -99,7 +99,7 @@ public class JU_AUTHZServlet {
field.setAccessible(true);
field.set(target, value);
field.setAccessible(false);
- } catch(Exception e) {
+ } catch (Exception e) {
System.err.println("Could not set field [" + fieldName + "] to " + value);
}
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/principal/test/JU_X509Principal.java b/cadi/core/src/test/java/org/onap/aaf/cadi/principal/test/JU_X509Principal.java
index a8839f2c..ea45c128 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/principal/test/JU_X509Principal.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/principal/test/JU_X509Principal.java
@@ -93,7 +93,7 @@ public class JU_X509Principal {
try {
x509 = new X509Principal(cert, cred, null);
fail("Should have thrown an Exception");
- } catch(IOException e) {
+ } catch (IOException e) {
assertThat(e.getMessage(), is("X509 does not have Identity as CN"));
}
@@ -102,7 +102,7 @@ public class JU_X509Principal {
try {
x509 = new X509Principal(cert, cred, null);
fail("Should have thrown an Exception");
- } catch(IOException e) {
+ } catch (IOException e) {
assertThat(e.getMessage(), is("X509 does not have Identity as CN"));
}
@@ -111,7 +111,7 @@ public class JU_X509Principal {
try {
x509 = new X509Principal(cert, cred, null);
fail("Should have thrown an Exception");
- } catch(IOException e) {
+ } catch (IOException e) {
assertThat(e.getMessage(), is("X509 does not have Identity as CN"));
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/taf/dos/test/JU_DenialOfServiceTaf.java b/cadi/core/src/test/java/org/onap/aaf/cadi/taf/dos/test/JU_DenialOfServiceTaf.java
index d67acf3c..47d8f8d1 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/taf/dos/test/JU_DenialOfServiceTaf.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/taf/dos/test/JU_DenialOfServiceTaf.java
@@ -353,7 +353,7 @@ public class JU_DenialOfServiceTaf {
field.setAccessible(true);
field.set(null, value);
field.setAccessible(false);
- } catch(Exception e) {
+ } catch (Exception e) {
System.err.println("Could not set field [" + fieldName + "] to " + value);
}
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
index affaccc5..a3e0db0d 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
@@ -60,7 +60,7 @@ public class JU_AES {
byte[] keyBytes = new byte[AES.AES_KEY_SIZE/8];
char[] codeset = Symm.base64.codeset;
int offset = (Math.abs(codeset[0]) + 47) % (codeset.length - keyBytes.length);
- for(int i = 0; i < keyBytes.length; ++i) {
+ for (int i = 0; i < keyBytes.length; ++i) {
keyBytes[i] = (byte)codeset[i+offset];
}
aes = new AES(keyBytes, 0, keyBytes.length);
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java
index 78a6fa21..60999b69 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_BufferedServletInputStream.java
@@ -151,7 +151,7 @@ public class JU_BufferedServletInputStream {
@Test
public void ByteArrayReadStateIsReadTest() throws Exception {
byte output[] = new byte[200];
- for(int i = 0; i < 2; ++i) {
+ for (int i = 0; i < 2; ++i) {
bsis.mark(0);
bsis.read(output, 0, 100);
Assert.assertEquals(new String(output, 0, expected.length()), expected);
@@ -160,7 +160,7 @@ public class JU_BufferedServletInputStream {
bsis.read(output, 0, output.length);
Assert.assertEquals(new String(output, 0, expected.length()), expected);
bsis = new BufferedServletInputStream(new ByteArrayInputStream(output));
- if(i == 0) {
+ if (i == 0) {
output = new byte[200];
}
}
@@ -286,7 +286,7 @@ public class JU_BufferedServletInputStream {
byte aa[] = new byte[testString.length()]; // 65 count... important for our test (divisible by 5);
int read;
- for(int i=0;i<aa.length;i+=5) {
+ for (int i=0;i<aa.length;i+=5) {
read = bsis.read(aa, i, 5);
assertEquals(5,read);
}
@@ -296,7 +296,7 @@ public class JU_BufferedServletInputStream {
byte bb[] = new byte[aa.length];
read = 0;
- for(int i=0;read>=0;i+=read) {
+ for (int i=0;read>=0;i+=read) {
read = bsis.read(bb,i,5);
switch(i) {
case 65:
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java
index 1bdbc571..4c842915 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Capacitor.java
@@ -58,13 +58,13 @@ public class JU_Capacitor {
assertNull(curr_field.get(cap));
assertEquals(idx_field.get(cap), 0);
- for(int iter = 0; iter < 20; ++iter) {
- for(int i = 0; i < 20; ++i) {
+ for (int iter = 0; iter < 20; ++iter) {
+ for (int i = 0; i < 20; ++i) {
cap.put((byte)('a' + i));
}
cap.setForRead();
byte[] array = new byte[20];
- for(int i = 0; i < 20; ++i) {
+ for (int i = 0; i < 20; ++i) {
array[i]=(byte)cap.read();
}
assertEquals("abcdefghijklmnopqrst", new String(array));
@@ -73,12 +73,12 @@ public class JU_Capacitor {
cap.done();
}
- for(int i = 0; i < 500; i++) {
+ for (int i = 0; i < 500; i++) {
cap.put((byte)'a');
}
cap.setForRead();
byte[] array = new byte[500];
- for(int i = 0; i < 500; ++i) {
+ for (int i = 0; i < 500; ++i) {
array[i]=(byte)cap.read();
}
assertEquals((new String(array)).length(), 500);
@@ -88,7 +88,7 @@ public class JU_Capacitor {
@Test
public void availableTest() {
assertEquals(cap.available(), 0);
- for(int i = 0; i < 100; ++i) {
+ for (int i = 0; i < 100; ++i) {
cap.put((byte)'a');
}
// The Capacitor can hold 256 bytes. After reading 100 bytes,
@@ -114,12 +114,12 @@ public class JU_Capacitor {
byte[] a = b.getBytes();
byte[] c = new byte[b.length()]; // we want to use this to test reading offsets, etc
- for(int i = 0; i < a.length; i += 11) {
+ for (int i = 0; i < a.length; i += 11) {
cap.put(a, i, Math.min(11, a.length-i));
}
cap.reset();
int read;
- for(int i = 0; i < c.length; i += read) {
+ for (int i = 0; i < c.length; i += read) {
read = cap.read(c, i, Math.min(3, c.length-i));
}
assertEquals(b, new String(c));
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
index cba4c46a..967bf221 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
@@ -163,7 +163,7 @@ public class JU_CmdLine {
String filePath = "test/output_key";
File testDir = new File("test");
- if(!testDir.exists()) {
+ if (!testDir.exists()) {
testDir.mkdirs();
}
CmdLine.main(new String[]{"keygen", filePath});
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_PropAccess.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_PropAccess.java
index 6f6f49e1..45f221c4 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_PropAccess.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_PropAccess.java
@@ -115,7 +115,7 @@ public class JU_PropAccess {
});
try {
pa.log(new Exception("This exception was thrown intentionally, please ignore it"));
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Should have thrown an exception");
}
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_ServletContextAccess.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_ServletContextAccess.java
index 15464bf1..7c67f8c9 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_ServletContextAccess.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_ServletContextAccess.java
@@ -89,7 +89,7 @@ public class JU_ServletContextAccess {
try {
sca.log(new Exception("This exception was thrown intentionally, please ignore it"));
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Should have thrown an exception");
}
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSEParser.java b/cadi/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSEParser.java
index 5a1014bc..5f880403 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSEParser.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/wsse/test/JU_WSSEParser.java
@@ -130,12 +130,12 @@ public class JU_WSSEParser {
// is = new BufferedServletInputStream(fis);
// is.mark(0);
// try {
-// while(is.read()>=0);
+// while (is.read()>=0);
// } finally {
// fis.close();
// }
//
-// for(int i=0;i<iter;++i) {
+// for (int i=0;i<iter;++i) {
// start = System.nanoTime();
// is.reset();
// try {