From b0b2493935b89e61e13ea3f3a51418e311970249 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 26 Dec 2018 20:01:36 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20whitelist=20=D1=81=20=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=BE=D1=89=D1=8C=D1=8E=20Reconfigurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/provider/RejectAuthProvider.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java index 56299bd0..16ca7081 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -1,9 +1,13 @@ package ru.gravit.launchserver.auth.provider; +import ru.gravit.launchserver.Reconfigurable; import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; -public final class RejectAuthProvider extends AuthProvider { +import java.util.ArrayList; + +public final class RejectAuthProvider extends AuthProvider implements Reconfigurable { public RejectAuthProvider() { } @@ -12,7 +16,7 @@ public RejectAuthProvider(String message) { } private String message; - private String[] whitelist; + private ArrayList whitelist; @Override public AuthProviderResult auth(String login, String password, String ip) throws AuthException { @@ -33,4 +37,35 @@ public AuthProviderResult auth(String login, String password, String ip) throws public void close() { // Do nothing } + + @Override + public void reconfig(String action, String[] args) { + if(action.equals("message")) + { + message = args[0]; + LogHelper.info("New reject message: %s", message); + } + else if(action.equals("whitelist.add")) + { + if(whitelist == null) whitelist = new ArrayList<>(); + whitelist.add(args[0]); + } + else if(action.equals("whitelist.remove")) + { + if(whitelist == null) whitelist = new ArrayList<>(); + whitelist.remove(args[0]); + } + else if(action.equals("whitelist.clear")) + { + whitelist.clear(); + } + } + + @Override + public void printConfigHelp() { + LogHelper.info("message [new message] - set message"); + LogHelper.info("whitelist.add [username] - add username to whitelist"); + LogHelper.info("whitelist.remove [username] - remove username into whitelist"); + LogHelper.info("whitelist.clear - clear whitelist"); + } }