xusl 1 jaar geleden
bovenliggende
commit
b1dfb7ee28

+ 0 - 57
backend/src/main/java/com/jiayue/pfr/config/EnvironmentPreparedListener.java

@@ -1,57 +0,0 @@
-package com.jiayue.pfr.config;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.jiayue.pfr.constant.SecretKeyConstants;
-import com.jiayue.pfr.util.SM2CryptUtils;
-import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
-import org.springframework.boot.env.OriginTrackedMapPropertySource;
-import org.springframework.context.ApplicationListener;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.MutablePropertySources;
-import org.springframework.core.env.PropertySource;
-
-/**
-*
-*
-* @author xsl
-* @since 2023/08/11
-*/
-
-public class EnvironmentPreparedListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent>{
-    @Override
-    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
-        ConfigurableEnvironment env = event.getEnvironment();
-        MutablePropertySources pss = env.getPropertySources();
-        List<PropertySource> list = new ArrayList<>();
-        for(PropertySource ps : pss){
-            Map<String,Object>  map = new HashMap<>();
-            if(ps instanceof OriginTrackedMapPropertySource){
-                OriginTrackedMapPropertySource propertySource = new OriginTrackedMapPropertySource(ps.getName(),map);
-                Map<String,Object> src = (Map<String,Object>)ps.getSource();
-                src.forEach((k,v)->{
-                    String strValue = String.valueOf(v);
-                    if(strValue.startsWith("JY[") && strValue.endsWith("]")) {
-                        // 此处进行截取出对应的密文 BR23C92223KKDNUIQMPLS0009 ,然后调用对应的解密算法进行解密操作
-                        v=SM2CryptUtils.decrypt(strValue.substring(3, strValue.length()-1), SecretKeyConstants.SERVER_PRIVATE_KEY);
-                    }
-                    map.put(k,v);
-                });
-                list.add(propertySource);
-            }
-        }
-        /**
-         此处是删除原来的 OriginTrackedMapPropertySource 对象,
-         把解密后新生成的放入到 Environment,为什么不直接修改原来的
-         OriginTrackedMapPropertySource 对象,此处不做过多解释
-         不懂的可以去看看它对应的源码,也算是留一个悬念,也是希望大家
-         能够没事多看一看源码。
-         */
-        list.forEach(ps->{
-            pss.remove(ps.getName());
-            pss.addLast(ps);
-        });
-    }
-}

+ 1 - 1
backend/src/main/resources/META-INF/spring.factories

@@ -1 +1 @@
-org.springframework.context.ApplicationListener=com.jiayue.pfr.config.EnvironmentPreparedListener
+

+ 3 - 3
backend/src/main/resources/application.yml

@@ -3,7 +3,7 @@ server:
   ssl:
     key-store: classpath:9564748_api.jiayuepowertech.com.pfx
     key-store-type: PKCS12
-    key-store-password: JY[7d28439aff975b7e01a6bde97cc460afbf70308b07b023809bf9d839e61284bb22ed37382bc5cd497b651b1f0e9e16befb8f590920cd9d2f452d30bcd8a06762199423c6f524f2085e66a3691fff57e7dd960714a8cc26da64f85a49ce18be812494fb33f29eea00]
+    key-store-password: s37d1gxm
     enabled-protocols: "TLSv1.2"
     ciphers: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
   servlet:
@@ -25,8 +25,8 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.alibaba.druid.pool.DruidDataSource
     url: jdbc:mysql://localhost:3306/pfr?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
-    username: JY[15a0b9e58aef5b73fbbc12ce85ab5046b22a703e45019dbf7dd7041c8c60ea061cca717220548d86baa4cab57ebcc42db62172178c4cc299f243cfe7a3550e3b367284368dc3a183b350b92b810da5b2030a647aaede5baf735c6dcc77700a5325773e91]
-    password: JY[bbe20dde79320dfbe7bca925e07c57c13d079c72f1547fb97023020262a339f2a293e466cfc9ee9f0cb7c139bdcb78bccdf0fe9090a3da72a09f645873af6a7696c286540112c2d0f634a15ed013827d078b6edd6afc45df94278d5cd0da622a2c88f5e52b4ad5b7ab]
+    username: root
+    password: '!QAZ2root'
 
 mybatis-plus:
   typeAliasesPackage: com.jiayue.pfr.entity