|
@@ -1,5 +1,11 @@ |
|
|
package me.chanjar.weixin.common.util.crypto; |
|
|
package me.chanjar.weixin.common.util.crypto; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.StringReader; |
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder; |
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory; |
|
|
|
|
|
import javax.xml.parsers.ParserConfigurationException; |
|
|
|
|
|
|
|
|
import org.testng.annotations.*; |
|
|
import org.testng.annotations.*; |
|
|
import org.w3c.dom.Document; |
|
|
import org.w3c.dom.Document; |
|
|
import org.w3c.dom.Element; |
|
|
import org.w3c.dom.Element; |
|
@@ -7,12 +13,6 @@ import org.w3c.dom.NodeList; |
|
|
import org.xml.sax.InputSource; |
|
|
import org.xml.sax.InputSource; |
|
|
import org.xml.sax.SAXException; |
|
|
import org.xml.sax.SAXException; |
|
|
|
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder; |
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory; |
|
|
|
|
|
import javax.xml.parsers.ParserConfigurationException; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.StringReader; |
|
|
|
|
|
|
|
|
|
|
|
import static org.testng.Assert.*; |
|
|
import static org.testng.Assert.*; |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
@@ -39,6 +39,7 @@ public class WxCryptUtilTest { |
|
|
System.out.println(encryptedXml); |
|
|
System.out.println(encryptedXml); |
|
|
|
|
|
|
|
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); |
|
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); |
|
|
|
|
|
documentBuilderFactory.setExpandEntityReferences(false); |
|
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); |
|
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); |
|
|
Document document = documentBuilder.parse(new InputSource(new StringReader(encryptedXml))); |
|
|
Document document = documentBuilder.parse(new InputSource(new StringReader(encryptedXml))); |
|
|
|
|
|
|
|
@@ -81,6 +82,7 @@ public class WxCryptUtilTest { |
|
|
WxCryptUtil pc = new WxCryptUtil(this.token, this.encodingAesKey, this.appId); |
|
|
WxCryptUtil pc = new WxCryptUtil(this.token, this.encodingAesKey, this.appId); |
|
|
String afterEncrpt = pc.encrypt(this.replyMsg); |
|
|
String afterEncrpt = pc.encrypt(this.replyMsg); |
|
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
|
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
|
|
|
|
|
dbf.setExpandEntityReferences(false); |
|
|
DocumentBuilder db = dbf.newDocumentBuilder(); |
|
|
DocumentBuilder db = dbf.newDocumentBuilder(); |
|
|
StringReader sr = new StringReader(afterEncrpt); |
|
|
StringReader sr = new StringReader(afterEncrpt); |
|
|
InputSource is = new InputSource(sr); |
|
|
InputSource is = new InputSource(sr); |
|
|