生成rs256格式jwt
//证书文件
String key_location = “config/tls/keystore.p12”;
//密钥库密码
String keystore_password = “password”;
//访问证书路径
ClassPathResource resource = new ClassPathResource(key_location);
//密钥工厂
KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(resource,
keystore_password.toCharArray());
//密钥的密码,此密码和别名要匹配
String keypassword = “password”;
//密钥别名
String alias = “selfsigned”;
//密钥对(密钥和公钥)
KeyPair keyPair = keyStoreKeyFactory.getKeyPair(alias,keypassword.toCharArray());
//私钥
RSAPrivateKey aPrivate = (RSAPrivateKey) keyPair.getPrivate();
//定义payload信息
Map<String, Object> tokenMap = new HashMap<>();
tokenMap.put(“user_name”, user_name);
String[] sc={“openid”};
tokenMap.put(“scope”, sc);
Calendar calendar = Calendar.getInstance();