From e53733b842dfd6de9fc17dc43ba81ca52f2246e9 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 20 Jul 2021 10:32:10 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E6=81=A2=E5=A4=8D=E8=AF=AF=E5=88=A0=E9=99=A4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/crypto/WxCryptUtil.java | 23 ++++++++----------- .../cp/tp/service/impl/WxCpTpServiceImpl.java | 12 ++++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java index aba5e2669..a73e01d0d 100755 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java @@ -36,19 +36,16 @@ public class WxCryptUtil { private static final Base64 BASE64 = new Base64(); private static final Charset CHARSET = StandardCharsets.UTF_8; - private static final ThreadLocal BUILDER_LOCAL = new ThreadLocal() { - @Override - protected DocumentBuilder initialValue() { - try { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setExpandEntityReferences(false); - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - return factory.newDocumentBuilder(); - } catch (ParserConfigurationException exc) { - throw new IllegalArgumentException(exc); - } + private static final ThreadLocal BUILDER_LOCAL = ThreadLocal.withInitial(() -> { + try { + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setExpandEntityReferences(false); + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + return factory.newDocumentBuilder(); + } catch (ParserConfigurationException exc) { + throw new IllegalArgumentException(exc); } - }; + }); protected byte[] aesKey; protected String token; @@ -67,7 +64,7 @@ public class WxCryptUtil { public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) { this.token = token; this.appidOrCorpid = appidOrCorpid; - this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey)); + this.aesKey = Base64.decodeBase64(CharMatcher.whitespace().removeFrom(encodingAesKey)); } private static String extractEncryptPart(String xml) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java new file mode 100644 index 000000000..58fb09cf9 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java @@ -0,0 +1,12 @@ +package me.chanjar.weixin.cp.tp.service.impl; + +/** + *
+ *  默认接口实现类,使用apache httpclient实现
+ * Created by zhenjun cai.
+ * 
+ * + * @author zhenjun cai + */ +public class WxCpTpServiceImpl extends WxCpTpServiceApacheHttpClientImpl { +}