Quellcode durchsuchen

木易华康 秘钥问题优化

xgb vor 1 Woche
Ursprung
Commit
b087274cd1

+ 11 - 1
fs-admin/src/main/java/com/fs/web/controller/common/CommonController.java

@@ -6,7 +6,8 @@ import javax.servlet.http.HttpServletResponse;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.file.OssException;
-import com.fs.course.dto.BatchSendCourseAllDTO;;
+import com.fs.course.dto.BatchSendCourseAllDTO;
+import com.fs.course.domain.ObsProperties;
 import com.fs.course.service.ITencentCloudCosService;
 import com.fs.framework.config.ServerConfig;
 import com.fs.his.domain.FsExportTask;
@@ -59,6 +60,9 @@ public class CommonController
 
     @Autowired
     private ITencentCloudCosService tencentCloudCosService;
+
+    @Autowired
+    private ObsProperties obsProperties;
     @Autowired
     private IFsExportTaskService exportTaskService;
 
@@ -242,6 +246,12 @@ public class CommonController
         return tencentCloudCosService.getKeyAndCredentials();
     }
 
+    @GetMapping("/common/getObsConfig")
+    public R getObsConfig()
+    {
+        return R.ok().put("data", obsProperties);
+    }
+
     /**
      * 测试接口
      */

+ 10 - 0
fs-company/src/main/java/com/fs/company/controller/common/CommonController.java

@@ -17,6 +17,7 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.utils.AudioUtils;
 import com.fs.company.vo.WangUploadVO;
 import com.fs.course.service.ITencentCloudCosService;
+import com.fs.course.domain.ObsProperties;
 import com.fs.framework.config.ServerConfig;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
@@ -75,6 +76,9 @@ public class CommonController
     @Autowired
     private ITencentCloudCosService tencentCloudCosService;
 
+    @Autowired
+    private ObsProperties obsProperties;
+
 
     @Autowired
     private ISysConfigService configService;
@@ -350,6 +354,12 @@ public class CommonController
         return tencentCloudCosService.getKeyAndCredentials();
     }
 
