From 757c7690cb009a2f688e5b7de14bfdd06c883d68 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 17 Feb 2019 14:15:57 +0300 Subject: [PATCH] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8=20(#1?= =?UTF-8?q?74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] MojangAuthProvider и его URL. * [FIX] Вправлены JFX классы, лишние убраны, т. к. теперь можно легко доставить JFoenix или аналоги. * [FIX] BinaryFileAuthHandler теперь работает. * [FIX] BinaryFileAuthHandler вынесен в LegacySupport. * [FEATURE] Переход на ThreadPool. * [ANY] Обновлены модули. * [FIX] Ошибки merge. --- CODEOFCONDUCT.md => CODE_OF_CONDUCT.md | 0 .../auth/provider/AuthProvider.java | 3 - .../auth/provider/MojangAuthProvider.java | 69 ------------------- .../provider/MojangAuthProviderResult.java | 14 ---- modules | 2 +- 5 files changed, 1 insertion(+), 87 deletions(-) rename CODEOFCONDUCT.md => CODE_OF_CONDUCT.md (100%) delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProviderResult.java diff --git a/CODEOFCONDUCT.md b/CODE_OF_CONDUCT.md similarity index 100% rename from CODEOFCONDUCT.md rename to CODE_OF_CONDUCT.md diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java index b797b7ad..6883f636 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java @@ -29,9 +29,6 @@ public static void registerProviders() { registerProvider("null", NullAuthProvider.class); registerProvider("accept", AcceptAuthProvider.class); registerProvider("reject", RejectAuthProvider.class); - - // Auth providers that doesn't do nothing :D - registerProvider("mojang", MojangAuthProvider.class); registerProvider("mysql", MySQLAuthProvider.class); registerProvider("request", RequestAuthProvider.class); registerProvider("json", JsonAuthProvider.class); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java deleted file mode 100644 index 5305c26f..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -package ru.gravit.launchserver.auth.provider; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import ru.gravit.utils.HTTPRequest; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.UUID; -import java.util.regex.Pattern; - -public final class MojangAuthProvider extends AuthProvider { - private static final Pattern UUID_REGEX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); - private static final URL URL; - private static final Gson gson = new Gson(); - - static { - try { - URL = new URL("https://authserver.com.mojang.com/authenticate"); - } catch (MalformedURLException e) { - throw new InternalError(e); - } - } - - public class mojangAuth { - public mojangAuth(String username, String password) { - this.username = username; - this.password = password; - name = "Minecraft"; - version = 1; - } - - String name; - int version; - String username; - String password; - - } - - @Override - public AuthProviderResult auth(String login, String password, String ip) throws Exception { - mojangAuth mojangAuth = new mojangAuth(login, password); - JsonElement request = gson.toJsonTree(mojangAuth); - - // Verify there's no error - JsonObject response = HTTPRequest.jsonRequest(request, URL).getAsJsonObject(); - if (response == null) - authError("Empty com.mojang response"); - JsonElement errorMessage = response.get("errorMessage"); - if (errorMessage != null) - authError(errorMessage.getAsString()); - - // Parse JSON data - JsonObject selectedProfile = response.get("selectedProfile").getAsJsonObject(); - String username = selectedProfile.get("name").getAsString(); - String accessToken = response.get("clientToken").getAsString(); - UUID uuid = UUID.fromString(UUID_REGEX.matcher(selectedProfile.get("id").getAsString()).replaceFirst("$1-$2-$3-$4-$5")); - String launcherToken = response.get("accessToken").getAsString(); - - // We're done - return new MojangAuthProviderResult(username, accessToken, uuid, launcherToken); - } - - @Override - public void close() { - // Do nothing - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProviderResult.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProviderResult.java deleted file mode 100644 index 123dbe05..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProviderResult.java +++ /dev/null @@ -1,14 +0,0 @@ -package ru.gravit.launchserver.auth.provider; - -import java.util.UUID; - -public final class MojangAuthProviderResult extends AuthProviderResult { - public final UUID uuid; - public final String launcherToken; - - public MojangAuthProviderResult(String username, String accessToken, UUID uuid, String launcherToken) { - super(username, accessToken); - this.uuid = uuid; - this.launcherToken = launcherToken; - } -} diff --git a/modules b/modules index 14d93a04..90a3b3ea 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 14d93a04d551ae36f68bd74d61445d8c7d7bd076 +Subproject commit 90a3b3eac726659a64410ea3134f8bc22893de32