From fd58b3f2125ed3db8e2e521a1e1228102a243944 Mon Sep 17 00:00:00 2001 From: cofe Date: Fri, 8 Jan 2021 17:07:32 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20weixin-java-pay=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=8E=BB=E9=99=A4jackson=E4=BE=9D=E8=B5=96=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin-java-pay/pom.xml | 6 ------ .../wxpay/v3/auth/AutoUpdateCertificatesVerifier.java | 11 ++++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 2c56bdad9..0907f34b6 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -70,12 +70,6 @@ org.projectlombok lombok - - - com.fasterxml.jackson.core - jackson-databind - 2.10.0.pr1 - com.google.code.gson gson diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java index e93e3cd78..b49f6251a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java @@ -1,16 +1,17 @@ package com.github.binarywang.wxpay.v3.auth; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.github.binarywang.wxpay.v3.Credentials; import com.github.binarywang.wxpay.v3.Validator; import com.github.binarywang.wxpay.v3.WxPayV3HttpClientBuilder; import com.github.binarywang.wxpay.v3.util.AesUtils; import com.github.binarywang.wxpay.v3.util.PemUtils; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxRuntimeException; +import me.chanjar.weixin.common.util.json.GsonParser; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -158,15 +159,15 @@ public class AutoUpdateCertificatesVerifier implements Verifier { */ private List deserializeToCerts(byte[] apiV3Key, String body) throws GeneralSecurityException, IOException { AesUtils aesUtils = new AesUtils(apiV3Key); - ObjectMapper mapper = new ObjectMapper(); - JsonNode dataNode = mapper.readTree(body).get("data"); + final JsonObject json = GsonParser.parse(body); + final JsonArray dataNode = json.getAsJsonArray("data"); if (dataNode == null) { return Collections.emptyList(); } List newCertList = new ArrayList<>(); for (int i = 0, count = dataNode.size(); i < count; i++) { - JsonNode encryptCertificateNode = dataNode.get(i).get("encrypt_certificate"); + final JsonObject encryptCertificateNode = ((JsonObject) dataNode.get(i)).getAsJsonObject("encrypt_certificate"); //解密 String cert = aesUtils.decryptToString( encryptCertificateNode.get("associated_data").toString().replaceAll("\"", "")