From 172eb97ce68826b34df410016700dda873a55606 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 26 Dec 2018 19:03:34 +0700 Subject: [PATCH] =?UTF-8?q?JsonFilePermissionsHandler=20=D1=82=D0=B5=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=8C=20Reloadable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 13 +++++++++++++ .../permissions/JsonFilePermissionsHandler.java | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 823c1f01..666cab6a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -364,6 +364,19 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { reloadManager = new ReloadManager(); GarbageManager.registerNeedGC(sessionManager); GarbageManager.registerNeedGC(limiter); + if(config.permissionsHandler instanceof Reloadable) + reloadManager.registerReloadable("permissionsHandler",(Reloadable) config.permissionsHandler); + if(config.authHandler instanceof Reloadable) + reloadManager.registerReloadable("authHandler",(Reloadable) config.authHandler); + for(int i=0;i { try { mirrorManager.addMirror(s); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index 6016d73f..fb15aa7c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -2,6 +2,7 @@ import com.google.gson.reflect.TypeToken; import ru.gravit.launcher.Launcher; +import ru.gravit.launchserver.Reloadable; import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.launchserver.manangers.PermissionsManager; import ru.gravit.utils.helper.IOHelper; @@ -16,9 +17,23 @@ import java.util.HashMap; import java.util.Map; -public class JsonFilePermissionsHandler extends PermissionsHandler { +public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable { public String filename = "permissions.json"; public static Map map; + + @Override + public void reload() throws Exception { + map.clear(); + Path path = Paths.get(filename); + Type type = new TypeToken>(){}.getType(); + try(Reader reader = IOHelper.newReader(path)) + { + map = Launcher.gson.fromJson(reader,type); + } catch (IOException e) { + LogHelper.error(e); + } + } + public static class Enity { public String username;