+    @GetMapping("/common/getObsConfig")
+    public R getObsConfig()
+    {
+        return R.ok().put("data", obsProperties);
+    }
+
     @GetMapping(value = "/common/getInquiryConfig")
     public AjaxResult getInquiryConfig()
     {

+ 11 - 7
fs-service/src/main/java/com/fs/ai/service/impl/BaiduAIServiceImpl.java

@@ -17,6 +17,7 @@ import com.fs.ai.vo.BaiduAITokenVO;
 import com.fs.chat.domain.ChatDataset;
 import com.fs.common.utils.StringUtils;
 import com.fs.erp.utils.CommonUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
@@ -27,13 +28,16 @@ import java.util.*;
 @Service
 public class BaiduAIServiceImpl implements IBaiduAIService {
 
-    String clientId="LUP3P6NA0q9CEAmUhjnWXt4Q";
-    String clientSecret="Esxtj5QVM2klCZV1HfIRYutW5mJ2AP5G";
-    String grantType="client_credentials";
-    String plugins="4v4ki9a5t1hxdv92";
-
-
-    String secretKey="bce-v3/ALTAK-P03N0q1ET2QKrbq3RGdgB/456be350fac6b3fe41ced46cada2cc287e04f5fc";
+    @Value("${baidu-ai.client-id:LUP3P6NA0q9CEAmUhjnWXt4Q}")
+    private String clientId;
+    @Value("${baidu-ai.client-secret:Esxtj5QVM2klCZV1HfIRYutW5mJ2AP5G}")
+    private String clientSecret;
+    @Value("${baidu-ai.grant-type:client_credentials}")
+    private String grantType;
+    @Value("${baidu-ai.plugins:4v4ki9a5t1hxdv92}")
+    private String plugins;
+    @Value("${baidu-ai.secret-key:bce-v3/ALTAK-P03N0q1ET2QKrbq3RGdgB/456be350fac6b3fe41ced46cada2cc287e04f5fc}")
+    private String secretKey;
 
     public static  BaiduAITokenVO vo=null;
 

+ 18 - 0
fs-service/src/main/java/com/fs/course/domain/ObsProperties.java

@@ -0,0 +1,18 @@
+package com.fs.course.domain;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+public class ObsProperties {
+    @Value("${obs.access-key-id:K2UTJGIN7UTZJR2XMXYG}")
+    private String accessKeyId;
+    @Value("${obs.secret-access-key:sbyeNJLbcYmH6copxeFP9pAoksM4NIT9Zw4x0SRX}")
+    private String secretAccessKey;
+    @Value("${obs.server:https://obs.cn-north-4.myhuaweicloud.com}")
+    private String server;
+    @Value("${obs.bucket:myhk-hw079058881}")
+    private String bucket;
+}

+ 20 - 0
fs-service/src/main/java/com/fs/his/utils/PhoneEncryptConfig.java

@@ -0,0 +1,20 @@
+package com.fs.his.utils;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public class PhoneEncryptConfig {
+    @Value("${phone.encrypt.aes-key:AESAabCdeREssREA}")
+    private String aesKey;
+    @Value("${phone.encrypt.old-key:2c8d1a7f4e9b3c6ae6d5c4b3a291f8c9}")
+    private String oldKey;
+
+    @PostConstruct
+    public void init() {
+        PhoneUtil.setAesKey(aesKey);
+        PhoneUtil.setOldKey(oldKey);
+    }
+}

+ 9 - 4
fs-service/src/main/java/com/fs/his/utils/PhoneUtil.java

@@ -7,10 +7,16 @@ import javax.crypto.spec.SecretKeySpec;
 import java.util.Base64;
 
 public class PhoneUtil {
+    public static String AES_KEY = "AESAabCdeREssREA";
+    public static String OLD_KEY = "2c8d1a7f4e9b3c6ae6d5c4b3a291f8c9";
+
+    public static void setAesKey(String key) { AES_KEY = key; }
+    public static void setOldKey(String key) { OLD_KEY = key; }
+
     public static String encryptPhone(String text) {
         String encryptedText=null;
         try {
-            SecretKeySpec secretKey = new SecretKeySpec("AESAabCdeREssREA".getBytes(), "AES");
+            SecretKeySpec secretKey = new SecretKeySpec(AES_KEY.getBytes(), "AES");
             Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
             // Encryption
             cipher.init(Cipher.ENCRYPT_MODE, secretKey);
@@ -27,7 +33,7 @@ public class PhoneUtil {
     public static String decryptPhone(String encryptedText) {
         String text=null;
         try {
-            SecretKeySpec secretKey = new SecretKeySpec("AESAabCdeREssREA".getBytes(), "AES");
+            SecretKeySpec secretKey = new SecretKeySpec(AES_KEY.getBytes(), "AES");
             Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
             cipher.init(Cipher.DECRYPT_MODE, secretKey);
             byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(encryptedText));
@@ -60,7 +66,7 @@ public class PhoneUtil {
         if (encryptedText!=null&&encryptedText!="") {
             if (encryptedText.length()>11){
                 try {
-                    SecretKeySpec secretKey = new SecretKeySpec("AESAabCdeREssREA".getBytes(), "AES");
+                    SecretKeySpec secretKey = new SecretKeySpec(AES_KEY.getBytes(), "AES");
                     Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
                     cipher.init(Cipher.DECRYPT_MODE, secretKey);
                     byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(encryptedText));
@@ -81,7 +87,6 @@ public class PhoneUtil {
      * @param text
      * @return
      */
-    private static String OLD_KEY = "2c8d1a7f4e9b3c6ae6d5c4b3a291f8c9";
     public static String encryptPhoneOldKey(String text) {
         String encryptedText=null;
         try {

+ 23 - 0
fs-service/src/main/java/com/fs/watch/utils/IotConfig.java

@@ -0,0 +1,23 @@
+package com.fs.watch.utils;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public class IotConfig {
+    @Value("${iot.api-address:219.153.134.60:3666}")
+    private String apiAddress;
+    @Value("${iot.app-id:240}")
+    private String appId;
+    @Value("${iot.api-key:38084a19ea3b43b1b39a64cb20e3f7eb}")
+    private String apiKey;
+
+    @PostConstruct
+    public void init() {
+        IotUtils.setApiAddress(apiAddress);
+        IotUtils.setAppid(appId);
+        IotUtils.setApiKey(apiKey);
+    }
+}

+ 6 - 4
fs-service/src/main/java/com/fs/watch/utils/IotUtils.java

@@ -13,11 +13,13 @@ import java.util.Map;
 import java.util.TreeMap;
 
 public class IotUtils {
-    private final static String apiAddress = "219.153.134.60:3666";
+    static String apiAddress = "219.153.134.60:3666";
     private final static String v = "1.0";
-    private final static String appid = "240";
-//    private final static String apiKey = "3d0193daa1c44dd0ba73c71de70bdf62";
-    private final static String apiKey = "38084a19ea3b43b1b39a64cb20e3f7eb";
+    static String appid = "240";
+    static String apiKey = "38084a19ea3b43b1b39a64cb20e3f7eb";
+    public static void setApiAddress(String v) { apiAddress = v; }
+    public static void setAppid(String v) { appid = v; }
+    public static void setApiKey(String v) { apiKey = v; }
 
     private final static MyHttpUtils httpUtils = new MyHttpUtils();
 

+ 23 - 0
fs-service/src/main/resources/application-config-myhk.yml

@@ -102,6 +102,29 @@ ipad:
 wx_miniapp_temp:
   pay_order_temp_id: VXEvKaGNPFuJmhWK9O_QPrTZxe9umDCukq-maI8Vdek
   inquiry_temp_id: 9POPYeqhI48LOPvq-Rfoklze7H-9SlunJKh10Qt4_2I
+# 百度AI配置
+baidu-ai:
+  client-id: LUP3P6NA0q9CEAmUhjnWXt4Q
+  client-secret: Esxtj5QVM2klCZV1HfIRYutW5mJ2AP5G
+  grant-type: client_credentials
+  plugins: 4v4ki9a5t1hxdv92
+  secret-key: bce-v3/ALTAK-P03N0q1ET2QKrbq3RGdgB/456be350fac6b3fe41ced46cada2cc287e04f5fc
+# 手机加密配置
+phone:
+  encrypt:
+    aes-key: AESAabCdeREssREA
+    old-key: 2c8d1a7f4e9b3c6ae6d5c4b3a291f8c9
+# IoT平台配置
+iot:
+  api-address: 219.153.134.60:3666
+  app-id: "240"
+  api-key: 38084a19ea3b43b1b39a64cb20e3f7eb
+# OBS配置
+obs:
+  access-key-id: K2UTJGIN7UTZJR2XMXYG
+  secret-access-key: sbyeNJLbcYmH6copxeFP9pAoksM4NIT9Zw4x0SRX
+  server: https://obs.cn-north-4.myhuaweicloud.com
+  bucket: myhk-hw079058881
 
 
 

+ 23 - 0
fs-service/src/main/resources/application-dev-test.yml

@@ -184,4 +184,27 @@ ipad:
 wx_miniapp_temp:
     pay_order_temp_id:
     inquiry_temp_id:
+# 百度AI配置
+baidu-ai:
+  client-id: LUP3P6NA0q9CEAmUhjnWXt4Q
+  client-secret: Esxtj5QVM2klCZV1HfIRYutW5mJ2AP5G
+  grant-type: client_credentials
+  plugins: 4v4ki9a5t1hxdv92
+  secret-key: bce-v3/ALTAK-P03N0q1ET2QKrbq3RGdgB/456be350fac6b3fe41ced46cada2cc287e04f5fc
+# 手机加密配置
+phone:
+  encrypt:
+    aes-key: AESAabCdeREssREA
+    old-key: 2c8d1a7f4e9b3c6ae6d5c4b3a291f8c9
+# IoT平台配置
+iot:
+  api-address: 219.153.134.60:3666
+  app-id: "240"
+  api-key: 38084a19ea3b43b1b39a64cb20e3f7eb
+# OBS配置
+obs:
+  access-key-id: K2UTJGIN7UTZJR2XMXYG
+  secret-access-key: sbyeNJLbcYmH6copxeFP9pAoksM4NIT9Zw4x0SRX
+  server: https://obs.cn-north-4.myhuaweicloud.com
+  bucket: myhk-hw079058881