From e2f28cff0069375cab853536b9ed8e4762a2f529 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Fri, 10 Sep 2021 11:33:19 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E[standardsUtil.java]=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BC=9A=E5=91=98=E7=B3=BB=E7=BB=9F=E7=9A=84?= =?UTF-8?q?=E5=85=AC=E9=92=A5=E5=92=8C=E5=8A=A0=E5=AF=86token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jero/util/standardsUtil.java | 42 +++++++++++++++++++ .../src/main/resources/application-dev.yml | 5 ++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 jero-boot-incoming-payment/src/main/java/com/jero/util/standardsUtil.java 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