diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index b218d1f2..0365ea7c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -21,6 +21,7 @@ public final class JsonHWIDHandler extends HWIDHandler { private URL urlBan; private URL urlUnBan; private URL urlGet; + private String apiKey; public class banRequest { public banRequest(OshiHWID hwid) { @@ -28,6 +29,12 @@ public banRequest(OshiHWID hwid) { } OshiHWID hwid; + String apiKey; + + public banRequest(OshiHWID hwid, String apiKey) { + this.hwid = hwid; + this.apiKey = apiKey; + } } public class checkRequest { @@ -38,7 +45,13 @@ public checkRequest(String username, OshiHWID hwid) { String username; OshiHWID hwid; + String apiKey; + public checkRequest(String username, OshiHWID hwid, String apiKey) { + this.username = username; + this.hwid = hwid; + this.apiKey = apiKey; + } } public class Result { @@ -56,12 +69,18 @@ public HWIDRequest(String username) { } String username; + String apiKey; + + public HWIDRequest(String username, String apiKey) { + this.username = username; + this.apiKey = apiKey; + } } @Override public void ban(List l_hwid) throws HWIDException { for (HWID hwid : l_hwid) { - banRequest request = new banRequest((OshiHWID) hwid); + banRequest request = new banRequest((OshiHWID) hwid, apiKey); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan); Result r = gson.fromJson(result, Result.class); @@ -75,7 +94,7 @@ public void ban(List l_hwid) throws HWIDException { @Override public void check0(HWID hwid, String username) throws HWIDException { - checkRequest request = new checkRequest(username, (OshiHWID) hwid); + checkRequest request = new checkRequest(username, (OshiHWID) hwid, apiKey); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), url); BannedResult r = gson.fromJson(result, BannedResult.class); @@ -96,7 +115,7 @@ public void close() { @Override public List getHwid(String username) throws HWIDException { ArrayList hwids = new ArrayList<>(); - HWIDRequest request = new HWIDRequest(username); + HWIDRequest request = new HWIDRequest(username, apiKey); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlGet); OshiHWID[] r = gson.fromJson(result, OshiHWID[].class); @@ -111,7 +130,7 @@ public List getHwid(String username) throws HWIDException { @Override public void unban(List l_hwid) throws HWIDException { for (HWID hwid : l_hwid) { - banRequest request = new banRequest((OshiHWID) hwid); + banRequest request = new banRequest((OshiHWID) hwid, apiKey); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlUnBan); Result r = gson.fromJson(result, Result.class); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java index 26bd7a24..9db4f054 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -13,6 +13,7 @@ public final class JsonAuthProvider extends AuthProvider { private static Gson gson = new Gson(); private URL url; + private String apiKey; public class authResult { String username; @@ -27,14 +28,22 @@ public authRequest(String username, String password, String ip) { this.ip = ip; } + public authRequest(String username, String password, String ip, String apiKey) { + this.username = username; + this.password = password; + this.ip = ip; + this.apiKey = apiKey; + } + String username; String password; String ip; + String apiKey; } @Override public AuthProviderResult auth(String login, String password, String ip) throws IOException { - authRequest authRequest = new authRequest(login, password, ip); + authRequest authRequest = new authRequest(login, password, ip, apiKey); JsonElement request = gson.toJsonTree(authRequest); JsonElement content = HTTPRequest.jsonRequest(request, url); if (!content.isJsonObject()) diff --git a/modules b/modules index b582cd64..ee2f9e66 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit b582cd6405d45d4478e62ca11045a34378c96d9d +Subproject commit ee2f9e6646a8f1972ceda68d56e88e71ab74f78f