Implement restricted users rules with * wildcard support (Enhancement #1278 and #1227) (#1297)

This commit is contained in:
HexelDev
2017-07-25 21:39:31 +02:00
committed by Gabriele C
parent 70d7249e12
commit a973dc3f6d
2 changed files with 17 additions and 13 deletions
@@ -160,19 +160,14 @@ public class ValidationService implements Reloadable {
for(String restriction : restrictions) {
if(restriction.startsWith("regex:")) {
restriction = restriction.replace("regex:", "");
if(ip.matches(restriction)) {
return true;
}
if(domain.matches(restriction)) {
return true;
}
} else {
if(ip.equals(restriction)) {
return true;
}
if(domain.equalsIgnoreCase(restriction)) {
return true;
}
restriction = restriction.replaceAll("\\*","(.*)");
}
if(ip.matches(restriction)) {
return true;
}
if(domain.matches(restriction)) {
return true;
}
}
return false;