mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Управление whitelist с помощью Reconfigurable
This commit is contained in:
parent
56e5874205
commit
b0b2493935
1 changed files with 37 additions and 2 deletions
|
@ -1,9 +1,13 @@
|
||||||
package ru.gravit.launchserver.auth.provider;
|
package ru.gravit.launchserver.auth.provider;
|
||||||
|
|
||||||
|
import ru.gravit.launchserver.Reconfigurable;
|
||||||
import ru.gravit.launchserver.auth.AuthException;
|
import ru.gravit.launchserver.auth.AuthException;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
import ru.gravit.utils.helper.SecurityHelper;
|
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() {
|
public RejectAuthProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +16,7 @@ public RejectAuthProvider(String message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
private String[] whitelist;
|
private ArrayList<String> whitelist;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthProviderResult auth(String login, String password, String ip) throws AuthException {
|
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() {
|
public void close() {
|
||||||
// Do nothing
|
// 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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue