|
|
@@ -0,0 +1,39 @@
|
|
|
+package com.uas.platform.b2c.core.support;
|
|
|
+
|
|
|
+import com.uas.platform.core.util.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;
|
|
|
+
|
|
|
+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 username = props.getProperty("jdbc.username");
|
|
|
+ if (username != null) {
|
|
|
+ props.setProperty("jdbc.username", des.decrypt(username, key));
|
|
|
+ }
|
|
|
+
|
|
|
+ String password = props.getProperty("jdbc.password");
|
|
|
+ if (password != null) {
|
|
|
+ props.setProperty("jdbc.password", des.decrypt(password, key));
|
|
|
+ }
|
|
|
+
|
|
|
+ String url = props.getProperty("jdbc.url");
|
|
|
+ if (url != null) {
|
|
|
+ props.setProperty("jdbc.url", des.decrypt(url, key));
|
|
|
+ }
|
|
|
+
|
|
|
+ super.processProperties(beanFactory, props);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new BeanInitializationException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|