diff --git a/jero-boot-incoming-payment/src/main/java/com/jero/util/standardsUtil.java b/jero-boot-incoming-payment/src/main/java/com/jero/util/standardsUtil.java new file mode 100644 index 00000000..0b9f6784 --- /dev/null +++ b/jero-boot-incoming-payment/src/main/java/com/jero/util/standardsUtil.java @@ -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); + } + +} diff --git a/jero-boot-single-startup/src/main/resources/application-dev.yml b/jero-boot-single-startup/src/main/resources/application-dev.yml index ae03f933..719bffb7 100644 --- a/jero-boot-single-startup/src/main/resources/application-dev.yml +++ b/jero-boot-single-startup/src/main/resources/application-dev.yml @@ -298,4 +298,7 @@ justauth: type: default prefix: 'demo::' timeout: 1h -defaultPassword: HZWLsoft.com123 \ No newline at end of file +defaultPassword: HZWLsoft.com123 +standards: + url: http://loaclhots:8081/api + token: Aa123456!! \ No newline at end of file