From d90cf639dfa5035d0e5132bff4273273b30c09b7 Mon Sep 17 00:00:00 2001 From: haozq <1611483981@qq.com> Date: Fri, 22 Mar 2024 15:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=A0=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- securitycontrol-auth/src/main/resources/bootstrap.yml | 4 ++++ .../common/core/utils/aes/AesCbcUtils.java | 4 ++-- .../filter/RsaDecryptResponseGatewayFilterFactory.java | 10 ++++++++-- .../src/main/resources/bootstrap.yml | 6 ++++-- .../background/service/impl/HumanServiceImpl.java | 4 ++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/securitycontrol-auth/src/main/resources/bootstrap.yml b/securitycontrol-auth/src/main/resources/bootstrap.yml index 2de2c49..541084a 100644 --- a/securitycontrol-auth/src/main/resources/bootstrap.yml +++ b/securitycontrol-auth/src/main/resources/bootstrap.yml @@ -19,10 +19,14 @@ spring: server-addr: 127.0.0.1:8848 # server-addr: 27.196.164.56:8848 namespace: jjzhgd + username: nacos + password: Jjsp@nacos2023 config: # server-addr: 27.196.164.56:8848 server-addr: 127.0.0.1:8848 namespace: jjzhgd + username: nacos + password: Jjsp@nacos2023 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/AesCbcUtils.java b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/AesCbcUtils.java index 93644dc..dc77acb 100644 --- a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/AesCbcUtils.java +++ b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/AesCbcUtils.java @@ -75,9 +75,9 @@ public class AesCbcUtils { } public static void main(String[] args) { - String json="username=guest&password=admin@123"; + // String json="username=guest&password=admin@123"; - // String json="{\"username\":\"guest\",\"password\":\"admin@123\"}"; + String json="{\"username\":\"guest\",\"password\":\"admin@123\"}"; String data=encrypt(json); System.err.println(data); } diff --git a/securitycontrol-gateway/src/main/java/com/securitycontrol/gateway/filter/RsaDecryptResponseGatewayFilterFactory.java b/securitycontrol-gateway/src/main/java/com/securitycontrol/gateway/filter/RsaDecryptResponseGatewayFilterFactory.java index 06770ed..de9f518 100644 --- a/securitycontrol-gateway/src/main/java/com/securitycontrol/gateway/filter/RsaDecryptResponseGatewayFilterFactory.java +++ b/securitycontrol-gateway/src/main/java/com/securitycontrol/gateway/filter/RsaDecryptResponseGatewayFilterFactory.java @@ -8,6 +8,7 @@ import com.securitycontrol.common.core.utils.aes.AesCbcUtils; import com.securitycontrol.common.core.utils.aes.MonoUtils; import com.securitycontrol.common.core.utils.aes.StringHelper; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.core.io.buffer.DataBuffer; @@ -37,12 +38,17 @@ import java.security.interfaces.RSAPrivateKey; @Component class RsaDecryptResponseGatewayFilterFactory extends AbstractGatewayFilterFactory { + @Value("${system.jm}") + public boolean AQ_JM; + + @Override public GatewayFilter apply(Object config) { return (exchange, chain) -> { ServerHttpRequest serverHttpRequest = exchange.getRequest(); - HttpHeaders header = serverHttpRequest.getHeaders(); - String decrypt = serverHttpRequest.getHeaders().getFirst("decrypt"); + if(!AQ_JM){ + return chain.filter(exchange); + } //get请求 默认 if(HttpMethod.GET.matches(serverHttpRequest.getMethodValue())){//如果是get if(exchange.getRequest().getQueryParams().isEmpty()){//如果参数是空的 diff --git a/securitycontrol-gateway/src/main/resources/bootstrap.yml b/securitycontrol-gateway/src/main/resources/bootstrap.yml index 98cb880..2f6e830 100644 --- a/securitycontrol-gateway/src/main/resources/bootstrap.yml +++ b/securitycontrol-gateway/src/main/resources/bootstrap.yml @@ -17,7 +17,7 @@ spring: nacos: discovery: username: nacos - password: nacos + password: Jjsp@nacos2023 namespace: jjzhgd # 服务注册地址 server-addr: 127.0.0.1:8848 @@ -32,7 +32,7 @@ spring: shared-configs: - vsc-dev.yml username: nacos - password: nacos + password: Jjsp@nacos2023 namespace: jjzhgd # server-addr: 10.138.132.188:18848 management: @@ -48,4 +48,6 @@ management: endpoints: env: enable: false +system: + jm: false diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java index 1c1e9fb..5a624f9 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java @@ -39,7 +39,7 @@ public class HumanServiceImpl implements HumanService { @Resource(name = "HumanManageMapper") private HumanManageMapper mapper; - @Autowired + @Resource private RemoteFileService remoteFileService; @Resource(name = "ValidatorsUtils") @@ -111,7 +111,7 @@ public class HumanServiceImpl implements HumanService { } } } - vo.setIdNumber(AesCbcUtils.encrypt(vo.getIdNumber(),AesCbcUtils.sKey)); + vo.setIdNumber(AesCbcUtils.encrypt(vo.getIdNumber())); // 保存人员数据 mapper.addOrUpdatePersonnel(vo); } catch (Exception e) {