提交 4071deac authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 b2a84155
......@@ -108,8 +108,7 @@ public class AssetsController {
while ((line = in.readLine()) != null) {
sb.append(line);
}
String xml = sb.toString();
log.info("解密前:{}", xml);
String postData = sb.toString();
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
......@@ -119,25 +118,21 @@ public class AssetsController {
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
dbf.setXIncludeAware(false);
dbf.setExpandEntityReferences(false);
DocumentBuilder db = dbf.newDocumentBuilder();
StringReader sr = new StringReader(xml);
StringReader sr = new StringReader(postData);
InputSource is = new InputSource(sr);
Document document = db.parse(is);
Element root = document.getDocumentElement();
NodeList nodelist1 = root.getElementsByTagName("Encrypt");
NodeList nodelist2 = root.getElementsByTagName("MsgSignature");
String encrypt = nodelist1.item(0).getTextContent();
String msgSignature1 = nodelist2.item(0).getTextContent();
String format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>";
String fromXML = String.format(format, encrypt);
// 公众平台发送消息给第三方,第三方处理
// 第三方收到公众号平台发送的消息
String result2 = pc.decryptMsg(msgSignature1, timestamp, nonce, fromXML);
String result2 = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML);
log.info("解密后================================================");
log.info("解密后++++++++++++++++++++++++++++++++++++++++++++++++++", result2+"123++++++++++++++++++++++++++++++");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论