Commit 60b69ccc0930acfe858785797145ca95c0f05322

Authored by yangfei
Exists in master

Merge branch 'master' of https://git.healthbaby.com.cn/jiangjiazhi/center

Showing 5 changed files

parent/center.manager/src/main/resources/dev/jdbc.properties View file @ 60b69cc
1 1 # Datasource Configurations
2 2 jdbc.url=jdbc:mysql://119.90.57.26:3306/center?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
3 3 jdbc.username=center
4   -jdbc.password=lyms2015
  4 +jdbc.password=p6CBLGB3pp7LZCJXI2+1cA==
5 5  
6 6 #jdbc.url=jdbc:mysql://localhost:3306/center?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
7 7 #jdbc.username=root
parent/center.manager/src/main/resources/xml/app-datasource.xml View file @ 60b69cc
... ... @@ -11,6 +11,8 @@
11 11  
12 12 <!-- 启用CGliB -->
13 13 <aop:aspectj-autoproxy proxy-target-class="true"/>
  14 +
  15 + <bean id="dbPasswordCallback" class="com.lyms.common.db.DBPasswordCallback" lazy-init="true"/>
14 16  
15 17 <!-- base dataSource -->
16 18 <bean name="baseDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
17 19  
... ... @@ -42,11 +44,13 @@
42 44 </bean>
43 45  
44 46 <!-- 主库 -->
45   - <bean id="master-dataSource" name="master-dataSource" parent="baseDataSource" init-method="init">
  47 + <bean id="master-dataSource" name="master-dataSource" parent="baseDataSource" init-method="init" lazy-init="true">
46 48 <property name="url" value="${jdbc.url}" />
47 49 <!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" /> -->
48 50 <property name="username" value="${jdbc.username}" />
49 51 <property name="password" value="${jdbc.password}" />
  52 + <property name="connectionProperties" value="password=${jdbc.password}"/>
  53 + <property name="passwordCallback" ref="dbPasswordCallback"/>
50 54 </bean>
51 55  
52 56 <!--数据源切面注入spring-->
parent/core.sdk/src/main/java/com/lyms/common/db/DBPasswordCallback.java View file @ 60b69cc
... ... @@ -23,28 +23,28 @@
23 23 */
24 24 @SuppressWarnings("serial")
25 25 public class DBPasswordCallback extends DruidPasswordCallback {
26   - private static final byte[] key = { 9, -1, 0, 5, 39, 8, 6, 19 };
  26 + private static final byte[] key = { 56, 43, -44, 9, 5, -41, 0, -5, -39, 8, 8, -6, 19 };
27 27  
28   - public void setProperties(Properties properties) {
29   - super.setProperties(properties);
30   - String pwd = properties.getProperty("password");
31   - if (StringUtils.isNotBlank(pwd)) {
32   - try {
33   - String password = new String(DES.decrypt(Base64Utils.decode(pwd), key));
34   - setPassword(password.toCharArray());
35   - } catch (Exception e) {
36   - setPassword(pwd.toCharArray());
37   - }
38   - } else {
39   - setPassword("".toCharArray());
40   - }
41   - }
  28 + public void setProperties(Properties properties) {
  29 + super.setProperties(properties);
  30 + String pwd = properties.getProperty("password");
  31 + if (StringUtils.isNotBlank(pwd)) {
  32 + try {
  33 + String password = new String(DES.decrypt(Base64Utils.decode(pwd), key));
  34 + setPassword(password.toCharArray());
  35 + } catch (Exception e) {
  36 + setPassword(pwd.toCharArray());
  37 + }
  38 + } else {
  39 + setPassword("".toCharArray());
  40 + }
  41 + }
42 42  
43   - /**
44   - * 数据库密码回调解密
45   - * <!--数据源加密操作-->
  43 + /**
  44 + * 数据库密码回调解密
  45 + * <!--数据源加密操作-->
46 46 <bean id="dbPasswordCallback" class="com.lyms.common.db.DBPasswordCallback" lazy-init="true"/>
47   -
  47 +
48 48 <bean id="readDataSource" class="com.alibaba.druid.pool.DruidDataSource"
49 49 destroy-method="close" init-method="init" lazy-init="true">
50 50 <property name="password" value="${password}"/>
... ... @@ -52,11 +52,13 @@
52 52 <property name="connectionProperties" value="password=${password}"/>
53 53 <property name="passwordCallback" ref="dbPasswordCallback"/>
54 54 </bean>
55   - */
56   - public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException, Exception {
57   - String encrypt = Base64Utils.encode(DES.encrypt("root".getBytes(), key));
58   - System.out.println(encrypt);
59   - System.out.println( new String(DES.decrypt(Base64Utils.decode(encrypt), key)));
60   - }
  55 + */
  56 + public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException,
  57 + IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException,
  58 + Exception {
  59 + String encrypt = Base64Utils.encode(DES.encrypt("lyms2015".getBytes(), key));
  60 + System.out.println(encrypt);
  61 + System.out.println(new String(DES.decrypt(Base64Utils.decode(encrypt), key)));
  62 + }
61 63 }
parent/hospital.web/src/main/resources/dev/jdbc.properties View file @ 60b69cc
1 1 # Datasource Configurations
2 2 jdbc.url=jdbc:mysql://119.90.57.26:3306/hospital?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
3 3 jdbc.username=hospital
4   -jdbc.password=lyms2015
  4 +jdbc.password=p6CBLGB3pp7LZCJXI2+1cA==
5 5  
6 6 druid.initialSize=10
7 7 druid.minIdle=10
parent/hospital.web/src/main/resources/xml/app-datasource.xml View file @ 60b69cc
... ... @@ -10,6 +10,8 @@
10 10  
11 11 <!-- 启用CGliB -->
12 12 <aop:aspectj-autoproxy proxy-target-class="true" />
  13 +
  14 + <bean id="dbPasswordCallback" class="com.lyms.common.db.DBPasswordCallback" lazy-init="true"/>
13 15  
14 16 <!-- base dataSource -->
15 17 <bean name="baseDataSource" class="com.alibaba.druid.pool.DruidDataSource"
... ... @@ -45,6 +47,8 @@
45 47 <!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" /> -->
46 48 <property name="username" value="${jdbc.username}" />
47 49 <property name="password" value="${jdbc.password}" />
  50 + <property name="connectionProperties" value="password=${jdbc.password}"/>
  51 + <property name="passwordCallback" ref="dbPasswordCallback"/>
48 52 </bean>
49 53  
50 54