mirror of
https://github.com/WuKongIM/WuKongIMAndroidSDK
synced 2025-06-05 00:28:22 +00:00
fix:修改收到消息时先验证合法性再解码内容
This commit is contained in:
parent
25caa7a067
commit
8c3cf3e820
@ -3,6 +3,7 @@ package com.xinbida.wukongdemo
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
@ -41,6 +42,12 @@ class ConversationActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
findViewById<Button>(R.id.disConn).setOnClickListener{
|
||||
WKIM.getInstance().connectionManager.disconnect(false)
|
||||
}
|
||||
findViewById<Button>(R.id.conn).setOnClickListener{
|
||||
WKIM.getInstance().connectionManager.connection()
|
||||
}
|
||||
// 监听连接状态
|
||||
WKIM.getInstance().connectionManager.addOnConnectionStatusListener(
|
||||
"conv"
|
||||
|
@ -35,4 +35,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<Button
|
||||
android:id="@+id/disConn"
|
||||
android:text="断开"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/conn"
|
||||
android:text="连接"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
@ -220,11 +220,6 @@ class WKProto {
|
||||
receivedMsg.topicID = wkRead.readString();
|
||||
}
|
||||
String content = wkRead.readPayload();
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
WKLoggerUtils.getInstance().e(TAG, "消息payload:" + content);
|
||||
receivedMsg.payload = CryptoUtils.getInstance().aesDecrypt(CryptoUtils.getInstance().base64Decode(content));
|
||||
>>>>>>> 9978523a9a818731b66c2409ff4c0cba70fab46f
|
||||
String msgKey = receivedMsg.messageID
|
||||
+ receivedMsg.messageSeq
|
||||
+ receivedMsg.clientMsgNo
|
||||
@ -239,13 +234,13 @@ class WKProto {
|
||||
}
|
||||
String base64Result = CryptoUtils.getInstance().base64Encode(result);
|
||||
String localMsgKey = CryptoUtils.getInstance().digestMD5(base64Result);
|
||||
WKLoggerUtils.getInstance().e("Receive message:");
|
||||
WKLoggerUtils.getInstance().e(receivedMsg.toString());
|
||||
if (!localMsgKey.equals(receivedMsg.msgKey)) {
|
||||
WKLoggerUtils.getInstance().e("Illegal messages,localMsgKey:" + localMsgKey + ",msgKey:" + msgKey);
|
||||
return null;
|
||||
}
|
||||
receivedMsg.payload = CryptoUtils.getInstance().aesDecrypt(CryptoUtils.getInstance().base64Decode(content));
|
||||
WKLoggerUtils.getInstance().e("Receive message:");
|
||||
WKLoggerUtils.getInstance().e(receivedMsg.toString());
|
||||
} catch (IOException e) {
|
||||
WKLoggerUtils.getInstance().e(TAG, "deReceivedMsg Decoding received message error");
|
||||
}
|
||||
|
@ -102,12 +102,8 @@ public class CryptoUtils {
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException |
|
||||
InvalidAlgorithmParameterException | IllegalBlockSizeException |
|
||||
BadPaddingException e) {
|
||||
<<<<<<< HEAD
|
||||
WKLoggerUtils.getInstance().e(TAG,"aesEncrypt encrypt error");
|
||||
return null;
|
||||
=======
|
||||
WKLoggerUtils.getInstance().e(TAG, "aesEncrypt encrypt error");
|
||||
>>>>>>> 9978523a9a818731b66c2409ff4c0cba70fab46f
|
||||
}
|
||||
if (encrypted == null) {
|
||||
WKLoggerUtils.getInstance().e(TAG, "aesEncrypt The encrypted data is empty");
|
||||
|
Loading…
x
Reference in New Issue
Block a user