0

新手JWT 我想验证我的字符串令牌,生成如下

String productkey:这是签名和编码的格式。

String publickey:从模拟器生成密钥并存储为字符串

JWSVerifier verifier= new ECSDVerifier(ECKey.parse(publickey))

Boolean test=verifier.verify(productkey);

请建议我必须使用哪种合适的方法。

4

1 回答 1

0

If you are new to JWT, I would suggest you to use JJwt API. You can easily sign your tokens and verify them.

Snippet to generate JWT token:

Jwts.builder()
        .setClaims(payload)
        .setExpiration(expiryDate)
        .signWith(SignatureAlgorithm.RS256, privateKey )
        .compact();

Snippet to verify the token with public key:

Jwts.parser() 
   .setSigningKey(publicKey )
   .parseClaimsJws(jwtToken)

JJwt Maven/Gradle link

Hope this helps.

于 2017-07-27T07:33:28.213 回答