第一版跨服务调用校验身份,用不了
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.jero.util;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@@ -19,7 +21,7 @@ public class standardsUtil {
|
||||
private static String token;
|
||||
|
||||
public static String getRSAPublicKey(){
|
||||
JSONObject jsonObject = RestUtil.get(url + "/sys/getRSAPublicKey");
|
||||
JSONObject jsonObject = RestUtil.get(url + "/commonUtils/getRSAPublicKey");
|
||||
if (jsonObject.getBoolean("success")) {
|
||||
return jsonObject.getString("result");
|
||||
}else {
|
||||
@@ -30,13 +32,14 @@ public class standardsUtil {
|
||||
|
||||
/**
|
||||
* RSA 使用公钥加密token
|
||||
* @param RSAPublicKey 公钥
|
||||
* @return String 加密后的字符串
|
||||
*/
|
||||
public static String encryptByRsaPriKey(String RSAPublicKey) {
|
||||
RSA rsa = new RSA(null, RSAPublicKey);
|
||||
byte[] encrypt = rsa.encrypt(token, KeyType.PublicKey);
|
||||
return new String(encrypt);
|
||||
public static byte[] encryptByRsaPriKey() {
|
||||
//从标协项目获取公钥
|
||||
String publicKey=HttpUtil.get("http://localhost:8080/api/authenticationUtils/getPublicKey");
|
||||
|
||||
RSA rsa = new RSA(null,publicKey);
|
||||
|
||||
return rsa.encrypt(StrUtil.bytes("Aa123456!!", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user