mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Jwt library remove deprecated
This commit is contained in:
parent
1710eb7bec
commit
f7decac23d
6 changed files with 14 additions and 14 deletions
|
@ -134,7 +134,7 @@ public static class HardwareInfoTokenVerifier implements RestoreResponse.Extende
|
||||||
public HardwareInfoTokenVerifier(LaunchServer server) {
|
public HardwareInfoTokenVerifier(LaunchServer server) {
|
||||||
this.parser = Jwts.parser()
|
this.parser = Jwts.parser()
|
||||||
.requireIssuer("LaunchServer")
|
.requireIssuer("LaunchServer")
|
||||||
.setSigningKey(server.keyAgreementManager.ecdsaPublicKey)
|
.verifyWith(server.keyAgreementManager.ecdsaPublicKey)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public static class PublicKeyTokenVerifier implements RestoreResponse.ExtendedTo
|
||||||
public PublicKeyTokenVerifier(LaunchServer server) {
|
public PublicKeyTokenVerifier(LaunchServer server) {
|
||||||
this.parser = Jwts.parser()
|
this.parser = Jwts.parser()
|
||||||
.requireIssuer("LaunchServer")
|
.requireIssuer("LaunchServer")
|
||||||
.setSigningKey(server.keyAgreementManager.ecdsaPublicKey)
|
.verifyWith(server.keyAgreementManager.ecdsaPublicKey)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ public TokenCommand(LaunchServer server) {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
verifyArgs(args, 1);
|
verifyArgs(args, 1);
|
||||||
var parser = Jwts.parser().setSigningKey(server.keyAgreementManager.ecdsaPublicKey).build();
|
var parser = Jwts.parser().verifyWith(server.keyAgreementManager.ecdsaPublicKey).build();
|
||||||
var claims = parser.parseClaimsJws(args[0]);
|
var claims = parser.parseSignedClaims(args[0]);
|
||||||
logger.info("Token: {}", claims.getBody());
|
logger.info("Token: {}", claims.getPayload());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.childCommands.put("server", new SubCommand("[profileName] (authId) (public only)", "generate new server token") {
|
this.childCommands.put("server", new SubCommand("[profileName] (authId) (public only)", "generate new server token") {
|
||||||
|
|
|
@ -27,12 +27,12 @@ public static String makeAccessJwtTokenFromString(User user, LocalDateTime expir
|
||||||
public static JwtTokenInfo getJwtInfoFromAccessToken(String token, ECPublicKey publicKey) {
|
public static JwtTokenInfo getJwtInfoFromAccessToken(String token, ECPublicKey publicKey) {
|
||||||
var parser = Jwts.parser()
|
var parser = Jwts.parser()
|
||||||
.requireIssuer("LaunchServer")
|
.requireIssuer("LaunchServer")
|
||||||
.setClock(() -> new Date(Clock.systemUTC().millis()))
|
.clock(() -> new Date(Clock.systemUTC().millis()))
|
||||||
.setSigningKey(publicKey)
|
.verifyWith(publicKey)
|
||||||
.build();
|
.build();
|
||||||
var claims = parser.parseClaimsJws(token);
|
var claims = parser.parseSignedClaims(token);
|
||||||
var uuid = UUID.fromString(claims.getBody().get("uuid", String.class));
|
var uuid = UUID.fromString(claims.getPayload().get("uuid", String.class));
|
||||||
var username = claims.getBody().getSubject();
|
var username = claims.getPayload().getSubject();
|
||||||
return new JwtTokenInfo(username, uuid);
|
return new JwtTokenInfo(username, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,13 @@ public AuthManager(LaunchServer server) {
|
||||||
this.checkServerTokenParser = Jwts.parser()
|
this.checkServerTokenParser = Jwts.parser()
|
||||||
.requireIssuer("LaunchServer")
|
.requireIssuer("LaunchServer")
|
||||||
.require("tokenType", "checkServer")
|
.require("tokenType", "checkServer")
|
||||||
.setSigningKey(server.keyAgreementManager.ecdsaPublicKey)
|
.verifyWith(server.keyAgreementManager.ecdsaPublicKey)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String newCheckServerToken(String serverName, String authId, boolean publicOnly) {
|
public String newCheckServerToken(String serverName, String authId, boolean publicOnly) {
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setIssuer("LaunchServer")
|
.issuer("LaunchServer")
|
||||||
.claim("serverName", serverName)
|
.claim("serverName", serverName)
|
||||||
.claim("authId", authId)
|
.claim("authId", authId)
|
||||||
.claim("tokenType", "checkServer")
|
.claim("tokenType", "checkServer")
|
||||||
|
|
|
@ -90,7 +90,7 @@ public static class LauncherTokenVerifier implements RestoreResponse.ExtendedTok
|
||||||
|
|
||||||
public LauncherTokenVerifier(LaunchServer server) {
|
public LauncherTokenVerifier(LaunchServer server) {
|
||||||
parser = Jwts.parser()
|
parser = Jwts.parser()
|
||||||
.setSigningKey(server.keyAgreementManager.ecdsaPublicKey)
|
.verifyWith(server.keyAgreementManager.ecdsaPublicKey)
|
||||||
.requireIssuer("LaunchServer")
|
.requireIssuer("LaunchServer")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ public final class Version implements Comparable<Version> {
|
||||||
public static final int MINOR = 6;
|
public static final int MINOR = 6;
|
||||||
public static final int PATCH = 0;
|
public static final int PATCH = 0;
|
||||||
public static final int BUILD = 1;
|
public static final int BUILD = 1;
|
||||||
public static final Version.Type RELEASE = Type.EXPERIMENTAL;
|
public static final Version.Type RELEASE = Type.DEV;
|
||||||
public final int major;
|
public final int major;
|
||||||
public final int minor;
|
public final int minor;
|
||||||
public final int patch;
|
public final int patch;
|
||||||
|
|
Loading…
Reference in a new issue