From 0470d5d7aad4027e3b045345864c82687d3c8e5e Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 23 Apr 2024 11:30:05 +0800 Subject: [PATCH] =?UTF-8?q?gzip=E5=8E=8B=E7=BC=A9=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java | 9 ++++----- .../src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java | 5 ++--- .../java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java index a8df87f..65c343d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/GzipUtil.java @@ -1,9 +1,9 @@ package com.hz.pm.api.common.util; +import cn.hutool.core.codec.Base64Decoder; +import cn.hutool.core.codec.Base64Encoder; import cn.hutool.core.util.StrUtil; import com.ningdatech.basic.exception.BizException; -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -35,7 +35,7 @@ public class GzipUtil { gzip.write(content.getBytes()); gzip.finish(); byte[] bytes = bos.toByteArray(); - return new BASE64Encoder().encode(bytes); + return Base64Encoder.encode(bytes); } catch (IOException e) { throw new BizException(e); } @@ -48,8 +48,7 @@ public class GzipUtil { if (StrUtil.isBlank(content)) { return content; } - BASE64Decoder decoder = new BASE64Decoder(); - try (ByteArrayInputStream bis = new ByteArrayInputStream(decoder.decodeBuffer(content)); + try (ByteArrayInputStream bis = new ByteArrayInputStream(Base64Decoder.decode(content)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPInputStream gis = new GZIPInputStream(bis)) { byte[] buffer = new byte[1024 * 16]; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java b/hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java index ee336f3..70588ac 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/irs/sign/IRSAPIRequest.java @@ -1,5 +1,6 @@ package com.hz.pm.api.irs.sign; +import cn.hutool.core.codec.Base64Decoder; import cn.hutool.core.io.FileUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -18,7 +19,6 @@ import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import sun.misc.BASE64Decoder; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -242,8 +242,7 @@ public class IRSAPIRequest { * @param base64Content 文件的存储路径(含文件名) */ public static void base64StringToPdf(String base64Content, String filePath) throws IOException { - BASE64Decoder decoder = new BASE64Decoder(); - byte[] bytes = decoder.decodeBuffer(base64Content); + byte[] bytes = Base64Decoder.decode(base64Content); File file = new File(filePath); FileUtil.mkParentDirs(file); try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index 24837ae..222d3b8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -3,6 +3,7 @@ package com.hz.pm.api.todocenter.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.codec.Base64; +import cn.hutool.core.codec.Base64Decoder; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; @@ -102,7 +103,6 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; @@ -487,10 +487,9 @@ public class TodoCenterManage { String signPdf = IRSAPIRequest.createSignPdf(signReq); ByteArrayInputStream inputStream = null; if (Objects.nonNull(signPdf)) { - BASE64Decoder decoder = new BASE64Decoder(); try { //转码 - byte[] b = decoder.decodeBuffer(signPdf); + byte[] b = Base64Decoder.decode(signPdf); for (int i = 0; i < b.length; ++i) { if (b[i] < 0) {//调整异常数据 b[i] += 256;