Explorar o código

1、优化推送密钥对接服务

Bingo %!s(int64=3) %!d(string=hai) anos
pai
achega
6a8e43f08c

+ 3 - 2
src/main/java/com/chuanghai/controller/WxController.java

@@ -96,8 +96,9 @@ public class WxController {
             String cIv = weixiaoConfig.getAppSecret().substring(0, 16);
             AesUtil aes = new AesUtil();
             String userString = aes.Decrypt(rawData, cKey, cIv);
-
-            System.out.println(userString);
+            weixiaoPushDTO.setApp_secret(cIv);
+           // System.out.println(weixiaoPushDTO);
+            //推送微校通知
             pushProjectService.pushProject(weixiaoPushDTO);
             return ReturnValueUtil.ok();
         } catch (Exception e) {

+ 6 - 0
src/main/java/com/chuanghai/dto/WeixiaoPushDTO.java

@@ -15,6 +15,10 @@ public class WeixiaoPushDTO {
      */
     private String app_key;
     /**
+     * 应用appSecret
+     */
+    private String app_secret;
+    /**
      * 学校主体代码
      */
     private String school_code;
@@ -32,4 +36,6 @@ public class WeixiaoPushDTO {
      * 推送加密后数据
      */
     private String raw_data;
+
+
 }

+ 5 - 4
src/main/java/com/chuanghai/utils/AesUtil.java

@@ -37,10 +37,10 @@ public class AesUtil {
 
     public static String Decrypt(String sSrc, String sKey, String sIv) throws Exception {
 
-        byte[] encrypted1      = hex2byte(sSrc);
+        byte[] encrypted1 = hex2byte(sSrc);
 
-        Cipher cipher          = Cipher.getInstance("AES/CBC/NoPadding");
-        SecretKeySpec keyspec  = new SecretKeySpec(sKey.getBytes(), "AES");
+        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+        SecretKeySpec keyspec = new SecretKeySpec(sKey.getBytes(), "AES");
         IvParameterSpec ivspec = new IvParameterSpec(sIv.getBytes());
 
         cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
@@ -101,7 +101,8 @@ public class AesUtil {
         System.out.println("加密耗时:" + lUseTime + "毫秒");
         // 解密
         lStart = System.currentTimeMillis();
-        String DeString = AesUtil.Decrypt(enString, cKey, cIv);
+//        String DeString = AesUtil.Decrypt(enString, cKey, cIv);
+        String DeString = AesUtil.Decrypt("34a4795c730b4e5ec822e710d0e5aff2ec9e0544f5ae27df5c62365ef8abd916c661ae91316674c545c7edadb86f70c7d06ec298b203e97fd9d1536d3c8e429c7000d4a737434f1c188d7d4c5faa227e68a018e8ad669e610572cd9b357eaa1cb745bd48b0f99dc9f53c594cd35c5b75952a2d1ecc4e93b24a8be8d1c67bdec95dff94e04507a94a0627ea6996a8019a9cee101bfac817f3e3389fd805750b3cl", cKey, cIv);
         System.out.println("解密后的字串是:" + DeString);
         lUseTime = System.currentTimeMillis() - lStart;
         System.out.println("解密耗时:" + lUseTime + "毫秒");

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 20 - 19
src/main/resources/static/doc/index.html