mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Мульти AuthProvider's
This commit is contained in:
parent
46a470f0af
commit
363a3ed462
3 changed files with 22 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue