我尝试使用RSA算法创建JWTVerifier:
JWTVerifier jwtVerifier = JWT.require(Algorithm.RSA512(rsaPublicKey, rsaPrivateKey)).build();
我想借助其实现RSAPublicKeyImpl和RSAPrivateKeyImpl来创建RSAPublicKey和RSAPrivateKey实例,并遇到第二个实例(错误上下文)的问题:
'RSAPrivateKeyImpl(java.math.BigInteger, java.math.BigInteger)' is not public in
'sun.security.rsa.RSAPrivateKeyImpl'. Cannot be accessed from outside package.
图书馆:
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import sun.security.rsa.RSAPrivateKeyImpl;
import sun.security.rsa.RSAPublicKeyImpl;
Intellij Idea中的代码:
private RSAPublicKey rsaPublicKey;
private RSAPrivateKey rsaPrivateKey;
public JwtFilter() throws InvalidKeyException {
this.rsaPublicKey = new RSAPublicKeyImpl(BigInteger.valueOf(1147), BigInteger.valueOf(7));
this.rsaPrivateKey = new RSAPrivateKeyImpl(BigInteger.valueOf(1147), BigInteger.valueOf(463));
}
RSAPublicKey可以。方法和类是公开的。我清理并重建了项目,使缓存无效并重新启动。