mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Improvements for token command
This commit is contained in:
parent
b5aeac3ff2
commit
d9a8e161f1
1 changed files with 16 additions and 3 deletions
|
@ -3,7 +3,9 @@
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.command.Command;
|
import pro.gravit.launchserver.command.Command;
|
||||||
import pro.gravit.utils.command.SubCommand;
|
import pro.gravit.utils.command.SubCommand;
|
||||||
|
|
||||||
|
@ -20,11 +22,22 @@ public void invoke(String... args) throws Exception {
|
||||||
logger.info("Token: {}", claims.getBody());
|
logger.info("Token: {}", claims.getBody());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.childCommands.put("server", new SubCommand("[serverName] (authId)", "generate new server token") {
|
this.childCommands.put("server", new SubCommand("[profileName] (authId)", "generate new server token") {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
String token = server.authManager.newCheckServerToken(args[0], args.length > 1 ? args[1] : server.config.getAuthProviderPair().name);
|
AuthProviderPair pair = args.length > 1 ? server.config.getAuthProviderPair(args[1]) : server.config.getAuthProviderPair();
|
||||||
logger.info("Token: {}", token);
|
ClientProfile profile = null;
|
||||||
|
for(ClientProfile p : server.getProfiles()) {
|
||||||
|
if(p.getTitle().equals(args[0])) {
|
||||||
|
profile = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(profile == null) {
|
||||||
|
logger.warn("Profile {} not found", args[0]);
|
||||||
|
}
|
||||||
|
String token = server.authManager.newCheckServerToken(args[0], pair.name);
|
||||||
|
logger.info("Server token {} authId {}: {}", args[0], pair.name, token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue