| @@ -8,6 +8,7 @@ import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; | |||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | ||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||||
| import me.chanjar.weixin.open.api.WxOpenConfigStorage; | import me.chanjar.weixin.open.api.WxOpenConfigStorage; | ||||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | |||||
| import me.chanjar.weixin.open.util.WxOpenCryptUtil; | import me.chanjar.weixin.open.util.WxOpenCryptUtil; | ||||
| import me.chanjar.weixin.open.util.xml.XStreamTransformer; | import me.chanjar.weixin.open.util.xml.XStreamTransformer; | ||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
| @@ -140,6 +141,7 @@ public class WxOpenXmlMessage implements Serializable { | |||||
| String timestamp, String nonce, String msgSignature) { | String timestamp, String nonce, String msgSignature) { | ||||
| WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); | WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); | ||||
| String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); | String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); | ||||
| log.debug("解密后的原始xml消息内容:{}", plainText); | |||||
| return WxMpXmlMessage.fromXml(plainText); | return WxMpXmlMessage.fromXml(plainText); | ||||
| } | } | ||||
| @@ -152,4 +154,31 @@ public class WxOpenXmlMessage implements Serializable { | |||||
| throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
| } | } | ||||
| } | } | ||||
| public static void main(String[] args) { | |||||
| WxOpenInMemoryConfigStorage wxOpenConfigStorage = new WxOpenInMemoryConfigStorage(); | |||||
| wxOpenConfigStorage.setComponentAesKey(""); | |||||
| wxOpenConfigStorage.setComponentToken(""); | |||||
| wxOpenConfigStorage.setComponentAppId(""); | |||||
| WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage); | |||||
| /** | |||||
| * 接收微信APP回调:[appId=[wx3cb90ab25f132468], openid=[ok9Xtt7rErEqlQKBjaluwroxsHaM], signature=[50e3ddd2d2817cbc309ed0a4b9b6eafe6e4c8648], encType=[aes], msgSignature=[00c9b32600e67276a56e2092fe3dfe1c486318f5], timestamp=[1653534263], nonce=[897774971], requestBody=[ | |||||
| * <xml> | |||||
| * <ToUserName><![CDATA[gh_ddfa54d85724]]></ToUserName> | |||||
| * <Encrypt><![CDATA[EUzw+5L2Vsqs6fxq4ZGw1S/Hu/4Gx04Z4v2ZqE45OM5OHvK/6z0K21D2wdVv20YmswbsxW7bThe2vvoMqf8dktp4MbOqLMACpYt9B1UeQBoG0tnwiQo1PggTLr3iomBVxRERVpLcyIRZHbyGW0sg3zKjecVGlvMgL4fQFCZmi5swzuR8zXsHQ9LlPiB0jSaF37cj0g7YMyYlzZ1GRyleGljLER3P+Plqa727bpJjGwRgSkBBco8vm4bEcOyTiO0Yy5gARMHC2bcQkhqgUgp6XRyz5YM9jW6DwXPhVCY+X/vvTL1gPm/UAZpwY+YUNh+1o+xm45MX+FjHXN/kbdeVV6NqO8VGF0sP0XYBlenBm4a3CmxU5AjNTauM1f6KSpoLV0R1c02l2hbvpwZ32CEgD5uriOh2NWOnWuLD58AScA8xyIUzdENUsYlq60H9tRd4KRbSydcwp2ALCcm0B1KS/GDT/587TntnL+Ai2VrUSnlZej/ByV8D4dvEuAU+5/ky]]></Encrypt> | |||||
| * </xml> | |||||
| * | |||||
| * ] | |||||
| */ | |||||
| String msgSignature = "50e3ddd2d2817cbc309ed0a4b9b6eafe6e4c8648"; | |||||
| String timestamp = "1653534263"; | |||||
| String nonce = "897774971"; | |||||
| String encryptedXml = "<xml>\n" + | |||||
| " <ToUserName><![CDATA[gh_ddfa54d85724]]></ToUserName>\n" + | |||||
| " <Encrypt><![CDATA[EUzw+5L2Vsqs6fxq4ZGw1S/Hu/4Gx04Z4v2ZqE45OM5OHvK/6z0K21D2wdVv20YmswbsxW7bThe2vvoMqf8dktp4MbOqLMACpYt9B1UeQBoG0tnwiQo1PggTLr3iomBVxRERVpLcyIRZHbyGW0sg3zKjecVGlvMgL4fQFCZmi5swzuR8zXsHQ9LlPiB0jSaF37cj0g7YMyYlzZ1GRyleGljLER3P+Plqa727bpJjGwRgSkBBco8vm4bEcOyTiO0Yy5gARMHC2bcQkhqgUgp6XRyz5YM9jW6DwXPhVCY+X/vvTL1gPm/UAZpwY+YUNh+1o+xm45MX+FjHXN/kbdeVV6NqO8VGF0sP0XYBlenBm4a3CmxU5AjNTauM1f6KSpoLV0R1c02l2hbvpwZ32CEgD5uriOh2NWOnWuLD58AScA8xyIUzdENUsYlq60H9tRd4KRbSydcwp2ALCcm0B1KS/GDT/587TntnL+Ai2VrUSnlZej/ByV8D4dvEuAU+5/ky]]></Encrypt>\n" + | |||||
| "</xml>"; | |||||
| String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml); | |||||
| System.out.println(plainText); | |||||
| } | |||||
| } | } | ||||