| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- package com.uas.credit.config;
- import com.uas.credit.support.Des;
- import org.springframework.beans.BeansException;
- import org.springframework.beans.factory.BeanInitializationException;
- import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
- import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
- import java.util.Properties;
- /**
- * 将加密的 userId password 进行解密
- * @author liuam
- * @since 2018/6/25 0025 下午 17:26
- */
- public class EncryptablePropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
- private static final String key = "10101010";
- protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
- throws BeansException {
- try {
- Des des = new Des();
- String userId = props.getProperty("pyconfig.userId");
- if (userId != null) {
- props.setProperty("pyconfig.userId", userId);
- }
- String password = props.getProperty("pyconfig.password");
- if (password != null) {
- props.setProperty("pyconfig.password", password);
- }
- // 自定义完成后调用父类方法
- super.processProperties(beanFactory, props);
- } catch (Exception e) {
- e.printStackTrace();
- throw new BeanInitializationException(e.getMessage());
- }
- }
- }
|