From 75aca761508907a2b6ad2118361994cf963a5065 Mon Sep 17 00:00:00 2001 From: yangyang01000846 <15195822163@163.com> Date: Tue, 30 Dec 2025 18:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=A0=E5=AF=86&=E8=A7=A3=E5=AF=86=E5=AF=86=E9=92=A5?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=B9=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/META-INF/spring.factories | 1 - .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - .../src/main/resources/bin/190/start.sh | 2 +- capability/src/main/resources/bin/65/start.sh | 2 +- .../DecryptEnvironmentPostProcessor.java | 14 +++++- .../java/com/sdm/common/utils/AESUtil.java | 43 ++++++++++------ .../main/resources/META-INF/spring.factories | 1 + .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - data/src/main/resources/bin/190/start.sh | 2 +- data/src/main/resources/bin/65/start.sh | 2 +- flowable/src/main/resources/bin/190/start.sh | 2 +- flowable/src/main/resources/bin/65/start.sh | 2 +- gateway2/src/main/resources/bin/190/start.sh | 2 +- gateway2/src/main/resources/bin/65/start.sh | 2 +- .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - pbs/src/main/resources/bin/190/start.sh | 2 +- pbs/src/main/resources/bin/65/start.sh | 2 +- .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - project/src/main/resources/bin/190/start.sh | 2 +- project/src/main/resources/bin/65/start.sh | 2 +- .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - system/src/main/resources/bin/190/start.sh | 2 +- system/src/main/resources/bin/65/start.sh | 2 +- .../DecryptEnvironmentPostProcessor.java | 49 ------------------- .../main/resources/META-INF/spring.factories | 1 - task/src/main/resources/bin/190/start.sh | 2 +- task/src/main/resources/bin/65/start.sh | 2 +- 34 files changed, 56 insertions(+), 385 deletions(-) delete mode 100644 approve/src/main/resources/META-INF/spring.factories delete mode 100644 capability/src/main/java/com/sdm/capability/config/DecryptEnvironmentPostProcessor.java delete mode 100644 capability/src/main/resources/META-INF/spring.factories rename {approve/src/main/java/com/sdm/approve => common/src/main/java/com/sdm/common}/config/DecryptEnvironmentPostProcessor.java (73%) create mode 100644 common/src/main/resources/META-INF/spring.factories delete mode 100644 data/src/main/java/com/sdm/data/config/DecryptEnvironmentPostProcessor.java delete mode 100644 data/src/main/resources/META-INF/spring.factories delete mode 100644 pbs/src/main/java/com/sdm/pbs/config/DecryptEnvironmentPostProcessor.java delete mode 100644 pbs/src/main/resources/META-INF/spring.factories delete mode 100644 performance/src/main/java/com/sdm/performance/config/DecryptEnvironmentPostProcessor.java delete mode 100644 performance/src/main/resources/META-INF/spring.factories delete mode 100644 project/src/main/java/com/sdm/project/config/DecryptEnvironmentPostProcessor.java delete mode 100644 project/src/main/resources/META-INF/spring.factories delete mode 100644 system/src/main/java/com/sdm/system/config/DecryptEnvironmentPostProcessor.java delete mode 100644 system/src/main/resources/META-INF/spring.factories delete mode 100644 task/src/main/java/com/sdm/task/config/DecryptEnvironmentPostProcessor.java delete mode 100644 task/src/main/resources/META-INF/spring.factories diff --git a/approve/src/main/resources/META-INF/spring.factories b/approve/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 999dd729..00000000 --- a/approve/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.approve.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/capability/src/main/java/com/sdm/capability/config/DecryptEnvironmentPostProcessor.java b/capability/src/main/java/com/sdm/capability/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 181f52f9..00000000 --- a/capability/src/main/java/com/sdm/capability/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.capability.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/capability/src/main/resources/META-INF/spring.factories b/capability/src/main/resources/META-INF/spring.factories deleted file mode 100644 index b54e938e..00000000 --- a/capability/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.capability.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/capability/src/main/resources/bin/190/start.sh b/capability/src/main/resources/bin/190/start.sh index 57ec92f4..ed0d2dcb 100644 --- a/capability/src/main/resources/bin/190/start.sh +++ b/capability/src/main/resources/bin/190/start.sh @@ -42,7 +42,7 @@ fi echo "正在启动项目..." # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5001 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5001 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/capability/src/main/resources/bin/65/start.sh b/capability/src/main/resources/bin/65/start.sh index 3508dbc5..de71c0d5 100644 --- a/capability/src/main/resources/bin/65/start.sh +++ b/capability/src/main/resources/bin/65/start.sh @@ -42,7 +42,7 @@ fi echo "正在启动项目..." # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5001 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5001 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/approve/src/main/java/com/sdm/approve/config/DecryptEnvironmentPostProcessor.java b/common/src/main/java/com/sdm/common/config/DecryptEnvironmentPostProcessor.java similarity index 73% rename from approve/src/main/java/com/sdm/approve/config/DecryptEnvironmentPostProcessor.java rename to common/src/main/java/com/sdm/common/config/DecryptEnvironmentPostProcessor.java index d82a972b..efff0551 100644 --- a/approve/src/main/java/com/sdm/approve/config/DecryptEnvironmentPostProcessor.java +++ b/common/src/main/java/com/sdm/common/config/DecryptEnvironmentPostProcessor.java @@ -1,6 +1,7 @@ -package com.sdm.approve.config; +package com.sdm.common.config; import com.sdm.common.utils.AESUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.core.env.*; @@ -28,11 +29,20 @@ public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); // 调用自定义工具类解密 String decryptedValue = null; + Long t1 = System.currentTimeMillis(); + // 优先读取JVM参数,然后环境变量参数,没有就报错 + String spdmEnkey = StringUtils.isBlank(System.getProperty("spdm.enkey"))? + System.getenv("spdm.enkey"):System.getProperty("spdm.enkey"); + if(StringUtils.isBlank(spdmEnkey)){ + throw new RuntimeException("spdm加密配置密钥读取失败!"); + } try { - decryptedValue = AESUtil.decode(encryptedValue); + decryptedValue = AESUtil.decodeNew(encryptedValue,spdmEnkey); } catch (Exception e) { throw new RuntimeException(e); } + Long t2 = System.currentTimeMillis(); + System.out.println("解密耗时: " + (t2 - t1) + "ms"); // 保存需要替换的配置 props.put(propertyName, decryptedValue); } diff --git a/common/src/main/java/com/sdm/common/utils/AESUtil.java b/common/src/main/java/com/sdm/common/utils/AESUtil.java index 8c8e945a..6d4a6c47 100644 --- a/common/src/main/java/com/sdm/common/utils/AESUtil.java +++ b/common/src/main/java/com/sdm/common/utils/AESUtil.java @@ -1,6 +1,7 @@ package com.sdm.common.utils; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.springframework.stereotype.Component; @@ -17,13 +18,14 @@ import java.util.Base64; @Component public class AESUtil { - private static final String FINAL_PARAM = "XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c="; +// private static final String FINAL_PARAM = "XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c="; /** * 块大小固定为8字节 */ private final static String AES_CBC_PKCS5PADDING = "AES/ECB/PKCS5Padding"; + /** * 加密 * @@ -31,8 +33,8 @@ public class AESUtil { * @return 密文 * @throws Exception */ - public static String encode(String content) throws Exception { - byte[] key = Base64.getDecoder().decode(FINAL_PARAM); + public static String encodeNew(String content,String keyStr) throws Exception { + byte[] key = Base64.getDecoder().decode(keyStr); byte[] data = content.getBytes(); SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); @@ -40,6 +42,7 @@ public class AESUtil { return Base64.getEncoder().encodeToString(cipher.doFinal(data)); } + /** * 解密 * @@ -47,8 +50,8 @@ public class AESUtil { * @return 解密后的数据 * @throws Exception */ - public static String decode(String content) throws Exception { - byte[] key = Base64.getDecoder().decode(FINAL_PARAM); + public static String decodeNew(String content,String keyStr) throws Exception { + byte[] key = Base64.getDecoder().decode(keyStr); SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); @@ -71,17 +74,6 @@ public class AESUtil { return keyGenerator.generateKey(); } -// public static void main(String[] args) { -// try { -// String ret = encode("03BD691EB0264CECF79"); -// System.out.println("encode:" + ret); -// String raw = decode(ret); -// System.out.println("decode:" + raw); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } - /** * get Cipher * @@ -211,4 +203,23 @@ public class AESUtil { } return cipherText; } + + public static void main(String[] args) { + try { + // 优先读取JVM参数,然后环境变量参数,没有就报错 + String spdmEnkey = StringUtils.isBlank(System.getProperty("spdm.enkey"))? + System.getenv("spdm.enkey"):System.getProperty("spdm.enkey"); + if(StringUtils.isBlank(spdmEnkey)){ + throw new RuntimeException("spdm加密配置密钥读取失败!"); + } + System.out.println("密钥是:"+spdmEnkey); + String ret = encodeNew("我是原文:8899",spdmEnkey); + System.out.println("encode:" + ret); + String raw = decodeNew(ret,spdmEnkey); + System.out.println("decode:" + raw); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } diff --git a/common/src/main/resources/META-INF/spring.factories b/common/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..ad07f7f0 --- /dev/null +++ b/common/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.common.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/config/DecryptEnvironmentPostProcessor.java b/data/src/main/java/com/sdm/data/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 64fe9946..00000000 --- a/data/src/main/java/com/sdm/data/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.data.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/data/src/main/resources/META-INF/spring.factories b/data/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 7e2fe91f..00000000 --- a/data/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.data.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/data/src/main/resources/bin/190/start.sh b/data/src/main/resources/bin/190/start.sh index 882a1769..ed670570 100644 --- a/data/src/main/resources/bin/190/start.sh +++ b/data/src/main/resources/bin/190/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5002 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & \ No newline at end of file +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5002 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & \ No newline at end of file diff --git a/data/src/main/resources/bin/65/start.sh b/data/src/main/resources/bin/65/start.sh index 369f8ea9..b6691f6f 100644 --- a/data/src/main/resources/bin/65/start.sh +++ b/data/src/main/resources/bin/65/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5002 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & \ No newline at end of file +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5002 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & \ No newline at end of file diff --git a/flowable/src/main/resources/bin/190/start.sh b/flowable/src/main/resources/bin/190/start.sh index 7f41d623..ca7c416b 100644 --- a/flowable/src/main/resources/bin/190/start.sh +++ b/flowable/src/main/resources/bin/190/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5003 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5003 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/flowable/src/main/resources/bin/65/start.sh b/flowable/src/main/resources/bin/65/start.sh index 2527184c..7d3628b7 100644 --- a/flowable/src/main/resources/bin/65/start.sh +++ b/flowable/src/main/resources/bin/65/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5003 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5003 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/gateway2/src/main/resources/bin/190/start.sh b/gateway2/src/main/resources/bin/190/start.sh index 0dd51014..bd73f348 100644 --- a/gateway2/src/main/resources/bin/190/start.sh +++ b/gateway2/src/main/resources/bin/190/start.sh @@ -43,6 +43,6 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/gateway2/src/main/resources/bin/65/start.sh b/gateway2/src/main/resources/bin/65/start.sh index d59ce663..532f3483 100644 --- a/gateway2/src/main/resources/bin/65/start.sh +++ b/gateway2/src/main/resources/bin/65/start.sh @@ -43,6 +43,6 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/pbs/src/main/java/com/sdm/pbs/config/DecryptEnvironmentPostProcessor.java b/pbs/src/main/java/com/sdm/pbs/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 0e90dd26..00000000 --- a/pbs/src/main/java/com/sdm/pbs/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.pbs.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/pbs/src/main/resources/META-INF/spring.factories b/pbs/src/main/resources/META-INF/spring.factories deleted file mode 100644 index bdf18fb2..00000000 --- a/pbs/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.pbs.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/pbs/src/main/resources/bin/190/start.sh b/pbs/src/main/resources/bin/190/start.sh index 4ce3508c..4ad90063 100644 --- a/pbs/src/main/resources/bin/190/start.sh +++ b/pbs/src/main/resources/bin/190/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5004 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5004 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/pbs/src/main/resources/bin/65/start.sh b/pbs/src/main/resources/bin/65/start.sh index e7ba50e2..c241790f 100644 --- a/pbs/src/main/resources/bin/65/start.sh +++ b/pbs/src/main/resources/bin/65/start.sh @@ -42,4 +42,4 @@ fi # 启动项目 echo "正在启动项目..." -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5004 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5004 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/performance/src/main/java/com/sdm/performance/config/DecryptEnvironmentPostProcessor.java b/performance/src/main/java/com/sdm/performance/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 10bece9c..00000000 --- a/performance/src/main/java/com/sdm/performance/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.performance.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/performance/src/main/resources/META-INF/spring.factories b/performance/src/main/resources/META-INF/spring.factories deleted file mode 100644 index cf215a2d..00000000 --- a/performance/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.performance.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/project/src/main/java/com/sdm/project/config/DecryptEnvironmentPostProcessor.java b/project/src/main/java/com/sdm/project/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index c348cc5b..00000000 --- a/project/src/main/java/com/sdm/project/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.project.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/project/src/main/resources/META-INF/spring.factories b/project/src/main/resources/META-INF/spring.factories deleted file mode 100644 index e9b7253f..00000000 --- a/project/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.project.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/project/src/main/resources/bin/190/start.sh b/project/src/main/resources/bin/190/start.sh index 0199ff76..5b8140c5 100644 --- a/project/src/main/resources/bin/190/start.sh +++ b/project/src/main/resources/bin/190/start.sh @@ -42,4 +42,4 @@ fi echo "正在启动项目... " # 启动项目并保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/project/src/main/resources/bin/65/start.sh b/project/src/main/resources/bin/65/start.sh index 260d37c5..d5a14c55 100644 --- a/project/src/main/resources/bin/65/start.sh +++ b/project/src/main/resources/bin/65/start.sh @@ -42,4 +42,4 @@ fi echo "正在启动项目... " # 启动项目并保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/system/src/main/java/com/sdm/system/config/DecryptEnvironmentPostProcessor.java b/system/src/main/java/com/sdm/system/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 9e7ace37..00000000 --- a/system/src/main/java/com/sdm/system/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.system.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/system/src/main/resources/META-INF/spring.factories b/system/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 502739a6..00000000 --- a/system/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.system.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/system/src/main/resources/bin/190/start.sh b/system/src/main/resources/bin/190/start.sh index d9e167c8..e0dc5138 100644 --- a/system/src/main/resources/bin/190/start.sh +++ b/system/src/main/resources/bin/190/start.sh @@ -42,5 +42,5 @@ fi echo "正在启动项目..." # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5006 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5006 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/system/src/main/resources/bin/65/start.sh b/system/src/main/resources/bin/65/start.sh index e888ec8c..704f8e7d 100644 --- a/system/src/main/resources/bin/65/start.sh +++ b/system/src/main/resources/bin/65/start.sh @@ -42,5 +42,5 @@ fi echo "正在启动项目..." # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5006 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5006 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/task/src/main/java/com/sdm/task/config/DecryptEnvironmentPostProcessor.java b/task/src/main/java/com/sdm/task/config/DecryptEnvironmentPostProcessor.java deleted file mode 100644 index 74667fba..00000000 --- a/task/src/main/java/com/sdm/task/config/DecryptEnvironmentPostProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sdm.task.config; - -import com.sdm.common.utils.AESUtil; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.*; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Properties props = new Properties(); // 临时存储需要替换的配置 - // 假设加密密码前缀为 "ENC(",后缀为 ")" - MutablePropertySources propertySources = environment.getPropertySources(); - for (PropertySource propertySource : propertySources) { - if (propertySource instanceof EnumerablePropertySource) { - EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; - String[] propertyNames = enumerablePropertySource.getPropertyNames(); - // 遍历所有配置key:value - for (String propertyName : propertyNames) { - String propertyVal = environment.getProperty(propertyName); - // 根据自己写的规则来解析那些配置是需要解密的 - if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { - // 解析得到加密的数据 - String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); - // 调用自定义工具类解密 - String decryptedValue = null; - try { - decryptedValue = AESUtil.decode(encryptedValue); - } catch (Exception e) { - throw new RuntimeException(e); - } - // 保存需要替换的配置 - props.put(propertyName, decryptedValue); - } - } - } - } - // 添加解密后的属性到环境中 - if (!props.isEmpty()) { - PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); - environment.getPropertySources().addFirst(pps); - } - } -} - diff --git a/task/src/main/resources/META-INF/spring.factories b/task/src/main/resources/META-INF/spring.factories deleted file mode 100644 index fc692aa1..00000000 --- a/task/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.env.EnvironmentPostProcessor=com.sdm.task.config.DecryptEnvironmentPostProcessor \ No newline at end of file diff --git a/task/src/main/resources/bin/190/start.sh b/task/src/main/resources/bin/190/start.sh index 2f4c8093..93b52462 100644 --- a/task/src/main/resources/bin/190/start.sh +++ b/task/src/main/resources/bin/190/start.sh @@ -43,5 +43,5 @@ echo "正在启动项目..." echo "======================================================================" # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5007 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5007 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & diff --git a/task/src/main/resources/bin/65/start.sh b/task/src/main/resources/bin/65/start.sh index 1c8e4c2d..6599c053 100644 --- a/task/src/main/resources/bin/65/start.sh +++ b/task/src/main/resources/bin/65/start.sh @@ -43,5 +43,5 @@ echo "正在启动项目..." echo "======================================================================" # 启动项目,保留控制台输出 -nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5007 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 & +nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-65 -Dspdm.enkey=XzKRqYnUypdE8VJ41yo/i0rMpZ0IlztSZ1PqWhr0q/c= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5007 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 &