mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Encrypt tool and Decrypter
This commit is contained in:
@@ -221,6 +221,16 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
protected AtomicLong createCount = new AtomicLong();
|
||||
protected AtomicLong destroyCount = new AtomicLong();
|
||||
|
||||
protected Decrypter decrypter;
|
||||
|
||||
public Decrypter getDecrypter() {
|
||||
return decrypter;
|
||||
}
|
||||
|
||||
public void setDecrypter(Decrypter decrypter) {
|
||||
this.decrypter = decrypter;
|
||||
}
|
||||
|
||||
public boolean isOracle() {
|
||||
return isOracle;
|
||||
}
|
||||
@@ -1237,6 +1247,18 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
}
|
||||
}
|
||||
|
||||
Decrypter decrypter1 = this.getDecrypter();
|
||||
if (decrypter1 != null) {
|
||||
try {
|
||||
SensitiveParameters parameters = decrypter1.decrypt(new SensitiveParameters(url, user, password));
|
||||
url = parameters.getUrl();
|
||||
user = parameters.getUsername();
|
||||
password = parameters.getPassword();
|
||||
} catch (DecryptException e) {
|
||||
throw new SQLException("Failed to decrypt sensitive parameters.", e);
|
||||
}
|
||||
}
|
||||
|
||||
Properties physicalConnectProperties = new Properties();
|
||||
if (connectProperties != null) {
|
||||
physicalConnectProperties.putAll(connectProperties);
|
||||
|
||||
Reference in New Issue
Block a user