From 73dedab20161786954c6eb591ad18575dcb7092e Mon Sep 17 00:00:00 2001 From: lengleng Date: Sat, 13 Mar 2021 16:19:50 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20closed=20##2476=20?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AF=86=E7=A0=81=E9=A6=96=E5=B0=BE=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=A4=9A=E4=B8=AA=E7=A9=BA=E6=A0=BC=E4=BB=BB=E7=84=B6?= =?UTF-8?q?=E8=83=BD=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/filter/PasswordDecoderFilter.java | 23 ++++++++----------- pom.xml | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java index efbe6b8ab..1ee739ce8 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java @@ -17,7 +17,13 @@ package com.pig4cloud.pigx.gateway.filter; -import cn.hutool.core.codec.Base64; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.Mode; @@ -55,13 +61,6 @@ import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - /** * @author lengleng * @date 2020/1/8 密码解密工具类 @@ -161,18 +160,16 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory { private Function decryptAES() { return s -> { // 构建前端对应解密AES 因子 - AES aes = new AES(Mode.CBC, Padding.NoPadding, + AES aes = new AES(Mode.CFB, Padding.NoPadding, new SecretKeySpec(gatewayConfig.getEncodeKey().getBytes(), KEY_ALGORITHM), new IvParameterSpec(gatewayConfig.getEncodeKey().getBytes())); // 获取请求密码并解密 Map inParamsMap = HttpUtil.decodeParamMap((String) s, CharsetUtil.CHARSET_UTF_8); if (inParamsMap.containsKey(PASSWORD)) { - byte[] result = aes.decrypt(Base64.decode(inParamsMap.get(PASSWORD).getBytes(StandardCharsets.UTF_8))); - String password = new String(result, StandardCharsets.UTF_8); - + String password = aes.decryptStr(inParamsMap.get(PASSWORD)); // 返回修改后报文字符 - inParamsMap.put(PASSWORD, password.trim()); + inParamsMap.put(PASSWORD, password); } else { log.error("非法请求数据:{}", s); diff --git a/pom.xml b/pom.xml index f53dc5f93..4187a5b21 100644 --- a/pom.xml +++ b/pom.xml @@ -206,7 +206,7 @@ - ${docker.registry}/${docker.namespace}/${project.name}:${project.version} + plw-harbor:8031/yxh/customize-gateway:3.10.0 ${project.basedir}/Dockerfile