웹 프로젝트 의 properties 파일 암호 화
3597 단어 web
# url
jdbc.url=jdbc:oracle:thin:@192.168.0.25:1521:orcl
jdbc.username=CROSS_INFO_BASE
jdbc.password=<> public class EncryptedPlaceholderConfigurer extends PropertyPlaceholderConfigurer{
public static final String PREFIX = "<;
@Override
protected String convertPropertyValue(String originalValue) {
if (originalValue.startsWith(PREFIX)) {
logger.debug("Find encrypted value:" + originalValue);
String jmStr=originalValue.substring(2,originalValue.length()-2);
//
String newValue =Base64.getFromBase64(jmStr);
return newValue;
}
return originalValue;
}
}
<bean id="propertyConfigurer" class="org.work.util.EncryptedPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:config/jdbc.propertiesvalue>
<value>classpath*:config/hibernate.propertiesvalue>
<value>classpath*:config/redis.propertiesvalue>
list>
property>
bean>