From a03799e08e7cc9b984b89cd125fd01e31f78486d Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 02 十二月 2021 09:44:20 +0800
Subject: [PATCH] 2021-12-02 1.增加网关认证错误

---
 HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java
index 8ffe79a..2ce8c8d 100644
--- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java
+++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java
@@ -1,11 +1,11 @@
 package com.hdl.sdk.connect.protocol;
 
 
-import com.hdl.sdk.common.config.AuthenticateConfig;
+import com.hdl.sdk.common.utils.LogUtils;
+import com.hdl.sdk.connect.config.HDLLinkConfig;
 import com.hdl.sdk.common.event.EventDispatcher;
 import com.hdl.sdk.common.utils.ByteUtils;
 import com.hdl.sdk.connect.bean.LinkResponse;
-import com.hdl.sdk.connect.utils.AESUtils;
 import com.hdl.sdk.connect.utils.AesUtil;
 import com.hdl.sdk.connect.utils.ProtocolParse;
 import com.hdl.sdk.socket.codec.ByteToMessageDecoder;
@@ -60,13 +60,19 @@
                 if (byteArray.length >= bodyLength + bodyStartIndex) {
                     byte[] body = ByteUtils.getRangeBytes(bytes, bodyStartIndex, bodyStartIndex + bodyLength);
 
-                    if(AuthenticateConfig.getInstance().ifNeedEncrypt(response.getTopic())){
+                    if (HDLLinkConfig.getInstance().ifNeedEncrypt(response.getTopic())) {
                         //闇�瑕佽В瀵�
-                        byte[] bodyBytes = AesUtil.aesDecrypt(body,AuthenticateConfig.getInstance().getLocalSecret());
+                        byte[] bodyBytes = AesUtil.aesDecrypt(body, HDLLinkConfig.getInstance().getLocalSecret());
 //                        byte[] bodyBytes = AESUtils.decryptAES(body,AuthenticateConfig.getInstance().getLocalSecret());
-                        response.setData(new String(bodyBytes, "utf-8"));
-//                        Log.i("TAG", "瑙e瘑 涓婚锛�"+response.getTopic()+ " body: "+response.getData());
-                    }else{
+                        if (bodyBytes != null) {
+                            response.setData(new String(bodyBytes, "utf-8"));
+//                            LogUtils.i("TAG", "瑙e瘑 涓婚锛�"+response.getTopic()+ " body: "+response.getData());
+                        } else {
+                            //瑙e瘑澶辫触锛岃繑鍥炲師鏁版嵁
+                            response.setData(new String(body, "utf-8"));
+                        }
+
+                    } else {
                         response.setData(new String(body, "utf-8"));
                     }
 

--
Gitblit v1.8.0