mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[REFACTOR] Upgrade to Java 17
This commit is contained in:
parent
eec54ad4d9
commit
fbbde7991e
12 changed files with 21 additions and 51 deletions
|
@ -12,8 +12,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = '11'
|
sourceCompatibility = '17'
|
||||||
targetCompatibility = '11'
|
targetCompatibility = '17'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
compileOnlyA
|
compileOnlyA
|
||||||
|
|
|
@ -247,18 +247,10 @@ public void invoke(String... args) throws Exception {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "full":
|
case "full" -> reload(ReloadType.FULL);
|
||||||
reload(ReloadType.FULL);
|
case "no_auth" -> reload(ReloadType.NO_AUTH);
|
||||||
break;
|
case "no_components" -> reload(ReloadType.NO_COMPONENTS);
|
||||||
case "no_auth":
|
default -> reload(ReloadType.FULL);
|
||||||
reload(ReloadType.NO_AUTH);
|
|
||||||
break;
|
|
||||||
case "no_components":
|
|
||||||
reload(ReloadType.NO_COMPONENTS);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reload(ReloadType.FULL);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,9 +85,6 @@ public static void main(String[] args) throws Exception {
|
||||||
logger.warn("LaunchServer signed incorrectly. Status: {}", result.type.name());
|
logger.warn("LaunchServer signed incorrectly. Status: {}", result.type.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (JVMHelper.getVersion() < 17) {
|
|
||||||
logger.warn("LaunchServer will end Java {} support in next release. Please install Java 17 or above", JVMHelper.getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchServerRuntimeConfig runtimeConfig;
|
LaunchServerRuntimeConfig runtimeConfig;
|
||||||
LaunchServerConfig config;
|
LaunchServerConfig config;
|
||||||
|
|
|
@ -134,8 +134,7 @@ public byte[] transformClass(byte[] bytes, String classname, BuildContext contex
|
||||||
ClassWriter writer;
|
ClassWriter writer;
|
||||||
ClassNode cn = null;
|
ClassNode cn = null;
|
||||||
for (Transformer t : transformers) {
|
for (Transformer t : transformers) {
|
||||||
if (t instanceof ASMTransformer) {
|
if (t instanceof ASMTransformer asmTransformer) {
|
||||||
ASMTransformer asmTransformer = (ASMTransformer) t;
|
|
||||||
if (cn == null) {
|
if (cn == null) {
|
||||||
ClassReader cr = new ClassReader(result);
|
ClassReader cr = new ClassReader(result);
|
||||||
cn = new ClassNode();
|
cn = new ClassNode();
|
||||||
|
|
|
@ -171,19 +171,10 @@ public void invoke(String... args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (config.env) {
|
switch (config.env) {
|
||||||
|
case DEV -> printCheckResult("env", "found env DEV", false);
|
||||||
case DEV:
|
case DEBUG -> printCheckResult("env", "found env DEBUG", false);
|
||||||
printCheckResult("env", "found env DEV", false);
|
case STD -> printCheckResult("env", "you can improve security by using env PROD", null);
|
||||||
break;
|
case PROD -> printCheckResult("env", "", true);
|
||||||
case DEBUG:
|
|
||||||
printCheckResult("env", "found env DEBUG", false);
|
|
||||||
break;
|
|
||||||
case STD:
|
|
||||||
printCheckResult("env", "you can improve security by using env PROD", null);
|
|
||||||
break;
|
|
||||||
case PROD:
|
|
||||||
printCheckResult("env", "", true);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Profiles
|
//Profiles
|
||||||
|
|
|
@ -117,8 +117,7 @@ private String authWithProviderAndHandler(AuthResponse.AuthContext context, Auth
|
||||||
private AuthReport authWithCore(AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password) throws AuthException {
|
private AuthReport authWithCore(AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password) throws AuthException {
|
||||||
AuthCoreProvider provider = context.pair.core;
|
AuthCoreProvider provider = context.pair.core;
|
||||||
provider.verifyAuth(context);
|
provider.verifyAuth(context);
|
||||||
if (password instanceof AuthOAuthPassword) {
|
if (password instanceof AuthOAuthPassword password1) {
|
||||||
AuthOAuthPassword password1 = (AuthOAuthPassword) password;
|
|
||||||
UserSession session;
|
UserSession session;
|
||||||
try {
|
try {
|
||||||
session = provider.getUserSessionByOAuthAccessToken(password1.accessToken);
|
session = provider.getUserSessionByOAuthAccessToken(password1.accessToken);
|
||||||
|
@ -327,12 +326,10 @@ private PlayerProfile getPlayerProfile(UUID uuid, String username, String client
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthRequest.AuthPasswordInterface decryptPassword(AuthRequest.AuthPasswordInterface password) throws AuthException {
|
public AuthRequest.AuthPasswordInterface decryptPassword(AuthRequest.AuthPasswordInterface password) throws AuthException {
|
||||||
if (password instanceof Auth2FAPassword) {
|
if (password instanceof Auth2FAPassword auth2FAPassword) {
|
||||||
Auth2FAPassword auth2FAPassword = (Auth2FAPassword) password;
|
|
||||||
auth2FAPassword.firstPassword = tryDecryptPasswordPlain(auth2FAPassword.firstPassword);
|
auth2FAPassword.firstPassword = tryDecryptPasswordPlain(auth2FAPassword.firstPassword);
|
||||||
auth2FAPassword.secondPassword = tryDecryptPasswordPlain(auth2FAPassword.secondPassword);
|
auth2FAPassword.secondPassword = tryDecryptPasswordPlain(auth2FAPassword.secondPassword);
|
||||||
} else if (password instanceof AuthMultiPassword) {
|
} else if (password instanceof AuthMultiPassword multiPassword) {
|
||||||
AuthMultiPassword multiPassword = (AuthMultiPassword) password;
|
|
||||||
List<AuthRequest.AuthPasswordInterface> list = new ArrayList<>(multiPassword.list.size());
|
List<AuthRequest.AuthPasswordInterface> list = new ArrayList<>(multiPassword.list.size());
|
||||||
for (AuthRequest.AuthPasswordInterface p : multiPassword.list) {
|
for (AuthRequest.AuthPasswordInterface p : multiPassword.list) {
|
||||||
list.add(tryDecryptPasswordPlain(p));
|
list.add(tryDecryptPasswordPlain(p));
|
||||||
|
|
|
@ -155,8 +155,7 @@ void process(ChannelHandlerContext ctx, WebSocketServerResponse response, Client
|
||||||
if (hook.hook(context, ctx)) {
|
if (hook.hook(context, ctx)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response instanceof SimpleResponse) {
|
if (response instanceof SimpleResponse simpleResponse) {
|
||||||
SimpleResponse simpleResponse = (SimpleResponse) response;
|
|
||||||
simpleResponse.server = server;
|
simpleResponse.server = server;
|
||||||
simpleResponse.service = this;
|
simpleResponse.service = this;
|
||||||
simpleResponse.ctx = ctx;
|
simpleResponse.ctx = ctx;
|
||||||
|
|
|
@ -31,8 +31,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
if (username == null && uuid == null) {
|
if (username == null && uuid == null) {
|
||||||
Map<String, String> properties;
|
Map<String, String> properties;
|
||||||
User user = client.getUser();
|
User user = client.getUser();
|
||||||
if (user instanceof UserSupportAdditionalData) {
|
if (user instanceof UserSupportAdditionalData userSupport) {
|
||||||
UserSupportAdditionalData userSupport = (UserSupportAdditionalData) user;
|
|
||||||
if (user.getPermissions().isPermission(ClientPermissions.PermissionConsts.ADMIN)) {
|
if (user.getPermissions().isPermission(ClientPermissions.PermissionConsts.ADMIN)) {
|
||||||
properties = userSupport.getPropertiesMap();
|
properties = userSupport.getPropertiesMap();
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,11 +49,10 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
} else {
|
} else {
|
||||||
user = pair.core.getUserByUUID(uuid);
|
user = pair.core.getUserByUUID(uuid);
|
||||||
}
|
}
|
||||||
if (!(user instanceof UserSupportAdditionalData)) {
|
if (!(user instanceof UserSupportAdditionalData userSupport)) {
|
||||||
sendResult(new AdditionalDataRequestEvent(Map.of()));
|
sendResult(new AdditionalDataRequestEvent(Map.of()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserSupportAdditionalData userSupport = (UserSupportAdditionalData) user;
|
|
||||||
Map<String, String> properties;
|
Map<String, String> properties;
|
||||||
if (client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) {
|
if (client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) {
|
||||||
properties = userSupport.getPropertiesMap();
|
properties = userSupport.getPropertiesMap();
|
||||||
|
|
|
@ -26,8 +26,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
|
|
||||||
List<ClientProfile> profileList;
|
List<ClientProfile> profileList;
|
||||||
Set<ClientProfile> serverProfiles = server.getProfiles();
|
Set<ClientProfile> serverProfiles = server.getProfiles();
|
||||||
if (server.config.protectHandler instanceof ProfilesProtectHandler) {
|
if (server.config.protectHandler instanceof ProfilesProtectHandler protectHandler) {
|
||||||
ProfilesProtectHandler protectHandler = (ProfilesProtectHandler) server.config.protectHandler;
|
|
||||||
profileList = new ArrayList<>(4);
|
profileList = new ArrayList<>(4);
|
||||||
for (ClientProfile profile : serverProfiles) {
|
for (ClientProfile profile : serverProfiles) {
|
||||||
if (protectHandler.canGetProfile(profile, client)) {
|
if (protectHandler.canGetProfile(profile, client)) {
|
||||||
|
|
|
@ -14,13 +14,12 @@ public String getType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!(server.config.protectHandler instanceof SecureProtectHandler)) {
|
if (!(server.config.protectHandler instanceof SecureProtectHandler secureProtectHandler)) {
|
||||||
GetSecureLevelInfoRequestEvent response = new GetSecureLevelInfoRequestEvent(null);
|
GetSecureLevelInfoRequestEvent response = new GetSecureLevelInfoRequestEvent(null);
|
||||||
response.enabled = false;
|
response.enabled = false;
|
||||||
sendResult(response);
|
sendResult(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SecureProtectHandler secureProtectHandler = (SecureProtectHandler) server.config.protectHandler;
|
|
||||||
if (!secureProtectHandler.allowGetSecureLevelInfo(client)) {
|
if (!secureProtectHandler.allowGetSecureLevelInfo(client)) {
|
||||||
sendError("Access denied");
|
sendError("Access denied");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,11 +19,10 @@ public String getType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!(server.config.protectHandler instanceof SecureProtectHandler) || client.trustLevel == null || client.trustLevel.verifySecureKey == null) {
|
if (!(server.config.protectHandler instanceof SecureProtectHandler secureProtectHandler) || client.trustLevel == null || client.trustLevel.verifySecureKey == null) {
|
||||||
sendError("This method not allowed");
|
sendError("This method not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SecureProtectHandler secureProtectHandler = (SecureProtectHandler) server.config.protectHandler;
|
|
||||||
try {
|
try {
|
||||||
secureProtectHandler.verifySecureLevelKey(publicKey, client.trustLevel.verifySecureKey, signature);
|
secureProtectHandler.verifySecureLevelKey(publicKey, client.trustLevel.verifySecureKey, signature);
|
||||||
} catch (InvalidKeySpecException e) {
|
} catch (InvalidKeySpecException e) {
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 84a5599243bddf0f7a8081cc7f5672e9140893bd
|
Subproject commit 74a45c7a697d33dbfc15efb0f5fac83055623ae9
|
Loading…
Reference in a new issue