Skip to content

Commit

Permalink
2024-07-24 07:25:22
Browse files Browse the repository at this point in the history
  • Loading branch information
yingzhuo committed Jul 23, 2024
1 parent 0f9063b commit 085ffee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ValidatingResult validateToken(String token) {

private Key getSignerKey() {
if (signer instanceof KeyPairJwtSigner keyPairJwtSigner) {
return keyPairJwtSigner.keyPair().getPrivate();
return keyPairJwtSigner.keyPair().getPrivate(); // 签名用私钥,验证用公钥
}

if (signer instanceof SecretKeyJwtSigner secretKeyJwtSigner) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package spring.turbo.module.jwt;

import io.jsonwebtoken.security.Jwks;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import spring.turbo.module.jwt.alg.JwtSignerFactories;
Expand All @@ -22,4 +23,15 @@ void test0() {
Assertions.assertEquals(ValidatingResult.OK, result);
}

@Test
void test1() {
var o = JwtSignerFactories.createFromBase64EncodedString("3mDk7egxOtYe3oDEiZAhdZ2+ZdfPu8zsYtSl500l004=");
var sk = o.secretKey();

var jwk = Jwks.builder().key(sk) // (1) and (2)
.id("default") // (3)
.build();

System.out.println(jwk.thumbprint().toString());
}
}

0 comments on commit 085ffee

Please sign in to comment.