提交 51e40f24 authored 作者:  狄熙卜's avatar 狄熙卜

添加方法,支持reload配置文件

上级 6769309d
...@@ -49,6 +49,63 @@ public class DbEncryptXmlConfig { ...@@ -49,6 +49,63 @@ public class DbEncryptXmlConfig {
private String interfaceSm2DecodeKey;//接口加解密时,sm2解密的私钥 private String interfaceSm2DecodeKey;//接口加解密时,sm2解密的私钥
private String interfaceSm2EncodeKey;//接口加解密时,sm2加密的公钥 private String interfaceSm2EncodeKey;//接口加解密时,sm2加密的公钥
private List<String> baseConfigOptions; private List<String> baseConfigOptions;
public void setBaseConfig(List<BaseConfig> baseConfig) {
this.baseConfig = baseConfig;
}
public void setGlobalEnableFields(List<String> globalEnableFields) {
this.globalEnableFields = globalEnableFields;
}
public void setGlobalDisableEntityFields(List<Map> globalDisableEntityFields) {
this.globalDisableEntityFields = globalDisableEntityFields;
}
public void setGlobalDisableMapFields(List<Map> globalDisableMapFields) {
this.globalDisableMapFields = globalDisableMapFields;
}
public void setSqlFileds(List<Map> sqlFileds) {
this.sqlFileds = sqlFileds;
}
public void setSqlEncryptFileds(List<Map> sqlEncryptFileds) {
this.sqlEncryptFileds = sqlEncryptFileds;
}
public void setSqlDecryptFileds(List<Map> sqlDecryptFileds) {
this.sqlDecryptFileds = sqlDecryptFileds;
}
public void setEntityFileds(List<Map> entityFileds) {
this.entityFileds = entityFileds;
}
public void setSqlSingleEncryptFileds(List<String> sqlSingleEncryptFileds) {
this.sqlSingleEncryptFileds = sqlSingleEncryptFileds;
}
public void setSqlSingleDecryptFileds(List<String> sqlSingleDecryptFileds) {
this.sqlSingleDecryptFileds = sqlSingleDecryptFileds;
}
public void setInterfaceEncryptList(List<String> interfaceEncryptList) {
this.interfaceEncryptList = interfaceEncryptList;
}
public void setInterfaceSm2DecodeKey(String interfaceSm2DecodeKey) {
this.interfaceSm2DecodeKey = interfaceSm2DecodeKey;
}
public void setInterfaceSm2EncodeKey(String interfaceSm2EncodeKey) {
this.interfaceSm2EncodeKey = interfaceSm2EncodeKey;
}
public void setBaseConfigOptions(List<String> baseConfigOptions) {
this.baseConfigOptions = baseConfigOptions;
}
public List<String> getBaseConfigOptions() { public List<String> getBaseConfigOptions() {
if(CollectionUtils.isNotEmpty(this.baseConfigOptions)){ if(CollectionUtils.isNotEmpty(this.baseConfigOptions)){
return this.baseConfigOptions; return this.baseConfigOptions;
...@@ -57,6 +114,22 @@ public class DbEncryptXmlConfig { ...@@ -57,6 +114,22 @@ public class DbEncryptXmlConfig {
return this.baseConfigOptions; return this.baseConfigOptions;
} }
} }
public void cleanConfig(){
setGlobalEnableFields(null);
setGlobalDisableEntityFields(null);
setGlobalDisableMapFields(null);
setSqlFileds(null);
setSqlEncryptFileds(null);
setSqlDecryptFileds(null);
setEntityFileds(null);
setSqlSingleEncryptFileds(null);
setSqlSingleDecryptFileds(null);
setInterfaceEncryptList(null);
setInterfaceSm2DecodeKey(null);
setInterfaceSm2EncodeKey(null);
setBaseConfigOptions(null);
}
public String getInterfaceSm2DecodeKey(){ public String getInterfaceSm2DecodeKey(){
if(!StringUtils.isBlank(this.interfaceSm2DecodeKey)){ if(!StringUtils.isBlank(this.interfaceSm2DecodeKey)){
return this.interfaceSm2DecodeKey; return this.interfaceSm2DecodeKey;
...@@ -344,7 +417,7 @@ public class DbEncryptXmlConfig { ...@@ -344,7 +417,7 @@ public class DbEncryptXmlConfig {
/** /**
* 从java文件中读取预置的加解密字段 * 从java文件中读取预置的加解密字段
*/ */
public void setBaseConfigFileds() { public void addBaseConfigFileds() {
List<String> baseConfigOptions = this.getBaseConfigOptions(); List<String> baseConfigOptions = this.getBaseConfigOptions();
if(CollectionUtils.isNotEmpty(baseConfig)){ if(CollectionUtils.isNotEmpty(baseConfig)){
for (BaseConfig config : baseConfig) { for (BaseConfig config : baseConfig) {
......
...@@ -33,6 +33,15 @@ public class EncryptInterceptor implements Interceptor { ...@@ -33,6 +33,15 @@ public class EncryptInterceptor implements Interceptor {
@Resource(name = "dbEncryptXmlConfig") @Resource(name = "dbEncryptXmlConfig")
private DbEncryptXmlConfig dbEncryptXmlConfig; private DbEncryptXmlConfig dbEncryptXmlConfig;
public static final ConcurrentHashMap<String, CryptAdapterMatadata> METHOD_ENCRYPT_MAP = new ConcurrentHashMap(); public static final ConcurrentHashMap<String, CryptAdapterMatadata> METHOD_ENCRYPT_MAP = new ConcurrentHashMap();
public CryptProperties getCryptProperties() {
return cryptProperties;
}
public void setCryptProperties(CryptProperties cryptProperties) {
this.cryptProperties = cryptProperties;
}
@Override @Override
public Object intercept(Invocation invocation) throws Throwable { public Object intercept(Invocation invocation) throws Throwable {
if (this.cryptEnable) { if (this.cryptEnable) {
...@@ -117,7 +126,7 @@ public class EncryptInterceptor implements Interceptor { ...@@ -117,7 +126,7 @@ public class EncryptInterceptor implements Interceptor {
dbEncryptXmlConfig.getSqlSingleEncryptFileds(); dbEncryptXmlConfig.getSqlSingleEncryptFileds();
dbEncryptXmlConfig.getSqlSingleDecryptFileds(); dbEncryptXmlConfig.getSqlSingleDecryptFileds();
//添加预置的字段 //添加预置的字段
dbEncryptXmlConfig.setBaseConfigFileds(); dbEncryptXmlConfig.addBaseConfigFileds();
this.cryptProperties.setGlobalEnableFields(dbEncryptXmlConfig.getGlobalEnableFields()); this.cryptProperties.setGlobalEnableFields(dbEncryptXmlConfig.getGlobalEnableFields());
this.cryptProperties.setGlobalDisableMapFields(dbEncryptXmlConfig.getGlobalDisableMapFields()); this.cryptProperties.setGlobalDisableMapFields(dbEncryptXmlConfig.getGlobalDisableMapFields());
this.cryptProperties.setGlobalDisableEntityFields(dbEncryptXmlConfig.getGlobalDisableEntityFields()); this.cryptProperties.setGlobalDisableEntityFields(dbEncryptXmlConfig.getGlobalDisableEntityFields());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论