提交 86c74cd5 authored 作者:  狄熙卜's avatar 狄熙卜

添加初始化判断

上级 452db1e3
...@@ -100,27 +100,28 @@ public class EncryptInterceptor implements Interceptor { ...@@ -100,27 +100,28 @@ public class EncryptInterceptor implements Interceptor {
*/ */
@Override @Override
public void setProperties(Properties properties) { public void setProperties(Properties properties) {
if(dbEncryptXmlConfig != null && dbEncryptXmlConfig.getConfigUrl() != null && StringUtils.isNotBlank( dbEncryptXmlConfig.getField("CryptType"))) {
this.cryptEnable = dbEncryptXmlConfig.getBooleanField("DatabaseEncryptEnable"); this.cryptEnable = dbEncryptXmlConfig.getBooleanField("DatabaseEncryptEnable");
String cryptTypeString = dbEncryptXmlConfig.getField("CryptType"); String cryptTypeString = dbEncryptXmlConfig.getField("CryptType");
CryptType cryptType = CryptType.valueOf(cryptTypeString); CryptType cryptType = CryptType.valueOf(cryptTypeString);
this.cryptProperties = new CryptProperties(this.cryptEnable,cryptType); this.cryptProperties = new CryptProperties(this.cryptEnable, cryptType);
String separator = dbEncryptXmlConfig.getField("Separator"); String separator = dbEncryptXmlConfig.getField("Separator");
if(StringUtils.isNotBlank(separator)) { if (StringUtils.isNotBlank(separator)) {
this.cryptProperties.setSeparator(separator); this.cryptProperties.setSeparator(separator);
} }
String sm4Salt = dbEncryptXmlConfig.getField("Sm4Salt"); String sm4Salt = dbEncryptXmlConfig.getField("Sm4Salt");
if(StringUtils.isNotBlank(sm4Salt)){ if (StringUtils.isNotBlank(sm4Salt)) {
this.cryptProperties.setSm4Salt(sm4Salt); this.cryptProperties.setSm4Salt(sm4Salt);
} }
boolean userSm4KeyEnable = dbEncryptXmlConfig.getBooleanField("UserSm4KeyEnable"); boolean userSm4KeyEnable = dbEncryptXmlConfig.getBooleanField("UserSm4KeyEnable");
this.cryptProperties.setUserSm4KeyEnable(userSm4KeyEnable); this.cryptProperties.setUserSm4KeyEnable(userSm4KeyEnable);
String sm4key = dbEncryptXmlConfig.getField("Sm4key"); String sm4key = dbEncryptXmlConfig.getField("Sm4key");
if(StringUtils.isNotBlank(sm4key)){ if (StringUtils.isNotBlank(sm4key)) {
this.cryptProperties.setSm4key(sm4key); this.cryptProperties.setSm4key(sm4key);
} }
String encoding = dbEncryptXmlConfig.getField("Encoding"); String encoding = dbEncryptXmlConfig.getField("Encoding");
if(StringUtils.isNotBlank(encoding)){ if (StringUtils.isNotBlank(encoding)) {
this.cryptProperties.setEncoding(encoding); this.cryptProperties.setEncoding(encoding);
} }
dbEncryptXmlConfig.getGlobalEnableFields(); dbEncryptXmlConfig.getGlobalEnableFields();
...@@ -146,4 +147,5 @@ public class EncryptInterceptor implements Interceptor { ...@@ -146,4 +147,5 @@ public class EncryptInterceptor implements Interceptor {
this.cryptProperties.setSqlSingleEncryptFields(dbEncryptXmlConfig.getSqlSingleEncryptFields()); this.cryptProperties.setSqlSingleEncryptFields(dbEncryptXmlConfig.getSqlSingleEncryptFields());
this.cryptProperties.setSqlSingleDecryptFields(dbEncryptXmlConfig.getSqlSingleDecryptFields()); this.cryptProperties.setSqlSingleDecryptFields(dbEncryptXmlConfig.getSqlSingleDecryptFields());
} }
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论