public DelIP() {
super("delip");
}
public void execute(String[] parameterList, Connection connection, User user, FileSystem fs) {
User u;
if (parameterList.length >= 3) {
if (!user.hasPermission(UserPermission.USEREDIT) && !currentUserIsGadminForUser(parameterList[1], user)) {
connection.respond("531 Permission denied.");
return;
} else {
try {
u = ServiceManager.getServices().getUserbase().getUser(parameterList[1]); // this means that we are doing the user lookup twice, but it doesn't really matter, since it's O(1) in a hash map, and this happens rarely
} catch (NoSuchUserException e) {
connection.respond("500 " + e.getMessage());
return;
}
}
} else if (parameterList.length == 2) {
u = user;
} else {
connection.respond("500 Syntax error: site delip [username] ident@ip");
return;
}
String malformedIps = "";
String removedIps = "";
String invalidIps = "";
for (int i = 2; i < parameterList.length; i++) {
if (ip.matcher(parameterList[i]).matches()) {
if (u.getIps().contains(parameterList[i])) {
u.delIp(parameterList[i]);
removedIps += parameterList[i] + ' ';
} else {
invalidIps += parameterList[i] + ' ';
}
} else {