This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
galaxy-k18-galaxy-service/src/main/java/com/nis/util/PropertyPlaceholderConfigurerCrypt.java

49 lines
1.6 KiB
Java
Raw Normal View History

2017-12-19 14:55:52 +08:00
package com.nis.util;
import java.util.Properties;
2018-10-18 19:19:59 +08:00
import com.zdjizhi.crypt.AESUtil;
2017-12-19 14:55:52 +08:00
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
public class PropertyPlaceholderConfigurerCrypt extends PropertyPlaceholderConfigurer {
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
throws BeansException {
try {
// mysql
2017-12-19 14:55:52 +08:00
String logPassword = props.getProperty("jdbc.log.password");
String logScretKey = props.getProperty("jdbc.log.key");
if (null != logPassword) {
props.setProperty("jdbc.log.password",
new String(AESUtil.decrypt(Base64.decodeBase64(logPassword), logScretKey)));
}
// clickhouse
String clickHousePassword = props.getProperty("jdbc.clickhouse.password");
String clickHouseScretKey = props.getProperty("jdbc.clickhouse.key");
if (null != clickHousePassword) {
props.setProperty("jdbc.clickhouse.password",
new String(AESUtil.decrypt(Base64.decodeBase64(clickHousePassword), clickHouseScretKey)));
}
// hive
String hivePassword = props.getProperty("jdbc.hive.password");
String hiveScretKey = props.getProperty("jdbc.hive.key");
if (null != clickHousePassword) {
props.setProperty("jdbc.hive.password",
new String(AESUtil.decrypt(Base64.decodeBase64(hivePassword), hiveScretKey)));
}
2017-12-19 14:55:52 +08:00
} catch (Exception e) {
e.printStackTrace();
}
super.processProperties(beanFactoryToProcess, props);
}
}