From abd73edd5d08e26fba60ab47f53722502a87505a Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 08 一月 2026 17:21:50 +0800
Subject: [PATCH] 浪潮对接单点登录:租户数据隔离功能
---
src/main/java/com/ruoyi/tide/utils/TideUtils.java | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/ruoyi/tide/utils/TideUtils.java b/src/main/java/com/ruoyi/tide/utils/TideUtils.java
index 2d27290..10f84ab 100644
--- a/src/main/java/com/ruoyi/tide/utils/TideUtils.java
+++ b/src/main/java/com/ruoyi/tide/utils/TideUtils.java
@@ -9,6 +9,7 @@
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -21,9 +22,26 @@
@Component
@Slf4j
public class TideUtils {
- private final static String appId = "1205972857687900160";
- private final static String appSecret = "MgzPMDYwMTIwMjYxNzQ2NDA3OTYGqt";
+ public static String APP_ID;
+ public static String APP_SECRET;
+
+
+ @Value("${inspur.appId}")
+ private String appId;
+
+ @Value("${inspur.appSecret}")
+ private String appSecret;
+
+ @Value("${inspur.appId}")
+ public void setAppId(String appId) {
+ TideUtils.APP_ID = appId;
+ }
+
+ @Value("${inspur.appSecret}")
+ public void setAppSecret(String appSecret) {
+ TideUtils.APP_SECRET = appSecret;
+ }
// 鍐呯綉鍦板潃
private final static String ip = "http://10.136.0.8:8083";
@@ -62,14 +80,14 @@
xSignSplicingTogether = "x-random=" + xRandom + "&x-time=" + xTime;
}
// 閰嶇疆鍔犲瘑鏂瑰紡涓庡瘑閽�
- HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, appSecret.getBytes());
+ HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, APP_SECRET.getBytes());
// 寰楀嚭x-sign
String xSign = hMac.digestHex(xSignSplicingTogether);
HashMap<String, String> result = new HashMap<>();
result.put("x-time", xTime);
result.put("x-random", xRandom);
result.put("x-sign", xSign);
- result.put("appKey", appId);
+ result.put("appKey", APP_ID);
return result;
}
@@ -91,13 +109,13 @@
xSignSplicingTogether = "x-random=" + xRandom + "&x-time=" + xTime;
}
// x-sign 鍔犲瘑
- HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, appSecret.getBytes());
+ HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, APP_SECRET.getBytes());
String xSign = hMac.digestHex(xSignSplicingTogether);
HashMap<String, String> result = new HashMap<>();
result.put("x-time", xTime);
result.put("x-random", xRandom);
result.put("x-sign", xSign);
- result.put("appKey", appId);
+ result.put("appKey", APP_ID);
return result;
}
@@ -117,8 +135,8 @@
String url = ip + "/cpn/extral/applicationCode/appAuthCheck";
JSONObject json = new JSONObject();
json.put("code", code);
- json.put("appID", appId);
- json.put("appSecret", appSecret);
+ json.put("appID", APP_ID);
+ json.put("appSecret", APP_SECRET);
HashMap<String, String> header = getPostHeader(json.toString());
String body = HttpRequest.post(url)
.headerMap(header, false)
@@ -132,7 +150,7 @@
public static JSONObject getUserInfo(String token) {
String url = ip + "/cpn/api/extral/applicationCode/getUserInfoByToken";
JSONObject json = new JSONObject();
- json.put("appID", appId);
+ json.put("appID", APP_ID);
HashMap<String, String> header = getPostHeader(json.toString());
header.put("Authorization", token);
String body = HttpRequest.post(url)
--
Gitblit v1.9.3