Skip to content

Commit e53733b

Browse files
committed
🎨 优化代码,恢复误删除代码
1 parent 1b48399 commit e53733b

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,16 @@ public class WxCryptUtil {
3636
private static final Base64 BASE64 = new Base64();
3737
private static final Charset CHARSET = StandardCharsets.UTF_8;
3838

39-
private static final ThreadLocal<DocumentBuilder> BUILDER_LOCAL = new ThreadLocal<DocumentBuilder>() {
40-
@Override
41-
protected DocumentBuilder initialValue() {
42-
try {
43-
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
44-
factory.setExpandEntityReferences(false);
45-
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
46-
return factory.newDocumentBuilder();
47-
} catch (ParserConfigurationException exc) {
48-
throw new IllegalArgumentException(exc);
49-
}
39+
private static final ThreadLocal<DocumentBuilder> BUILDER_LOCAL = ThreadLocal.withInitial(() -> {
40+
try {
41+
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
42+
factory.setExpandEntityReferences(false);
43+
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
44+
return factory.newDocumentBuilder();
45+
} catch (ParserConfigurationException exc) {
46+
throw new IllegalArgumentException(exc);
5047
}
51-
};
48+
});
5249

5350
protected byte[] aesKey;
5451
protected String token;
@@ -67,7 +64,7 @@ public WxCryptUtil() {
6764
public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) {
6865
this.token = token;
6966
this.appidOrCorpid = appidOrCorpid;
70-
this.aesKey = BaseEncoding.base64().decode(CharMatcher.whitespace().removeFrom(encodingAesKey));
67+
this.aesKey = Base64.decodeBase64(CharMatcher.whitespace().removeFrom(encodingAesKey));
7168
}
7269

7370
private static String extractEncryptPart(String xml) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package me.chanjar.weixin.cp.tp.service.impl;
2+
3+
/**
4+
* <pre>
5+
* 默认接口实现类,使用apache httpclient实现
6+
* Created by zhenjun cai.
7+
* </pre>
8+
*
9+
* @author zhenjun cai
10+
*/
11+
public class WxCpTpServiceImpl extends WxCpTpServiceApacheHttpClientImpl {
12+
}

0 commit comments

Comments
 (0)