From 115b7e872cab733b0bf500112f7b0d22951e624a Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 31 Aug 2019 22:03:33 +0700 Subject: [PATCH 1/7] =?UTF-8?q?[DOC]=20=D0=9D=D0=B5=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D1=8B=D0=B5=20HTML=20=D1=82?= =?UTF-8?q?=D0=B5=D0=B3=D0=B8=20=D0=B2=20LauncherModule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launcher/modules/LauncherModule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java index 7878bb00..2392d725 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java @@ -126,8 +126,8 @@ public LauncherModule preInit() * Modify module description, dependencies * Add modules * Read configuration - * @param initContext null on module initialization during boot or startup - * Not null during module initialization while running + * @param initContext null on module initialization during boot or startup + * Not null during module initialization while running */ public abstract void init(LauncherInitContext initContext); From c44ab07bf08d6ad998338df187b4c9ec4609d04b Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 31 Aug 2019 22:15:42 +0700 Subject: [PATCH 2/7] =?UTF-8?q?[ANY][DOC]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B8=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launcher/modules/LauncherModule.java | 4 ++-- modules | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java index 2392d725..f1bd173b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java @@ -126,8 +126,8 @@ public LauncherModule preInit() * Modify module description, dependencies * Add modules * Read configuration - * @param initContext null on module initialization during boot or startup - * Not null during module initialization while running + * @param initContext null on module initialization during boot or startup + * Not null during module initialization while running */ public abstract void init(LauncherInitContext initContext); diff --git a/modules b/modules index 03cb8cb0..1d8b759f 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 03cb8cb081fe48755e691f5ed56f0d2da6a1ca2f +Subproject commit 1d8b759f6fdda6e9ae6306886a75d8ddd1e5c159 From e9d0ac7f6675af34632628949bc38a0b8e454a36 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 31 Aug 2019 22:36:20 +0700 Subject: [PATCH 3/7] [ANY] Release 5.0.7 stable --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 96667473..2f0a7cae 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -24,7 +24,7 @@ public final class Version { public static final int MINOR = 0; public static final int PATCH = 7; public static final int BUILD = 1; - public static final Version.Type RELEASE = Version.Type.DEV; + public static final Version.Type RELEASE = Type.STABLE; @LauncherAPI public Version(int major, int minor, int patch) { diff --git a/build.gradle b/build.gradle index e06ea52b..62c43e91 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ id 'signing' } group = 'pro.gravit.launcher' -version = '5.0.7-SNAPSHOT' +version = '5.0.7' configure(subprojects.findAll { it.name != 'modules' }) { apply plugin: 'idea' From 988d220f353bf1acba737aac4c39b6ffa890c586 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 31 Aug 2019 22:38:41 +0700 Subject: [PATCH 4/7] [ANY] 5.0.8 dev --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 2f0a7cae..b4bbc4e2 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -22,9 +22,9 @@ public final class Version { public final Type release; public static final int MAJOR = 5; public static final int MINOR = 0; - public static final int PATCH = 7; + public static final int PATCH = 8; public static final int BUILD = 1; - public static final Version.Type RELEASE = Type.STABLE; + public static final Version.Type RELEASE = Type.DEV; @LauncherAPI public Version(int major, int minor, int patch) { diff --git a/build.gradle b/build.gradle index 62c43e91..5f99cee4 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ id 'signing' } group = 'pro.gravit.launcher' -version = '5.0.7' +version = '5.0.8-SNAPSHOT' configure(subprojects.findAll { it.name != 'modules' }) { apply plugin: 'idea' From 49e26d0d2919d92e26b394d36f16e36965819131 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 1 Sep 2019 20:07:23 +0700 Subject: [PATCH 5/7] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B8?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20Guard=20=D0=B8=20ClassCastException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/pro/gravit/launcher/LauncherEngine.java | 2 +- .../websockets/StandartClientWebSocketService.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index c48bf6dd..47b571b7 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -113,13 +113,13 @@ public void start(String... args) throws Throwable { } }; } - LauncherGuardManager.initGuard(false); if(UpdateRequest.getController() == null) UpdateRequest.setController(new LauncherUpdateController()); Objects.requireNonNull(args, "args"); if (started.getAndSet(true)) throw new IllegalStateException("Launcher has been already started"); LauncherEngine.modulesManager.invokeEvent(new ClientEngineInitPhase(this)); runtimeProvider.preLoad(); + LauncherGuardManager.initGuard(false); FunctionalBridge.getHWID = CommonHelper.newThread("GetHWID Thread", true, FunctionalBridge::getHWID); FunctionalBridge.getHWID.start(); LogHelper.debug("Dir: %s", DirBridge.dir); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 0b9da5ab..f56717d9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -7,6 +7,7 @@ import javax.net.ssl.SSLException; +import pro.gravit.launcher.events.ExceptionEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.RequestException; @@ -67,6 +68,10 @@ public WebSocketEvent get() throws InterruptedException, ExecutionException { ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result; throw new ExecutionException(new RequestException(errorRequestEvent.error)); } + if (event.result.getType().equals("exception")) { + ExceptionEvent error = (ExceptionEvent) event.result; + throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message))); + } return result; } @@ -80,10 +85,14 @@ public WebSocketEvent get(long timeout, TimeUnit unit) throws InterruptedExcepti } WebSocketEvent result = event.result; waitEventHandler.requests.remove(event); - if (event.result.getType().equals("error") || event.result.getType().equals("exception")) { + if (event.result.getType().equals("error")) { ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) event.result; throw new ExecutionException(new RequestException(errorRequestEvent.error)); } + if (event.result.getType().equals("exception")) { + ExceptionEvent error = (ExceptionEvent) event.result; + throw new ExecutionException(new RequestException(String.format("LaunchServer fatal error: %s: %s", error.clazz, error.message))); + } return result; } } From d9c4cfdbc89e9954ba6b34d21d9becae112f0e06 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 1 Sep 2019 20:12:50 +0700 Subject: [PATCH 6/7] =?UTF-8?q?[FEATURE]=20email=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launchserver/dao/User.java | 1 + .../launchserver/socket/response/auth/RegisterResponse.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java index 0573c2c3..c25d8c13 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java @@ -36,6 +36,7 @@ public class User { private byte[] password; private String accessToken; public String serverID; + public String email; private String password_salt; public long permissions; //TODO: заменить EAGER на LASY и придумать способ сохранить сессию diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java index b5fae77e..97b89be9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java @@ -14,6 +14,7 @@ public class RegisterResponse extends SimpleResponse { public String login; public String password; + public String email; public byte[] verifyHash; @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception @@ -32,6 +33,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception } User user = new User(); user.username = login; + user.email = email; user.setPassword(password); user.uuid = UUID.randomUUID(); server.config.dao.userService.saveUser(user); From aea67ae8ec8f9394936ff30374db888fb99e3236 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 1 Sep 2019 20:25:15 +0700 Subject: [PATCH 7/7] =?UTF-8?q?[FEATURE]=20=D0=A1=D0=BC=D0=B5=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20=D1=83=D1=87=D0=B0=D1=81=D1=82=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/dao/User.java | 2 +- .../launchserver/socket/WebSocketService.java | 11 +--- .../response/auth/SetPasswordResponse.java | 55 +++++++++++++++++++ .../request/SetPasswordRequestEvent.java | 10 ++++ .../websockets/ClientWebSocketService.java | 21 +------ 5 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java index c25d8c13..c6766218 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/User.java @@ -30,13 +30,13 @@ public class User { private long id; @Column(unique = true) public String username; + public String email; @Column(unique = true) public UUID uuid; @Column(name = "password") private byte[] password; private String accessToken; public String serverID; - public String email; private String password_salt; public long permissions; //TODO: заменить EAGER на LASY и придумать способ сохранить сессию diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index dedf17da..a564b4aa 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -1,7 +1,6 @@ package pro.gravit.launchserver.socket; import java.lang.reflect.Type; -import java.util.HashMap; import com.google.gson.Gson; @@ -21,14 +20,7 @@ import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.launchserver.socket.response.admin.AddLogListenerResponse; import pro.gravit.launchserver.socket.response.admin.ExecCommandResponse; -import pro.gravit.launchserver.socket.response.auth.AuthResponse; -import pro.gravit.launchserver.socket.response.auth.CheckServerResponse; -import pro.gravit.launchserver.socket.response.auth.GetAvailabilityAuthResponse; -import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; -import pro.gravit.launchserver.socket.response.auth.ProfilesResponse; -import pro.gravit.launchserver.socket.response.auth.RegisterResponse; -import pro.gravit.launchserver.socket.response.auth.RestoreSessionResponse; -import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; +import pro.gravit.launchserver.socket.response.auth.*; import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUsername; @@ -132,6 +124,7 @@ public static void registerResponses() { providers.register("verifySecureToken", VerifySecureTokenResponse.class); providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class); providers.register("register", RegisterResponse.class); + providers.register("setPassword", SetPasswordResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java new file mode 100644 index 00000000..93f2fb26 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java @@ -0,0 +1,55 @@ +package pro.gravit.launchserver.socket.response.auth; + +import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launcher.events.request.SetPasswordRequestEvent; +import pro.gravit.launchserver.dao.User; +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.response.SimpleResponse; + +public class SetPasswordResponse extends SimpleResponse { + public String oldPassword; + public String newPassword; + public String username; + @Override + public String getType() { + return "setPassword"; + } + + @Override + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { + if(( oldPassword == null && username == null ) || newPassword == null) + { + sendError("Request invalid"); + return; + } + if(!client.isAuth) + { + sendError("You not authorized"); + return; + } + if(username != null && !client.permissions.canAdmin) + { + sendError("You not admin"); + return; + } + if(username != null) + { + User user = server.config.dao.userService.findUserByUsername(username); + user.setPassword(newPassword); + sendResult(new SetPasswordRequestEvent()); + } + else + { + User user = server.config.dao.userService.findUserByUsername(client.username); + if(user.verifyPassword(oldPassword)) + { + user.setPassword(newPassword); + sendResult(new SetPasswordRequestEvent()); + } + else + { + sendError("Old password incorrect"); + } + } + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java new file mode 100644 index 00000000..96efa2c0 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.events.request; + +import pro.gravit.launcher.events.RequestEvent; + +public class SetPasswordRequestEvent extends RequestEvent { + @Override + public String getType() { + return "setPassword"; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index c16300c8..5b62226d 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -12,25 +12,7 @@ import pro.gravit.launcher.Launcher; import pro.gravit.launcher.events.ExceptionEvent; -import pro.gravit.launcher.events.request.AuthRequestEvent; -import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; -import pro.gravit.launcher.events.request.CheckServerRequestEvent; -import pro.gravit.launcher.events.request.ErrorRequestEvent; -import pro.gravit.launcher.events.request.ExecCommandRequestEvent; -import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; -import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent; -import pro.gravit.launcher.events.request.JoinServerRequestEvent; -import pro.gravit.launcher.events.request.LauncherRequestEvent; -import pro.gravit.launcher.events.request.LogEvent; -import pro.gravit.launcher.events.request.ProfileByUUIDRequestEvent; -import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; -import pro.gravit.launcher.events.request.ProfilesRequestEvent; -import pro.gravit.launcher.events.request.RegisterRequestEvent; -import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; -import pro.gravit.launcher.events.request.SetProfileRequestEvent; -import pro.gravit.launcher.events.request.UpdateListRequestEvent; -import pro.gravit.launcher.events.request.UpdateRequestEvent; -import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent; +import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.request.WebSocketEvent; @@ -126,6 +108,7 @@ public void registerResults() { results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); results.register("exception", ExceptionEvent.class); results.register("register", RegisterRequestEvent.class); + results.register("setpassword", SetPasswordRequestEvent.class); } public void registerHandler(EventHandler eventHandler) {