首页>代码>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();
}
}
}
}
}
}
最近下载更多
1271247100 LV9
11月22日
甜心冰淇淋 LV4
6月15日
微信网友_7321633020284928 LV2
1月1日
hongdongdong LV14
2024年6月12日
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日
最近浏览更多
1271247100 LV9
11月22日
vinlon
6月17日
暂无贡献等级
甜心冰淇淋 LV4
6月14日
shhhhhh
6月13日
暂无贡献等级
llxxyy
6月9日
暂无贡献等级
jhtxdy
5月4日
暂无贡献等级
hezhihui
1月9日
暂无贡献等级
微信网友_7321633020284928 LV2
1月1日
xiaoaitx LV8
1月1日
ma406805131 LV19
2024年12月27日

