mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Merge pull request #990 from shicmV5/master
增加 目标数据库密码加密解密,采用druid方式进行加密解密,并设置canal.instance.enableDruid=true时,请使…
This commit is contained in:
@@ -31,8 +31,12 @@ canal.instance.tsdb.enable=true
|
||||
|
||||
# username/password
|
||||
canal.instance.dbUsername=canal
|
||||
canal.instance.dbPassword=canal
|
||||
canal.instance.connectionCharset=UTF-8
|
||||
canal.instance.dbPassword=cZozNf1mzW6EQLGO2q9u99619xbZLO0fbua3EX08r4BWNXb8lAt1aHrTEOBttd6UY8Vnuc0easlVXZDdLtt8BQ==
|
||||
canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
|
||||
canal.instance.connectionCharset = UTF-8
|
||||
canal.instance.defaultDatabaseName =test
|
||||
# enable druid Decrypt database password
|
||||
canal.instance.enableDruid=true
|
||||
|
||||
# table regex
|
||||
canal.instance.filter.regex=.*\\..*
|
||||
|
||||
@@ -126,18 +126,22 @@
|
||||
|
||||
<!-- 解析数据库信息 -->
|
||||
<property name="masterInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.master.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="standbyInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.standby.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
|
||||
@@ -111,18 +111,22 @@
|
||||
|
||||
<!-- 解析数据库信息 -->
|
||||
<property name="masterInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.master.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="standbyInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.standby.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
|
||||
@@ -108,18 +108,22 @@
|
||||
|
||||
<!-- 解析数据库信息 -->
|
||||
<property name="masterInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.master1.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="standbyInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.standby1.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
@@ -206,18 +210,22 @@
|
||||
|
||||
<!-- 解析数据库信息 -->
|
||||
<property name="masterInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.master2.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="standbyInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.standby2.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
|
||||
@@ -99,18 +99,22 @@
|
||||
|
||||
<!-- 解析数据库信息 -->
|
||||
<property name="masterInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.master.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="standbyInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo">
|
||||
<bean class="com.alibaba.otter.canal.parse.support.AuthenticationInfo" init-method="initPwd">
|
||||
<property name="address" value="${canal.instance.standby.address}" />
|
||||
<property name="username" value="${canal.instance.dbUsername:retl}" />
|
||||
<property name="password" value="${canal.instance.dbPassword:retl}" />
|
||||
<property name="pwdPublicKey" value="${canal.instance.pwdPublicKey:retl}" />
|
||||
<property name="enableDruid" value="${canal.instance.enableDruid:false}" />
|
||||
<property name="defaultDatabaseName" value="${canal.instance.defaultDatabaseName:test}" />
|
||||
</bean>
|
||||
</property>
|
||||
|
||||
@@ -27,9 +27,12 @@ canal.instance.master2.timestamp =
|
||||
|
||||
# username/password
|
||||
canal.instance.dbUsername = xxxxx
|
||||
canal.instance.dbPassword = xxxxx
|
||||
canal.instance.dbPassword=cZozNf1mzW6EQLGO2q9u99619xbZLO0fbua3EX08r4BWNXb8lAt1aHrTEOBttd6UY8Vnuc0easlVXZDdLtt8BQ==
|
||||
canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
|
||||
canal.instance.defaultDatabaseName =
|
||||
canal.instance.connectionCharset = UTF-8
|
||||
# enable druid Decrypt database password
|
||||
canal.instance.enableDruid=true
|
||||
|
||||
# table regex
|
||||
canal.instance.filter.regex = .*\\..*
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.alibaba.otter.canal.parse.support;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringStyle;
|
||||
|
||||
@@ -13,10 +14,20 @@ import org.apache.commons.lang.builder.ToStringStyle;
|
||||
*/
|
||||
public class AuthenticationInfo {
|
||||
|
||||
|
||||
|
||||
private InetSocketAddress address; // 主库信息
|
||||
private String username; // 帐号
|
||||
private String password; // 密码
|
||||
private String defaultDatabaseName; // 默认链接的数据库
|
||||
private String defaultDatabaseName;// 默认链接的数据库
|
||||
private String pwdPublicKey; //公钥
|
||||
private boolean enableDruid; //是否使用druid加密解密数据库密码
|
||||
|
||||
public void initPwd() throws Exception{
|
||||
if (enableDruid) {
|
||||
this.password = ConfigTools.decrypt(pwdPublicKey, password);
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationInfo(){
|
||||
super();
|
||||
@@ -65,6 +76,22 @@ public class AuthenticationInfo {
|
||||
this.defaultDatabaseName = defaultDatabaseName;
|
||||
}
|
||||
|
||||
public String getPwdPublicKey() {
|
||||
return pwdPublicKey;
|
||||
}
|
||||
|
||||
public void setPwdPublicKey(String pwdPublicKey) {
|
||||
this.pwdPublicKey = pwdPublicKey;
|
||||
}
|
||||
|
||||
public boolean isEnableDruid() {
|
||||
return enableDruid;
|
||||
}
|
||||
|
||||
public void setEnableDruid(boolean enableDruid) {
|
||||
this.enableDruid = enableDruid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
|
||||
|
||||
Reference in New Issue
Block a user