提交 a15b80c6 编写于 作者: Z zhourui

fix datasource password

上级 d0852a41
......@@ -9,9 +9,13 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.LogLevel;
import com.x.base.core.container.factory.SlicePropertiesBuilder;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.Crypto;
public class ExternalDataSource extends ConfigObject {
// 无需保存
private transient String _password;
public ExternalDataSource() {
this.enable = false;
this.url = "";
......@@ -136,7 +140,10 @@ public class ExternalDataSource extends ConfigObject {
}
public String getPassword() {
return password;
if (StringUtils.isEmpty(this._password)) {
this._password = Crypto.plainText(this.password);
}
return this._password;
}
public void setPassword(String password) {
......
package com.x.base.core.project.config;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.StorageProtocol;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.Crypto;
public class ExternalStorageSource extends ConfigObject {
// 无需保存
private transient String _password;
public ExternalStorageSource() {
this.protocol = default_protocol;
this.username = default_username;
......@@ -66,7 +71,10 @@ public class ExternalStorageSource extends ConfigObject {
}
public String getPassword() {
return password;
if (StringUtils.isEmpty(this._password)) {
this._password = Crypto.plainText(this.password);
}
return this._password;
}
public String getHost() {
......
......@@ -95,7 +95,7 @@ public class Token extends ConfigObject {
}
}
public String getCipher() throws Exception {
public String getCipher() {
if (StringUtils.isEmpty(this._cipher)) {
this._cipher = DigestUtils.md5Hex(this.getPassword());
}
......@@ -103,7 +103,7 @@ public class Token extends ConfigObject {
// return this.getPassword() + surfix;
}
public String getPassword() throws Exception {
public String getPassword() {
if (StringUtils.isEmpty(this._password)) {
this._password = StringUtils.isEmpty(this.password) ? initPassword : Crypto.plainText(this.password);
}
......
......@@ -126,10 +126,11 @@ public class Crypto {
public static final String TEST_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWcVZIS57VeOUzi8c01WKvwJK9uRe6hrGTUYmF6J/pI6/UvCbdBWCoErbzsBZOElOH8Sqal3vsNMVLjPYClfoDyYDaUlakP3ldfnXJzAFJVVubF53KadG+fwnh9ZMvxdh7VXVqRL3IQBDwGgzX4rmSK+qkUJjc3OkrNJPB7LLD8QIDAQAB";
public static final String TEST_PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJZxVkhLntV45TOLxzTVYq/Akr25F7qGsZNRiYXon+kjr9S8Jt0FYKgStvOwFk4SU4fxKpqXe+w0xUuM9gKV+gPJgNpSVqQ/eV1+dcnMAUlVW5sXncpp0b5/CeH1ky/F2HtVdWpEvchAEPAaDNfiuZIr6qRQmNzc6Ss0k8HsssPxAgMBAAECgYAWtRy05NUgm5Lc6Og0jVDL/mEnydxPBy2ectwzHh2k7wIHNi8XhUxFki2TMqzrM9Dv3/LySpMl4AE3mhs34LNPy6F+MwyF5X7j+2Y6MflJyeb9HNyT++viysQneoOEiOk3ghxF2/GPjpiEF79wSp+1YKTxRAyq7ypV3t35fGOOEQJBANLDPWl8b5c3lrcz/dTamMjHbVamEyX43yzQOphzkhYsz4pruATzTxU+z8/zPdEqHcWWV39CP3xu3EYNcAhxJW8CQQC2u7PF5Xb1xYRCsmIPssFxil64vvdUadSxl7GLAgjQ9ULyYWB24KObCEzLnPcT8Pf2Q0YQOixxa/78FuzmgbyfAkA7ZFFV/H7lugB6t+f7p24OhkRFep9CwBMD6dnZRBgSr6X8d8ZvfrD2Z7DgBMeSva+OEoOtlNmXExZ3lynO9zN5AkAVczEmIMp3DSl6XtAuAZC9kD2QODJ2QToLYsAfjiyUwsWKCC43piTuVOoW2KUUPSwOR1VZIEsJQWEcHGDQqhgHAkAeZ7a6dVRZFdBwKA0ADjYCufAW2cIYiVDQBJpgB+kiLQflusNOCBK0FT3lg8BdUSy2D253Ih6l3lbaM/4M7DFQ";
public static String plainText(String text) throws Exception {
public static String plainText(String text) {
if (StringUtils.isEmpty(text)) {
return text;
}
try {
Matcher matcher = StringTools.SCRIPTTEXT_REGEX.matcher(text);
if (matcher.matches()) {
String value = StringEscapeUtils.unescapeJson(matcher.group(1));
......@@ -144,6 +145,10 @@ public class Crypto {
} else {
return text;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String defaultEncrypt(String data) throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册