From 44155b50cbb4f6ad78474f40331ed8838a3b0d49 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 15 十一月 2021 09:27:36 +0800
Subject: [PATCH] 2021-11-15 1.增加认证和加密通讯,未调通

---
 HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 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 26679ab..5047ae0 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,9 +1,13 @@
 package com.hdl.sdk.connect.protocol;
 
 
+import android.util.Log;
+
+import com.hdl.sdk.common.config.AuthenticateConfig;
 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.AesUtil;
 import com.hdl.sdk.connect.utils.ProtocolParse;
 import com.hdl.sdk.socket.codec.ByteToMessageDecoder;
 
@@ -56,7 +60,17 @@
             if (bodyLength > 0) {
                 if (byteArray.length >= bodyLength + bodyStartIndex) {
                     byte[] body = ByteUtils.getRangeBytes(bytes, bodyStartIndex, bodyStartIndex + bodyLength);
-                    response.setData(new String(body, "utf-8"));
+
+                    if(AuthenticateConfig.getInstance().ifNeedEncrypt(response.getTopic())){
+                        //闇�瑕佽В瀵�
+                        byte[] bodyBytes = AesUtil.aesDecrypt(body,AuthenticateConfig.getInstance().getLocalSecret());
+                        response.setData(new String(bodyBytes, "utf-8"));
+                        Log.i("TAG", "decoder: ");
+                    }else{
+                        response.setData(new String(body, "utf-8"));
+                    }
+
+
 
                     if (byteArray.length >= bodyLength + bodyStartIndex) {
                         //淇濆瓨浣欑暀

--
Gitblit v1.8.0