zoukankan      html  css  js  c++  java
  • 加密配置文件插件

    加密配置文件插件

    package cn.ucaner.alpaca.common.plugin;
    
    import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
    
    import cn.ucaner.alpaca.common.util.AESUtil;
    
    /**
    * @Package:cn.ucaner.alpaca.common.plugin   
    * @ClassName:EncryptPropertyPlaceholderConfigurer   
    * @Description:   <p> 支持加密配置文件插件 </p>
    * @Author: -    
    * @CreatTime:2018年5月24日 下午2:31:18   
    * @Modify By:   
    * @ModifyTime:  2018年5月24日
    * @Modify marker:   
    * @version    V1.0
     */
    public class EncryptPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
    
        /**
         * 需要加密的propertyNames[]
         */
        private String[] propertyNames = {
            "master.jdbc.password", 
            "slave.jdbc.password",
            "generator.jdbc.password",
            "master.redis.password"
        };
    
        /**
         * 解密指定propertyName的加密属性值
         * @param propertyName
         * @param propertyValue
         * @return
         */
        @Override
        protected String convertProperty(String propertyName, String propertyValue) {
            for (String p : propertyNames) {
                if (p.equalsIgnoreCase(propertyName)) {
                    return AESUtil.aesDecode(propertyValue);
                }
            }
            return super.convertProperty(propertyName, propertyValue);
        }
    
    }
  • 相关阅读:
    python迭代器与iter()函数实例教程
    手动安装python后,交互模式下退格键乱码
    find参数exec、管道符|、xargs的区别
    比较好的网址收集
    sed小知识总结
    irc操作小记
    irssi忽略退出,加入消息
    Web自动化简介
    android&ios区别
    移动自动化应用展望
  • 原文地址:https://www.cnblogs.com/jasonandy/p/9184951.html
Copyright © 2011-2022 走看看