add 新增[standardsUtil.java] 获取会员系统的公钥和加密token
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
package com.jero.util;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.asymmetric.KeyType;
|
||||||
|
import cn.hutool.crypto.asymmetric.RSA;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jero.common.exception.JeroBootException;
|
||||||
|
import com.jero.common.util.RestUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liJiaRao
|
||||||
|
* @date 2021-09-10 9:58
|
||||||
|
*/
|
||||||
|
public class standardsUtil {
|
||||||
|
@Value("${standards.url}")
|
||||||
|
private static String url;
|
||||||
|
@Value("${standards.token}")
|
||||||
|
private static String token;
|
||||||
|
|
||||||
|
public static String getRSAPublicKey(){
|
||||||
|
JSONObject jsonObject = RestUtil.get(url + "/sys/getRSAPublicKey");
|
||||||
|
if (jsonObject.getBoolean("success")) {
|
||||||
|
return jsonObject.getString("result");
|
||||||
|
}else {
|
||||||
|
throw new JeroBootException("调用会员系统出错");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -298,4 +298,7 @@ justauth:
|
|||||||
type: default
|
type: default
|
||||||
prefix: 'demo::'
|
prefix: 'demo::'
|
||||||
timeout: 1h
|
timeout: 1h
|
||||||
defaultPassword: HZWLsoft.com123
|
defaultPassword: HZWLsoft.com123
|
||||||
|
standards:
|
||||||
|
url: http://loaclhots:8081/api
|
||||||
|
token: Aa123456!!
|
||||||
Reference in New Issue
Block a user