diff --git a/LaunchServer/source/auth/provider/AuthlibAuthProvider.java b/LaunchServer/source/auth/provider/AuthlibAuthProvider.java index 251ad43..55f50a7 100644 --- a/LaunchServer/source/auth/provider/AuthlibAuthProvider.java +++ b/LaunchServer/source/auth/provider/AuthlibAuthProvider.java @@ -23,14 +23,18 @@ public class AuthlibAuthProvider extends AuthProvider { private static final Pattern UUID_REGEX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); - private static final java.net.URL URL; + private static URL URL; private static String authUrl; // TODO: // https://wiki.vg/Authentication#Refresh // https://wiki.vg/Authentication#Signout - static + + AuthlibAuthProvider(BlockConfigEntry block) { + super(block); + authUrl = block.getEntryValue("authUrl", StringConfigEntry.class); + try { // Docs: https://wiki.vg/Authentication#Authenticate @@ -42,12 +46,6 @@ } } - AuthlibAuthProvider(BlockConfigEntry block) - { - super(block); - authUrl = block.getEntryValue("authUrl", StringConfigEntry.class); - } - public static JsonObject makeAuthlibRequest(URL url, JsonObject request) throws IOException { HttpURLConnection connection = request == null ? @@ -75,7 +73,7 @@ // Parse response String json = new String(IOHelper.read(input), charsetObject); - LogHelper.subDebug("Raw Mojang response: '" + json + '\''); + LogHelper.subDebug("Raw Authlib response: '" + json + '\''); return json.isEmpty() ? null : Json.parse(json).asObject(); } } @@ -91,7 +89,7 @@ JsonObject response = makeAuthlibRequest(URL, request); if (response == null) { - authError("Empty authlib response"); + authError("Empty Authlib response"); } JsonValue errorMessage = response.get("errorMessage"); if (errorMessage != null) diff --git a/LaunchServer/source/texture/AuthlibTextureProvider.java b/LaunchServer/source/texture/AuthlibTextureProvider.java index ff17e62..58739d0 100644 --- a/LaunchServer/source/texture/AuthlibTextureProvider.java +++ b/LaunchServer/source/texture/AuthlibTextureProvider.java @@ -12,7 +12,7 @@ import launcher.helper.VerifyHelper; import launcher.serialize.config.entry.BlockConfigEntry; import launcher.serialize.config.entry.StringConfigEntry; -import launchserver.auth.provider.MojangAuthProvider; +import launchserver.auth.provider.AuthlibAuthProvider; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -38,15 +38,8 @@ public AuthlibTextureProvider(BlockConfigEntry block) { super(block); - - // "https://api.mojang.com/users/profiles/minecraft/" setUuidURL = block.getEntryValue("usersURL", StringConfigEntry.class); - // "https://sessionserver.mojang.com/session/minecraft/profile/" setProfileURL = block.getEntryValue("profileURL", StringConfigEntry.class); - - // TODO: Verify - //IOHelper.verifyURL(setUuidURL); - //IOHelper.verifyURL(setProfileURL); } @Override @@ -85,7 +78,7 @@ { // TODO Don't query UUID by username if using mojang auth handler (not implemented yet) URL uuidURL = new URL(setUuidURL + IOHelper.urlEncode(username)); - JsonObject uuidResponse = MojangAuthProvider.makeMojangRequest(uuidURL, null); + JsonObject uuidResponse = AuthlibAuthProvider.makeAuthlibRequest(uuidURL, null); if (uuidResponse == null) { throw new IllegalArgumentException("Empty UUID response"); @@ -94,7 +87,7 @@ // Obtain player profile URL profileURL = new URL(setProfileURL + uuidResolved); - JsonObject profileResponse = MojangAuthProvider.makeMojangRequest(profileURL, null); + JsonObject profileResponse = AuthlibAuthProvider.makeAuthlibRequest(profileURL, null); if (profileResponse == null) { throw new IllegalArgumentException("Empty Authlib response"); diff --git a/buildnumber b/buildnumber index 8d7eb9f..6d2b988 100644 --- a/buildnumber +++ b/buildnumber @@ -1 +1 @@ -541, 30.04.2021 \ No newline at end of file +544, 01.05.2021 \ No newline at end of file