X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fvalidation%2FValidator.java;fp=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fvalidation%2FValidator.java;h=1e40604390c06977c26f6c281d8535668b0bbacc;hp=fcbccb12da4b3d0b778f29d8563003e9504ff646;hb=82755753f41112e1cdd91b2994620ad074dfbf20;hpb=e78d297795f08d3ecdc176ff10c6c77570828e17 diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java index fcbccb12..1e406043 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java @@ -47,7 +47,9 @@ public class Validator { private final Pattern actionChars; private final Pattern instChars; private StringBuilder msgs; - + public static final String PERM_TYPE = "Perm Type ["; + public static final String IS_INVALID = "] is invalid."; + public static final String ROLE_STR = "Role ["; static { nsKeywords = new ArrayList<>(); nsKeywords.add(".access"); @@ -145,7 +147,7 @@ public class Validator { public final Validator permType(String type) { if (nob(type,NAME_CHARS)) { - msg("Perm Type [" +type + "] is invalid."); + msg(PERM_TYPE +type + IS_INVALID); } return this; } @@ -158,7 +160,7 @@ public class Validator { } else { if(!(type.startsWith(user) && type.endsWith(":id"))) { if(nob(type,NAME_CHARS)) { - msg("Perm Type [" + type + "] is invalid."); + msg(PERM_TYPE + type + IS_INVALID); } } } @@ -171,14 +173,14 @@ public class Validator { } else if (ns==null) { msg("Perm NS is null"); } else if (nob(type,NAME_CHARS)) { - msg("Perm Type [" + (ns+(type.length()==0?"":'.')) + type + "] is invalid."); + msg(PERM_TYPE + (ns+(type.length()==0?"":'.')) + type + IS_INVALID); } return this; } public final Validator permInstance(String instance) { if(!"/".equals(instance) && nob(instance,instChars)) { - msg("Perm Instance [" + instance + "] is invalid."); + msg("Perm Instance [" + instance + IS_INVALID); } return this; } @@ -186,7 +188,7 @@ public class Validator { public final Validator permAction(String action) { // TODO check for correct Splits? Type|Instance|Action ? if (nob(action, actionChars)) { - msg("Perm Action [" + action + "] is invalid."); + msg("Perm Action [" + action + IS_INVALID); } return this; } @@ -204,10 +206,10 @@ public class Validator { if(!quit) { if(role.startsWith(user) && role.endsWith(":user")) { if(!(role.length() == user.length() + 5)) { - msg("Role [" + role + "] is invalid."); + msg(ROLE_STR + role + IS_INVALID); } } else if (nob(role, NAME_CHARS)) { - msg("Role [" + role + "] is invalid."); + msg(ROLE_STR + role + IS_INVALID); } } return this; @@ -216,7 +218,7 @@ public class Validator { public final Validator role(String role) { if (nob(role, NAME_CHARS)) { - msg("Role [" + role + "] is invalid."); + msg(ROLE_STR + role + IS_INVALID); } return this; } @@ -226,7 +228,7 @@ public class Validator { msg("NS is null"); return this; } else if (nob(ns,NAME_CHARS)) { - msg("NS [" + ns + "] is invalid."); + msg("NS [" + ns + IS_INVALID); } for (String s : nsKeywords) { if (ns.endsWith(s)) {