首页>代码>ssm+maven搭建简单java学生信息后台管理系统>/com.student.smm/src/main/java/com/student/bizImpl/DecryptPropertyPlaceholderConfigurer.java
package com.student.bizImpl;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.Key;
import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;

import com.student.uilt.DESEncryptUtil;


public class DecryptPropertyPlaceholderConfigurer extends
        PropertyPlaceholderConfigurer
{
    private Resource[] locations;
    
    private Resource keyLocation;
    
    private String fileEncoding;
    
    public void setKeyLocation(Resource keyLocation)
    {
        this.keyLocation = keyLocation;
    }
    
    public void setLocations(Resource[] locations)
    {
        this.locations = locations;
    }
    
    public void loadProperties(Properties props) throws IOException
    {
        if (this.locations != null)
        {
            PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
            for (int i = 0; i < this.locations.length; i++)
            {
                Resource location = this.locations[i];
                if (logger.isInfoEnabled())
                {
                    logger.info("Loading properties file from " + location);
                }
                InputStream is = null;
                try
                {
                    is = location.getInputStream();
                    Key key = DESEncryptUtil.getKey(keyLocation.getInputStream());
                    is = DESEncryptUtil.doDecrypt(key, is);
                    if (fileEncoding != null)
                    {
                        propertiesPersister.load(props, new InputStreamReader(
                                is, fileEncoding));
                    }
                    else
                    {
                        propertiesPersister.load(props, is);
                    }
                }
                finally
                {
                    if (is != null)
                    {
                        is.close();
                    }
                }
            }
        }
    }
}
最近下载更多
zhangbo2020  LV6 2023年11月22日
李亮  LV19 2023年8月28日
wddqwe  LV1 2023年6月29日
微信网友_6505997864357888  LV3 2023年6月5日
ruoran7  LV1 2023年5月28日
qiangmin1223  LV12 2023年4月24日
kk1031  LV8 2023年4月13日
764364777  LV2 2023年2月23日
微信网友_6248713511227392  LV11 2022年12月5日
云龙123456  LV7 2022年12月2日
最近浏览更多
minjiang110  LV3 1月3日
zzzzzzz09173 2023年12月27日
暂无贡献等级
WBelong  LV7 2023年12月25日
磊哥哥哥哥  LV13 2023年12月22日
颜菜菜  LV2 2023年12月21日
wwwww816  LV3 2023年12月19日
zhangbo2020  LV6 2023年11月22日
jiemomo  LV12 2023年11月2日
husiyu  LV3 2023年10月4日
李亮  LV19 2023年8月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友