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

添加初始化判断

上级 452db1e3
......@@ -100,50 +100,52 @@ public class EncryptInterceptor implements Interceptor {
*/
@Override
public void setProperties(Properties properties) {
this.cryptEnable = dbEncryptXmlConfig.getBooleanField("DatabaseEncryptEnable");
String cryptTypeString = dbEncryptXmlConfig.getField("CryptType");
CryptType cryptType = CryptType.valueOf(cryptTypeString);
this.cryptProperties = new CryptProperties(this.cryptEnable,cryptType);
if(dbEncryptXmlConfig != null && dbEncryptXmlConfig.getConfigUrl() != null && StringUtils.isNotBlank( dbEncryptXmlConfig.getField("CryptType"))) {
this.cryptEnable = dbEncryptXmlConfig.getBooleanField("DatabaseEncryptEnable");
String cryptTypeString = dbEncryptXmlConfig.getField("CryptType");
CryptType cryptType = CryptType.valueOf(cryptTypeString);
this.cryptProperties = new CryptProperties(this.cryptEnable, cryptType);
String separator = dbEncryptXmlConfig.getField("Separator");
if(StringUtils.isNotBlank(separator)) {
this.cryptProperties.setSeparator(separator);
String separator = dbEncryptXmlConfig.getField("Separator");
if (StringUtils.isNotBlank(separator)) {
this.cryptProperties.setSeparator(separator);
}
String sm4Salt = dbEncryptXmlConfig.getField("Sm4Salt");
if (StringUtils.isNotBlank(sm4Salt)) {
this.cryptProperties.setSm4Salt(sm4Salt);
}
boolean userSm4KeyEnable = dbEncryptXmlConfig.getBooleanField("UserSm4KeyEnable");
this.cryptProperties.setUserSm4KeyEnable(userSm4KeyEnable);
String sm4key = dbEncryptXmlConfig.getField("Sm4key");
if (StringUtils.isNotBlank(sm4key)) {
this.cryptProperties.setSm4key(sm4key);
}
String encoding = dbEncryptXmlConfig.getField("Encoding");
if (StringUtils.isNotBlank(encoding)) {
this.cryptProperties.setEncoding(encoding);
}
dbEncryptXmlConfig.getGlobalEnableFields();
dbEncryptXmlConfig.getGlobalDisableMapFields();
dbEncryptXmlConfig.getGlobalDisableEntityFields();
dbEncryptXmlConfig.getSqlFields();
dbEncryptXmlConfig.getSqlEncryptFields();
dbEncryptXmlConfig.getSqlDecryptFields();
dbEncryptXmlConfig.getEntityFields();
dbEncryptXmlConfig.getSqlSingleEncryptFields();
dbEncryptXmlConfig.getSqlSingleDecryptFields();
//添加预置的字段
dbEncryptXmlConfig.addBaseConfigFields();
//根据注解获取加解密配置
dbEncryptXmlConfig.addAnnotationConfigFields();
this.cryptProperties.setGlobalEnableFields(dbEncryptXmlConfig.getGlobalEnableFields());
this.cryptProperties.setGlobalDisableMapFields(dbEncryptXmlConfig.getGlobalDisableMapFields());
this.cryptProperties.setGlobalDisableEntityFields(dbEncryptXmlConfig.getGlobalDisableEntityFields());
this.cryptProperties.setSqlFields(dbEncryptXmlConfig.getSqlFields());
this.cryptProperties.setSqlEncryptFields(dbEncryptXmlConfig.getSqlEncryptFields());
this.cryptProperties.setSqlDecryptFields(dbEncryptXmlConfig.getSqlDecryptFields());
this.cryptProperties.setEntityFields(dbEncryptXmlConfig.getEntityFields());
this.cryptProperties.setSqlSingleEncryptFields(dbEncryptXmlConfig.getSqlSingleEncryptFields());
this.cryptProperties.setSqlSingleDecryptFields(dbEncryptXmlConfig.getSqlSingleDecryptFields());
}
String sm4Salt = dbEncryptXmlConfig.getField("Sm4Salt");
if(StringUtils.isNotBlank(sm4Salt)){
this.cryptProperties.setSm4Salt(sm4Salt);
}
boolean userSm4KeyEnable = dbEncryptXmlConfig.getBooleanField("UserSm4KeyEnable");
this.cryptProperties.setUserSm4KeyEnable(userSm4KeyEnable);
String sm4key = dbEncryptXmlConfig.getField("Sm4key");
if(StringUtils.isNotBlank(sm4key)){
this.cryptProperties.setSm4key(sm4key);
}
String encoding = dbEncryptXmlConfig.getField("Encoding");
if(StringUtils.isNotBlank(encoding)){
this.cryptProperties.setEncoding(encoding);
}
dbEncryptXmlConfig.getGlobalEnableFields();
dbEncryptXmlConfig.getGlobalDisableMapFields();
dbEncryptXmlConfig.getGlobalDisableEntityFields();
dbEncryptXmlConfig.getSqlFields();
dbEncryptXmlConfig.getSqlEncryptFields();
dbEncryptXmlConfig.getSqlDecryptFields();
dbEncryptXmlConfig.getEntityFields();
dbEncryptXmlConfig.getSqlSingleEncryptFields();
dbEncryptXmlConfig.getSqlSingleDecryptFields();
//添加预置的字段
dbEncryptXmlConfig.addBaseConfigFields();
//根据注解获取加解密配置
dbEncryptXmlConfig.addAnnotationConfigFields();
this.cryptProperties.setGlobalEnableFields(dbEncryptXmlConfig.getGlobalEnableFields());
this.cryptProperties.setGlobalDisableMapFields(dbEncryptXmlConfig.getGlobalDisableMapFields());
this.cryptProperties.setGlobalDisableEntityFields(dbEncryptXmlConfig.getGlobalDisableEntityFields());
this.cryptProperties.setSqlFields(dbEncryptXmlConfig.getSqlFields());
this.cryptProperties.setSqlEncryptFields(dbEncryptXmlConfig.getSqlEncryptFields());
this.cryptProperties.setSqlDecryptFields(dbEncryptXmlConfig.getSqlDecryptFields());
this.cryptProperties.setEntityFields(dbEncryptXmlConfig.getEntityFields());
this.cryptProperties.setSqlSingleEncryptFields(dbEncryptXmlConfig.getSqlSingleEncryptFields());
this.cryptProperties.setSqlSingleDecryptFields(dbEncryptXmlConfig.getSqlSingleDecryptFields());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论