diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java index 5f9cdc49..74a32934 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java @@ -47,12 +47,12 @@ public void invoke(String... args) { logger.info("OAuth {} | session {}", client.useOAuth, client.sessionObject == null ? "null" : client.sessionObject); logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false", client.auth_id); - if (client.trustLevel != null) { - logger.info("trustLevel | key {} | pubkey {}", client.trustLevel.keyChecked ? "checked" : "unchecked", client.trustLevel.publicKey == null ? "null" : new String(Base64.getEncoder().encode(client.trustLevel.publicKey))); - } - if (client.permissions != null) { - logger.info("Permissions: {}", client.permissions.toString()); - } + } + if (client.trustLevel != null) { + logger.info("trustLevel | key {} | pubkey {}", client.trustLevel.keyChecked ? "checked" : "unchecked", client.trustLevel.publicKey == null ? "null" : new String(Base64.getEncoder().encode(client.trustLevel.publicKey))); + } + if (client.permissions != null) { + logger.info("Permissions: {}", client.permissions.toString()); } })); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java index 40a38952..63529b75 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java @@ -1,6 +1,5 @@ package pro.gravit.launchserver.manangers; -import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.Jwts; import org.apache.logging.log4j.LogManager; @@ -70,11 +69,16 @@ public CheckServerTokenInfo parseCheckServerToken(String token) { } } - public class CheckServerVerifier implements RestoreResponse.ExtendedTokenProvider { + public static class CheckServerVerifier implements RestoreResponse.ExtendedTokenProvider { + private final LaunchServer server; + + public CheckServerVerifier(LaunchServer server) { + this.server = server; + } @Override public boolean accept(Client client, AuthProviderPair pair, String extendedToken) { - var info = parseCheckServerToken(extendedToken); + var info = server.authManager.parseCheckServerToken(extendedToken); if(info == null) { return false; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java index f7398190..e7a51b3c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java @@ -10,6 +10,7 @@ import pro.gravit.launchserver.auth.core.User; import pro.gravit.launchserver.auth.core.UserSession; import pro.gravit.launchserver.auth.protect.AdvancedProtectHandler; +import pro.gravit.launchserver.manangers.AuthManager; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse; @@ -32,6 +33,7 @@ public static void registerProviders(LaunchServer server) { providers.put(LauncherRequestEvent.LAUNCHER_EXTENDED_TOKEN_NAME, new LauncherResponse.LauncherTokenVerifier(server)); providers.put("publicKey", new AdvancedProtectHandler.PublicKeyTokenVerifier(server)); providers.put("hardware", new AdvancedProtectHandler.HardwareInfoTokenVerifier(server)); + providers.put("checkServer", new AuthManager.CheckServerVerifier(server)); registeredProviders = true; } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java index d61f6d6c..3a10075a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java @@ -92,9 +92,12 @@ public void addRole(String role) { public void addAction(String action) { if (actions == null) { - actions = new ArrayList<>(); + actions = new ArrayList<>(1); } actions.add(action); + if(available == null) { + available = new ArrayList<>(1); + } available.add(Pattern.compile(action)); } @@ -154,15 +157,9 @@ public final void setFlag(long mask, boolean value) { @Override public String toString() { - if (roles != null || actions != null) { - return "ClientPermissions{" + - "roles=" + String.join(", ", roles == null ? Collections.emptyList() : roles) + - ", actions=" + String.join(", ", actions == null ? Collections.emptyList() : actions) + - '}'; - } return "ClientPermissions{" + - "permissions=" + permissions + - ", flags=" + flags + + "roles=" + String.join(", ", roles == null ? Collections.emptyList() : roles) + + ", actions=" + String.join(", ", actions == null ? Collections.emptyList() : actions) + '}'; } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 0390f1eb..55e8d8c4 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -156,7 +156,7 @@ public void run(String... args) throws Throwable { { LogHelper.debug("WebSocket connect closed. Try reconnect"); try { - restore(); + Request.reconnect(); getProfiles(); } catch (Exception e) { LogHelper.error(e);