Merge "Sonar fix: Perm.java"
[aaf/authz.git] / auth / auth-core / src / main / java / org / onap / aaf / auth / validation / Validator.java
index c0f2f53..6d519c6 100644 (file)
@@ -86,8 +86,15 @@ public class Validator {
     }
 
     protected final boolean noMatch(String str, Pattern p) {
-        return !p.matcher(str).matches();
+        return str==null || !p.matcher(str).matches();
     }
+
+    protected final void match(String text, String str, Pattern p) {
+       if(str==null || !p.matcher(str).matches()) {
+               msg(text);
+       }
+    }
+
     protected final boolean nob(String str, Pattern p) {
         return str==null || !p.matcher(str).matches(); 
     }
@@ -185,13 +192,16 @@ public class Validator {
     }
 
     public final Validator role(String user, String role) {
+       boolean quit = false;
        if(role==null) {
                msg("Role is null");
+               quit = true;
        }
        if(user==null) {
-               msg("User is null");                    
+               msg("User is null");
+               quit = true;
        }
-       if(!err()) {
+       if(!quit) {
                if(role.startsWith(user) && role.endsWith(":user")) {
                        if(!(role.length() == user.length() + 5)) {
                    msg("Role [" + role + "] is invalid.");