X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Faaf%2FAAFPermission.java;h=8c39e44db42e23a705bb35e3230b5f03e60751a4;hb=3d1706fcbe7f95830ff6fd23cf679ee55c6d0595;hp=c4876f29c87c5f11c5954fb59645ca49f4995844;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java index c4876f29..8c39e44d 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java @@ -50,7 +50,7 @@ public class AAFPermission implements Permission { type = name; this.instance = instance; this.action = action; - if(ns==null) { + if (ns==null) { key = type + '|' + instance + '|' + action; } else { key = ns + '|' + type + '|' + instance + '|' + action; @@ -64,7 +64,7 @@ public class AAFPermission implements Permission { type = name; this.instance = instance; this.action = action; - if(ns==null) { + if (ns==null) { key = type + '|' + instance + '|' + action; } else { key = ns + '|' + type + '|' + instance + '|' + action; @@ -83,11 +83,14 @@ public class AAFPermission implements Permission { * If you want a simple field comparison, it is faster without REGEX */ public boolean match(Permission p) { + if(p==null) { + return false; + } String aafNS; String aafType; String aafInstance; String aafAction; - if(p instanceof AAFPermission) { + if (p instanceof AAFPermission) { AAFPermission ap = (AAFPermission)p; // Note: In AAF > 1.0, Accepting "*" from name would violate multi-tenancy // Current solution is only allow direct match on Type. @@ -125,15 +128,15 @@ public class AAFPermission implements Permission { } } boolean typeMatches; - if(aafNS==null) { - if(ns==null) { + if (aafNS==null) { + if (ns==null) { typeMatches = aafType.equals(type); } else { typeMatches = aafType.equals(ns+'.'+type); } - } else if(ns==null) { + } else if (ns==null) { typeMatches = type.equals(aafNS+'.'+aafType); - } else if(aafNS.length() == ns.length()) { + } else if (aafNS.length() == ns.length()) { typeMatches = aafNS.equals(ns) && aafType.equals(type); } else { // Allow for restructuring of NS/Perm structure typeMatches = (aafNS+'.'+aafType).equals(ns+'.'+type);