diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index f9ebd0ea..e3c8a6f1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -75,7 +75,7 @@ public static final class Config extends ConfigObject { @LauncherAPI public final AuthHandler authHandler; @LauncherAPI - public final AuthProvider authProvider; + public final AuthProvider[] authProvider; @LauncherAPI public final TextureProvider textureProvider; @LauncherAPI @@ -125,7 +125,8 @@ private Config(BlockConfigEntry block, Path coredir) { // Set handlers & providers authHandler = AuthHandler.newHandler(block.getEntryValue("authHandler", StringConfigEntry.class), block.getEntry("authHandlerConfig", BlockConfigEntry.class)); - authProvider = AuthProvider.newProvider(block.getEntryValue("authProvider", StringConfigEntry.class), + authProvider = new AuthProvider[1]; + authProvider[0] = AuthProvider.newProvider(block.getEntryValue("authProvider", StringConfigEntry.class), block.getEntry("authProviderConfig", BlockConfigEntry.class)); textureProvider = TextureProvider.newProvider(block.getEntryValue("textureProvider", StringConfigEntry.class), block.getEntry("textureProviderConfig", BlockConfigEntry.class)); @@ -459,7 +460,7 @@ public void close() { LogHelper.error(e); } try { - config.authProvider.close(); + for(AuthProvider p : config.authProvider) p.close(); } catch (IOException e) { LogHelper.error(e); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java index 48c80c4e..814c9c34 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java @@ -40,9 +40,11 @@ public AuthResponse(LaunchServer server, long session, HInput input, HOutput out public void reply() throws Exception { String login = input.readString(SerializeLimits.MAX_LOGIN); String client = input.readString(SerializeLimits.MAX_CLIENT); + int auth_id = input.readInt(); long hwid_hdd = input.readLong(); long hwid_cpu = input.readLong(); long hwid_bios = input.readLong(); + if(auth_id + 1 > server.config.authProvider.length || auth_id < 0) auth_id = 0; byte[] encryptedPassword = input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH); // Decrypt password String password; @@ -62,7 +64,8 @@ public void reply() throws Exception { AuthProvider.authError(server.config.authRejectString); return; } - result = server.config.authProvider.auth(login, password, ip); + AuthProvider provider = server.config.authProvider[auth_id]; + result = provider.auth(login, password, ip); if (!VerifyHelper.isValidUsername(result.username)) { AuthProvider.authError(String.format("Illegal result: '%s'", result.username)); return; diff --git a/Launcher/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/Launcher/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index fd331575..d6a68057 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/Launcher/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -33,18 +33,31 @@ private Result(PlayerProfile pp, String accessToken) { private final String login; private final byte[] encryptedPassword; + private final int auth_id; @LauncherAPI public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword) { super(config); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = encryptedPassword.clone(); + auth_id = 0; + } + @LauncherAPI + public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword,int auth_id) { + super(config); + this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); + this.encryptedPassword = encryptedPassword.clone(); + this.auth_id = auth_id; } @LauncherAPI public AuthRequest(String login, byte[] encryptedPassword) { this(null, login, encryptedPassword); } + @LauncherAPI + public AuthRequest(String login, byte[] encryptedPassword,int auth_id) { + this(null, login, encryptedPassword,auth_id); + } @Override public Integer getType() { @@ -55,6 +68,7 @@ public Integer getType() { protected Result requestDo(HInput input, HOutput output) throws IOException { output.writeString(login, SerializeLimits.MAX_LOGIN); output.writeString(ClientLauncher.title, SerializeLimits.MAX_CLIENT); + output.writeInt(auth_id); output.writeLong(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE ? GuardBind.avnGetHddId() : 0); output.writeLong(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE ? GuardBind.avnGetCpuid() : 0); output.writeLong(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE ? GuardBind.avnGetSmbiosId() : 0);