|
|
@ -2,6 +2,7 @@ package com.ccsens.util.config; |
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64; |
|
|
|
import cn.hutool.core.util.CharsetUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.crypto.symmetric.SymmetricAlgorithm; |
|
|
|
import cn.hutool.crypto.symmetric.SymmetricCrypto; |
|
|
|
import com.alibaba.druid.pool.DruidDataSource; |
|
|
@ -62,12 +63,15 @@ public class DruidProps { |
|
|
|
|
|
|
|
datasource.setUrl(url); |
|
|
|
datasource.setUsername(username); |
|
|
|
String key = System.getenv(env); |
|
|
|
// String key = System.getenv("CCSENS_HT_PROD");
|
|
|
|
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); |
|
|
|
//解密为字符串
|
|
|
|
String decryptStr = aes.decryptStr(password, CharsetUtil.CHARSET_UTF_8); |
|
|
|
datasource.setPassword(decryptStr); |
|
|
|
if (StrUtil.isNotEmpty(password)) { |
|
|
|
String key = System.getenv(env); |
|
|
|
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key)); |
|
|
|
String decryptStr = aes.decryptStr(password, CharsetUtil.CHARSET_UTF_8); |
|
|
|
datasource.setPassword(decryptStr); |
|
|
|
} else { |
|
|
|
datasource.setPassword(""); |
|
|
|
} |
|
|
|
|
|
|
|
datasource.setDriverClassName(driverClassName); |
|
|
|
|
|
|
|
//configuration
|
|
|
|