🎨 增加对象自身的解密方法,调整解密工具类方法名

This commit is contained in:
Scruel Tao
2021-12-08 09:41:59 +08:00
committed by GitHub
parent ce8bf302fa
commit 1c6b7fc07c
2 changed files with 89 additions and 9 deletions

View File

@ -506,7 +506,6 @@ public class WxMpXmlMessage implements Serializable {
@JacksonXmlProperty(localName = "ReceiptInfo")
private String receiptInfo;
///////////////////////////////////////
// 门店审核事件推送
///////////////////////////////////////
@ -797,6 +796,12 @@ public class WxMpXmlMessage implements Serializable {
@JacksonXmlProperty(localName = "nsrsbh")
private String nsrsbh;
/**
* 加密消息
*/
@XStreamAlias("Encrypt")
@JacksonXmlProperty(localName = "Encrypt")
private String encrypt;
public static WxMpXmlMessage fromXml(String xml) {
//修改微信变态的消息内容格式,方便解析
@ -836,6 +841,14 @@ public class WxMpXmlMessage implements Serializable {
}
}
public WxMpXmlMessage decryptField(WxMpConfigStorage wxMpConfigStorage,
String timestamp, String nonce, String msgSignature) {
WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage);
String plainText = cryptUtil.decryptContent(msgSignature, timestamp, nonce, this.encrypt);
log.debug("解密后的原始xml消息内容{}", plainText);
return fromXml(plainText);
}
/**
* <pre>
* 当接受用户消息时,可能会获得以下值: