提交 452db1e3 authored 作者:  狄熙卜's avatar 狄熙卜

修改错误拼写

上级 f5c2ec91
......@@ -28,17 +28,17 @@ public class CryptProperties {
//entity中全局加解密字段的例外(在例外中不加解密)
private List<Map> globalDisableMapFields;
//sql加解密字段
private List<Map> sqlFileds;
private List<Map> sqlFields;
//sql仅加密字段
private List<Map> sqlEncryptFileds;
private List<Map> sqlEncryptFields;
//sql仅解密字段
private List<Map> sqlDecryptFileds;
private List<Map> sqlDecryptFields;
//实体加解密字段
private List<Map> entityFileds;
private List<Map> entityFields;
//sql参数为单独的string,对参数加密(等价于注解)
private List<String> sqlSingleEncryptFileds;
private List<String> sqlSingleEncryptFields;
//sql返回值为单独的string,对返回值加密(等价于注解)
private List<String> sqlSingleDecryptFileds;
private List<String> sqlSingleDecryptFields;
public CryptProperties(boolean cryptEnable) {
this.cryptEnable = cryptEnable;
}
......@@ -47,20 +47,20 @@ public class CryptProperties {
this.cryptType = cryptType;
}
public List<String> getSqlSingleEncryptFileds() {
return sqlSingleEncryptFileds;
public List<String> getSqlSingleEncryptFields() {
return sqlSingleEncryptFields;
}
public void setSqlSingleEncryptFileds(List<String> sqlSingleEncryptFileds) {
this.sqlSingleEncryptFileds = sqlSingleEncryptFileds;
public void setSqlSingleEncryptFields(List<String> sqlSingleEncryptFields) {
this.sqlSingleEncryptFields = sqlSingleEncryptFields;
}
public List<String> getSqlSingleDecryptFileds() {
return sqlSingleDecryptFileds;
public List<String> getSqlSingleDecryptFields() {
return sqlSingleDecryptFields;
}
public void setSqlSingleDecryptFileds(List<String> sqlSingleDecryptFileds) {
this.sqlSingleDecryptFileds = sqlSingleDecryptFileds;
public void setSqlSingleDecryptFields(List<String> sqlSingleDecryptFields) {
this.sqlSingleDecryptFields = sqlSingleDecryptFields;
}
public boolean isUserSm4KeyEnable() {
......@@ -144,36 +144,36 @@ public class CryptProperties {
this.globalDisableMapFields = globalDisableMapFields;
}
public List<Map> getSqlFileds() {
return sqlFileds;
public List<Map> getSqlFields() {
return sqlFields;
}
public void setSqlFileds(List<Map> sqlFileds) {
this.sqlFileds = sqlFileds;
public void setSqlFields(List<Map> sqlFields) {
this.sqlFields = sqlFields;
}
public List<Map> getSqlEncryptFileds() {
return sqlEncryptFileds;
public List<Map> getSqlEncryptFields() {
return sqlEncryptFields;
}
public void setSqlEncryptFileds(List<Map> sqlEncryptFileds) {
this.sqlEncryptFileds = sqlEncryptFileds;
public void setSqlEncryptFields(List<Map> sqlEncryptFields) {
this.sqlEncryptFields = sqlEncryptFields;
}
public List<Map> getSqlDecryptFileds() {
return sqlDecryptFileds;
public List<Map> getSqlDecryptFields() {
return sqlDecryptFields;
}
public void setSqlDecryptFileds(List<Map> sqlDecryptFileds) {
this.sqlDecryptFileds = sqlDecryptFileds;
public void setSqlDecryptFields(List<Map> sqlDecryptFields) {
this.sqlDecryptFields = sqlDecryptFields;
}
public List<Map> getEntityFileds() {
return entityFileds;
public List<Map> getEntityFields() {
return entityFields;
}
public void setEntityFileds(List<Map> entityFileds) {
this.entityFileds = entityFileds;
public void setEntityFields(List<Map> entityFields) {
this.entityFields = entityFields;
}
public boolean isEncryptDecryptEntityField(String entityName, String fieldName) {
......@@ -183,8 +183,8 @@ public class CryptProperties {
if(isGlobalFields(null, entityName, fieldName)){
return true;
}else{
List<Map> entityFileds = getEntityFileds();
if(getEntityContainsField(entityFileds,entityName,fieldName)){
List<Map> entityFields = getEntityFields();
if(getEntityContainsField(entityFields,entityName,fieldName)){
return true;
}else{
return false;
......@@ -199,9 +199,9 @@ public class CryptProperties {
if(isGlobalFields(mapid,null, fieldName)){
return true;
}else{
List<Map> sqlFileds = getSqlFileds();
List<Map> sqlEncryptFileds = getSqlEncryptFileds();
if(getMapContainsField(sqlFileds,mapid,fieldName) || getMapContainsField(sqlEncryptFileds,mapid,fieldName)){
List<Map> sqlFields = getSqlFields();
List<Map> sqlEncryptFields = getSqlEncryptFields();
if(getMapContainsField(sqlFields,mapid,fieldName) || getMapContainsField(sqlEncryptFields,mapid,fieldName)){
return true;
}else{
return false;
......@@ -216,9 +216,9 @@ public class CryptProperties {
if(isGlobalFields(mapid,null, fieldName)){
return true;
}else{
List<Map> sqlFileds = getSqlFileds();
List<Map> sqlDecryptFileds = getSqlDecryptFileds();
if(getMapContainsField(sqlFileds,mapid,fieldName) || getMapContainsField(sqlDecryptFileds,mapid,fieldName)){
List<Map> sqlFields = getSqlFields();
List<Map> sqlDecryptFields = getSqlDecryptFields();
if(getMapContainsField(sqlFields,mapid,fieldName) || getMapContainsField(sqlDecryptFields,mapid,fieldName)){
return true;
}else{
return false;
......
......@@ -45,17 +45,17 @@ public class DbEncryptXmlConfig {
//entity中全局加解密字段的例外(在例外中不加解密)
private List<Map> globalDisableMapFields;
//sql加解密字段
private List<Map> sqlFileds;
private List<Map> sqlFields;
//sql仅加密字段
private List<Map> sqlEncryptFileds;
private List<Map> sqlEncryptFields;
//sql仅解密字段
private List<Map> sqlDecryptFileds;
private List<Map> sqlDecryptFields;
//实体加解密字段
private List<Map> entityFileds;
private List<Map> entityFields;
//sql参数为单独的string,对参数加密(等价于注解)
private List<String> sqlSingleEncryptFileds;
private List<String> sqlSingleEncryptFields;
//sql返回值为单独的string,对返回值加密(等价于注解)
private List<String> sqlSingleDecryptFileds;
private List<String> sqlSingleDecryptFields;
//接口加解密列表
private List<String> interfaceEncryptList;
private String interfaceSm2DecodeKey;//接口加解密时,sm2解密的私钥
......@@ -89,28 +89,28 @@ public class DbEncryptXmlConfig {
this.globalDisableMapFields = globalDisableMapFields;
}
public void setSqlFileds(List<Map> sqlFileds) {
this.sqlFileds = sqlFileds;
public void setSqlFields(List<Map> sqlFields) {
this.sqlFields = sqlFields;
}
public void setSqlEncryptFileds(List<Map> sqlEncryptFileds) {
this.sqlEncryptFileds = sqlEncryptFileds;
public void setSqlEncryptFields(List<Map> sqlEncryptFields) {
this.sqlEncryptFields = sqlEncryptFields;
}
public void setSqlDecryptFileds(List<Map> sqlDecryptFileds) {
this.sqlDecryptFileds = sqlDecryptFileds;
public void setSqlDecryptFields(List<Map> sqlDecryptFields) {
this.sqlDecryptFields = sqlDecryptFields;
}
public void setEntityFileds(List<Map> entityFileds) {
this.entityFileds = entityFileds;
public void setEntityFields(List<Map> entityFields) {
this.entityFields = entityFields;
}
public void setSqlSingleEncryptFileds(List<String> sqlSingleEncryptFileds) {
this.sqlSingleEncryptFileds = sqlSingleEncryptFileds;
public void setSqlSingleEncryptFields(List<String> sqlSingleEncryptFields) {
this.sqlSingleEncryptFields = sqlSingleEncryptFields;
}
public void setSqlSingleDecryptFileds(List<String> sqlSingleDecryptFileds) {
this.sqlSingleDecryptFileds = sqlSingleDecryptFileds;
public void setSqlSingleDecryptFields(List<String> sqlSingleDecryptFields) {
this.sqlSingleDecryptFields = sqlSingleDecryptFields;
}
public void setInterfaceEncryptList(List<String> interfaceEncryptList) {
......@@ -142,12 +142,12 @@ public class DbEncryptXmlConfig {
setGlobalEnableFields(null);
setGlobalDisableEntityFields(null);
setGlobalDisableMapFields(null);
setSqlFileds(null);
setSqlEncryptFileds(null);
setSqlDecryptFileds(null);
setEntityFileds(null);
setSqlSingleEncryptFileds(null);
setSqlSingleDecryptFileds(null);
setSqlFields(null);
setSqlEncryptFields(null);
setSqlDecryptFields(null);
setEntityFields(null);
setSqlSingleEncryptFields(null);
setSqlSingleDecryptFields(null);
setInterfaceEncryptList(null);
setInterfaceSm2DecodeKey(null);
setInterfaceSm2EncodeKey(null);
......@@ -177,25 +177,25 @@ public class DbEncryptXmlConfig {
return this.interfaceEncryptList;
}else {
List<String> list = new ArrayList<String>();
list = getFieldsInOneFiled("IneterfaceEcnrypt", "patternUrl");
list = getFieldsInOneField("IneterfaceEcnrypt", "patternUrl");
this.interfaceEncryptList = list;
return list;
}
}
public List<String> getSqlSingleEncryptFileds(){
if(CollectionUtils.isNotEmpty(this.sqlSingleEncryptFileds)){
return this.sqlSingleEncryptFileds;
public List<String> getSqlSingleEncryptFields(){
if(CollectionUtils.isNotEmpty(this.sqlSingleEncryptFields)){
return this.sqlSingleEncryptFields;
}else{
this.sqlSingleEncryptFileds = getArrFields("SqlSingleEncryptFileds");
return this.sqlSingleEncryptFileds;
this.sqlSingleEncryptFields = getArrFields("SqlSingleEncryptFields");
return this.sqlSingleEncryptFields;
}
}
public List<String> getSqlSingleDecryptFileds(){
if(CollectionUtils.isNotEmpty(this.sqlSingleDecryptFileds)){
return this.sqlSingleDecryptFileds;
public List<String> getSqlSingleDecryptFields(){
if(CollectionUtils.isNotEmpty(this.sqlSingleDecryptFields)){
return this.sqlSingleDecryptFields;
}else{
this.sqlSingleDecryptFileds = getArrFields("SqlSingleDecryptFileds");
return this.sqlSingleDecryptFileds;
this.sqlSingleDecryptFields = getArrFields("SqlSingleDecryptFields");
return this.sqlSingleDecryptFields;
}
}
......@@ -249,80 +249,80 @@ public class DbEncryptXmlConfig {
return globalDisableEntityFields;
}
public List<Map> getSqlFileds() {
if(sqlFileds == null){
List<String> getSqlFiledsList = getArrFields("SqlFileds");
if(CollectionUtils.isNotEmpty(getSqlFiledsList)){
sqlFileds = new ArrayList<Map>();
for (String s : getSqlFiledsList) {
public List<Map> getSqlFields() {
if(sqlFields == null){
List<String> getSqlFieldsList = getArrFields("SqlFields");
if(CollectionUtils.isNotEmpty(getSqlFieldsList)){
sqlFields = new ArrayList<Map>();
for (String s : getSqlFieldsList) {
int i = s.lastIndexOf(".");
String mapid = s.substring(0, i);
String fieldName = s.substring(i+1);
Map sqlFiledsMap = new HashMap<String,Object>();
sqlFiledsMap.put("mapid",mapid);
sqlFiledsMap.put("field",fieldName);
sqlFileds.add(sqlFiledsMap);
Map sqlFieldsMap = new HashMap<String,Object>();
sqlFieldsMap.put("mapid",mapid);
sqlFieldsMap.put("field",fieldName);
sqlFields.add(sqlFieldsMap);
}
}
}
return sqlFileds;
return sqlFields;
}
public List<Map> getSqlEncryptFileds() {
if(sqlEncryptFileds == null){
List<String> getSqlEncryptFiledsList = getArrFields("SqlEncryptFileds");
if(CollectionUtils.isNotEmpty(getSqlEncryptFiledsList)){
sqlEncryptFileds = new ArrayList<Map>();
for (String s : getSqlEncryptFiledsList) {
public List<Map> getSqlEncryptFields() {
if(sqlEncryptFields == null){
List<String> getSqlEncryptFieldsList = getArrFields("SqlEncryptFields");
if(CollectionUtils.isNotEmpty(getSqlEncryptFieldsList)){
sqlEncryptFields = new ArrayList<Map>();
for (String s : getSqlEncryptFieldsList) {
int i = s.lastIndexOf(".");
String mapid = s.substring(0, i);
String fieldName = s.substring(i+1);
Map sqlEncryptFiledsMap = new HashMap<String,Object>();
sqlEncryptFiledsMap.put("mapid",mapid);
sqlEncryptFiledsMap.put("field",fieldName);
sqlEncryptFileds.add(sqlEncryptFiledsMap);
Map sqlEncryptFieldsMap = new HashMap<String,Object>();
sqlEncryptFieldsMap.put("mapid",mapid);
sqlEncryptFieldsMap.put("field",fieldName);
sqlEncryptFields.add(sqlEncryptFieldsMap);
}
}
}
return sqlEncryptFileds;
return sqlEncryptFields;
}
public List<Map> getSqlDecryptFileds() {
if(sqlDecryptFileds == null){
List<String> getSqlDecryptFiledsList = getArrFields("SqlDecryptFileds");
if(CollectionUtils.isNotEmpty(getSqlDecryptFiledsList)){
sqlDecryptFileds = new ArrayList<Map>();
for (String s : getSqlDecryptFiledsList) {
public List<Map> getSqlDecryptFields() {
if(sqlDecryptFields == null){
List<String> getSqlDecryptFieldsList = getArrFields("SqlDecryptFields");
if(CollectionUtils.isNotEmpty(getSqlDecryptFieldsList)){
sqlDecryptFields = new ArrayList<Map>();
for (String s : getSqlDecryptFieldsList) {
int i = s.lastIndexOf(".");
String mapid = s.substring(0, i);
String fieldName = s.substring(i+1);
Map sqlDecryptFiledsMap = new HashMap<String,Object>();
sqlDecryptFiledsMap.put("mapid",mapid);
sqlDecryptFiledsMap.put("field",fieldName);
sqlDecryptFileds.add(sqlDecryptFiledsMap);
Map sqlDecryptFieldsMap = new HashMap<String,Object>();
sqlDecryptFieldsMap.put("mapid",mapid);
sqlDecryptFieldsMap.put("field",fieldName);
sqlDecryptFields.add(sqlDecryptFieldsMap);
}
}
}
return sqlDecryptFileds;
return sqlDecryptFields;
}
public List<Map> getEntityFileds() {
if(entityFileds == null){
List<String> getEntityFiledsList = getArrFields("EntityFileds");
if(CollectionUtils.isNotEmpty(getEntityFiledsList)){
entityFileds = new ArrayList<Map>();
for (String s : getEntityFiledsList) {
public List<Map> getEntityFields() {
if(entityFields == null){
List<String> getEntityFieldsList = getArrFields("EntityFields");
if(CollectionUtils.isNotEmpty(getEntityFieldsList)){
entityFields = new ArrayList<Map>();
for (String s : getEntityFieldsList) {
int i = s.lastIndexOf(".");
String mapid = s.substring(0, i);
String fieldName = s.substring(i+1);
Map entityFiledsMap = new HashMap<String,Object>();
entityFiledsMap.put("entity",mapid);
entityFiledsMap.put("field",fieldName);
entityFileds.add(entityFiledsMap);
Map entityFieldsMap = new HashMap<String,Object>();
entityFieldsMap.put("entity",mapid);
entityFieldsMap.put("field",fieldName);
entityFields.add(entityFieldsMap);
}
}
}
return entityFileds;
return entityFields;
}
......@@ -361,7 +361,7 @@ public class DbEncryptXmlConfig {
}
return result;
}
public List<String> getFieldsInOneFiled(String fieldName,String secondFieldName){
public List<String> getFieldsInOneField(String fieldName,String secondFieldName){
SAXReader sr = new SAXReader();
Document document = null;
List<String> result = new ArrayList<String>();
......@@ -451,7 +451,7 @@ public class DbEncryptXmlConfig {
/**
* 从java文件中读取预置的加解密字段
*/
public void addBaseConfigFileds() {
public void addBaseConfigFields() {
List<String> baseConfigOptions = this.getBaseConfigOptions();
if(CollectionUtils.isNotEmpty(baseConfig)){
for (BaseConfig config : baseConfig) {
......@@ -466,46 +466,46 @@ public class DbEncryptXmlConfig {
globalEnableFields.addAll(config.getGlobalEnableFields());
}
//预置的sql加解密字段(正向配置)
if(CollectionUtils.isNotEmpty(config.getSqlFileds())){
if(CollectionUtils.isEmpty(sqlFileds)){
sqlFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(config.getSqlFields())){
if(CollectionUtils.isEmpty(sqlFields)){
sqlFields = new ArrayList<Map>();
}
sqlFileds.addAll(config.getSqlFileds());
sqlFields.addAll(config.getSqlFields());
}
//预置的sql加密字段(正向配置)
if(CollectionUtils.isNotEmpty(config.getSqlEncryptFileds())){
if(CollectionUtils.isEmpty(sqlEncryptFileds)){
sqlEncryptFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(config.getSqlEncryptFields())){
if(CollectionUtils.isEmpty(sqlEncryptFields)){
sqlEncryptFields = new ArrayList<Map>();
}
sqlEncryptFileds.addAll(config.getSqlEncryptFileds());
sqlEncryptFields.addAll(config.getSqlEncryptFields());
}
//预置的sql解密字段(正向配置)
if(CollectionUtils.isNotEmpty(config.getSqlDecryptFileds())){
if(CollectionUtils.isEmpty(sqlDecryptFileds)){
sqlDecryptFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(config.getSqlDecryptFields())){
if(CollectionUtils.isEmpty(sqlDecryptFields)){
sqlDecryptFields = new ArrayList<Map>();
}
sqlDecryptFileds.addAll(config.getSqlDecryptFileds());
sqlDecryptFields.addAll(config.getSqlDecryptFields());
}
//预置的实体加解密字段(正向配置)
if(CollectionUtils.isNotEmpty(config.getEntityFileds())){
if(CollectionUtils.isEmpty(entityFileds)){
entityFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(config.getEntityFields())){
if(CollectionUtils.isEmpty(entityFields)){
entityFields = new ArrayList<Map>();
}
entityFileds.addAll(config.getEntityFileds());
entityFields.addAll(config.getEntityFields());
}
//单一string作为参数加密(正向配置)
if(CollectionUtils.isNotEmpty(config.getSqlSingleEncryptFileds())){
if(CollectionUtils.isEmpty(sqlSingleEncryptFileds)){
sqlSingleEncryptFileds = new ArrayList<String>();
if(CollectionUtils.isNotEmpty(config.getSqlSingleEncryptFields())){
if(CollectionUtils.isEmpty(sqlSingleEncryptFields)){
sqlSingleEncryptFields = new ArrayList<String>();
}
sqlSingleEncryptFileds.addAll(config.getSqlSingleEncryptFileds());
sqlSingleEncryptFields.addAll(config.getSqlSingleEncryptFields());
}
//单一string作为返回值解密(正向配置)
if(CollectionUtils.isNotEmpty(config.getSqlSingleDecryptFileds())){
if(CollectionUtils.isEmpty(sqlSingleDecryptFileds)){
sqlSingleDecryptFileds = new ArrayList<String>();
if(CollectionUtils.isNotEmpty(config.getSqlSingleDecryptFields())){
if(CollectionUtils.isEmpty(sqlSingleDecryptFields)){
sqlSingleDecryptFields = new ArrayList<String>();
}
sqlSingleDecryptFileds.addAll(config.getSqlSingleDecryptFileds());
sqlSingleDecryptFields.addAll(config.getSqlSingleDecryptFields());
}
//全局加密字段在sql中的反向配置(配置在其中的不进行加解密处理) 反向配置
//不需要做特殊处理逻辑,因为在判断是否为加解密字段时,判断顺序为:是否为全局加解密字段-》是否为全局非加解密字段-》是否为加解密字段,所以是否为加解密字段本身优先级高于全局配置,不需要在此处根据已有的是否为加解密字段配置调整是否为全局非加解密字段
......@@ -571,7 +571,7 @@ public class DbEncryptXmlConfig {
this.annoSqlPackage = annoSqlPackage;
}
public void addAnnotationConfigFileds() {
public void addAnnotationConfigFields() {
long begin = System.currentTimeMillis();
//获取注解加解密总开关
if(!isAnnoEnable()){
......@@ -589,7 +589,7 @@ public class DbEncryptXmlConfig {
.setUrls(ClasspathHelper.forPackage(annoEntityPackage))
.addScanners(new FieldAnnotationsScanner()));
Set<Field> encryptAnnoFields = ref.getFieldsAnnotatedWith(Encrypt.class);
List<Map> annoEntityFileds = new ArrayList<Map>();
List<Map> annoEntityFields = new ArrayList<Map>();
if (CollectionUtils.isNotEmpty(encryptAnnoFields)) {
for (Field field : encryptAnnoFields) {
Encrypt annotation = field.getAnnotation(Encrypt.class);
......@@ -604,14 +604,14 @@ public class DbEncryptXmlConfig {
Map map = new HashMap<String, Object>();
map.put("entity", className);
map.put("field", field.getName());
annoEntityFileds.add(map);
annoEntityFields.add(map);
}
}
if (CollectionUtils.isNotEmpty(annoEntityFileds)) {
if (CollectionUtils.isEmpty(entityFileds)) {
entityFileds = new ArrayList<Map>();
if (CollectionUtils.isNotEmpty(annoEntityFields)) {
if (CollectionUtils.isEmpty(entityFields)) {
entityFields = new ArrayList<Map>();
}
entityFileds.addAll(annoEntityFileds);
entityFields.addAll(annoEntityFields);
}
}
......@@ -632,21 +632,21 @@ public class DbEncryptXmlConfig {
return;
}
//sql加解密字段
List<Map> annoSqlFileds = new ArrayList<Map>();
List<Map> annoSqlFields = new ArrayList<Map>();
//sql仅加密字段
List<Map> annoSqlEncryptFileds = new ArrayList<Map>();
List<Map> annoSqlEncryptFields = new ArrayList<Map>();
//sql仅解密字段
List<Map> annoSqlDecryptFileds = new ArrayList<Map>();
List<Map> annoSqlDecryptFields = new ArrayList<Map>();
//sql参数为单独的string,对参数加密(等价于注解)
List<String> annoSqlSingleEncryptFileds = new ArrayList<String>();
List<String> annoSqlSingleEncryptFields = new ArrayList<String>();
//sql返回值为单独的string,对返回值加密(等价于注解)
List<String> annoSqlSingleDecryptFileds = new ArrayList<String>();
List<String> annoSqlSingleDecryptFields = new ArrayList<String>();
//处理方法上的Encrypt注解
if(CollectionUtils.isNotEmpty(enctyptMethods)){
for (Method method : enctyptMethods) {
Encrypt annotation = method.getAnnotation(Encrypt.class);
getFieldsFromAnno(annoSqlFileds,annoSqlEncryptFileds,annoSqlDecryptFileds,annoSqlSingleEncryptFileds,
annoSqlSingleDecryptFileds,method,annotation);
getFieldsFromAnno(annoSqlFields,annoSqlEncryptFields,annoSqlDecryptFields,annoSqlSingleEncryptFields,
annoSqlSingleDecryptFields,method,annotation);
}
}
//处理方法上的Encrypts注解
......@@ -656,46 +656,46 @@ public class DbEncryptXmlConfig {
Encrypt[] value = annotation.value();
if(value != null && value.length > 0){
for (Encrypt encrypt : value) {
getFieldsFromAnno(annoSqlFileds,annoSqlEncryptFileds,annoSqlDecryptFileds,annoSqlSingleEncryptFileds,
annoSqlSingleDecryptFileds,method,encrypt);
getFieldsFromAnno(annoSqlFields,annoSqlEncryptFields,annoSqlDecryptFields,annoSqlSingleEncryptFields,
annoSqlSingleDecryptFields,method,encrypt);
}
}
}
}
//预置的sql加解密字段(正向配置)
if(CollectionUtils.isNotEmpty(annoSqlFileds)){
if(CollectionUtils.isEmpty(sqlFileds)){
sqlFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(annoSqlFields)){
if(CollectionUtils.isEmpty(sqlFields)){
sqlFields = new ArrayList<Map>();
}
sqlFileds.addAll(annoSqlFileds);
sqlFields.addAll(annoSqlFields);
}
//预置的sql加密字段(正向配置)
if(CollectionUtils.isNotEmpty(annoSqlEncryptFileds)){
if(CollectionUtils.isEmpty(sqlEncryptFileds)){
sqlEncryptFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(annoSqlEncryptFields)){
if(CollectionUtils.isEmpty(sqlEncryptFields)){
sqlEncryptFields = new ArrayList<Map>();
}
sqlEncryptFileds.addAll(annoSqlEncryptFileds);
sqlEncryptFields.addAll(annoSqlEncryptFields);
}
//预置的sql解密字段(正向配置)
if(CollectionUtils.isNotEmpty(annoSqlDecryptFileds)){
if(CollectionUtils.isEmpty(sqlDecryptFileds)){
sqlDecryptFileds = new ArrayList<Map>();
if(CollectionUtils.isNotEmpty(annoSqlDecryptFields)){
if(CollectionUtils.isEmpty(sqlDecryptFields)){
sqlDecryptFields = new ArrayList<Map>();
}
sqlDecryptFileds.addAll(annoSqlDecryptFileds);
sqlDecryptFields.addAll(annoSqlDecryptFields);
}
//单一string作为参数加密(正向配置)
if(CollectionUtils.isNotEmpty(annoSqlSingleEncryptFileds)){
if(CollectionUtils.isEmpty(sqlSingleEncryptFileds)){
sqlSingleEncryptFileds = new ArrayList<String>();
if(CollectionUtils.isNotEmpty(annoSqlSingleEncryptFields)){
if(CollectionUtils.isEmpty(sqlSingleEncryptFields)){
sqlSingleEncryptFields = new ArrayList<String>();
}
sqlSingleEncryptFileds.addAll(annoSqlSingleEncryptFileds);
sqlSingleEncryptFields.addAll(annoSqlSingleEncryptFields);
}
//单一string作为返回值解密(正向配置)
if(CollectionUtils.isNotEmpty(annoSqlSingleDecryptFileds)){
if(CollectionUtils.isEmpty(sqlSingleDecryptFileds)){
sqlSingleDecryptFileds = new ArrayList<String>();
if(CollectionUtils.isNotEmpty(annoSqlSingleDecryptFields)){
if(CollectionUtils.isEmpty(sqlSingleDecryptFields)){
sqlSingleDecryptFields = new ArrayList<String>();
}
sqlSingleDecryptFileds.addAll(annoSqlSingleDecryptFileds);
sqlSingleDecryptFields.addAll(annoSqlSingleDecryptFields);
}
long end = System.currentTimeMillis();
LOGGER.error("anno scan used time:"+(end-begin));
......@@ -704,63 +704,63 @@ public class DbEncryptXmlConfig {
/**
* 同时提供方法和注解参数,便于代码的复用
* @param annoSqlFileds
* @param annoSqlEncryptFileds
* @param annoSqlDecryptFileds
* @param annoSqlSingleEncryptFileds
* @param annoSqlSingleDecryptFileds
* @param annoSqlFields
* @param annoSqlEncryptFields
* @param annoSqlDecryptFields
* @param annoSqlSingleEncryptFields
* @param annoSqlSingleDecryptFields
* @param method
* @param annotation
*/
private void getFieldsFromAnno(List<Map> annoSqlFileds,List<Map> annoSqlEncryptFileds,List<Map> annoSqlDecryptFileds,
List<String> annoSqlSingleEncryptFileds,List<String> annoSqlSingleDecryptFileds,Method method,Encrypt annotation){
private void getFieldsFromAnno(List<Map> annoSqlFields,List<Map> annoSqlEncryptFields,List<Map> annoSqlDecryptFields,
List<String> annoSqlSingleEncryptFields,List<String> annoSqlSingleDecryptFields,Method method,Encrypt annotation){
if(annotation == null || !annoGroupNames.contains(annotation.group())){
return;
}
String className = method.getDeclaringClass().getName();
String fileds = annotation.fileds();//注解的加解密属性处理
if(StringUtils.isNotBlank(fileds)){
String[] split = fileds.split(",");
String Fields = annotation.fields();//注解的加解密属性处理
if(StringUtils.isNotBlank(Fields)){
String[] split = Fields.split(",");
if(split != null && split.length > 0){
for (String s : split) {
Map sqlFiledMap = new HashMap<String,Object>();
sqlFiledMap.put("mapid",className+"."+method.getName());
sqlFiledMap.put("field",s);
annoSqlFileds.add(sqlFiledMap);
Map sqlFieldMap = new HashMap<String,Object>();
sqlFieldMap.put("mapid",className+"."+method.getName());
sqlFieldMap.put("field",s);
annoSqlFields.add(sqlFieldMap);
}
}
}
String encodeFileds = annotation.encodeFileds();//注解的加密属性处理
if(StringUtils.isNotBlank(encodeFileds)){
String[] split = encodeFileds.split(",");
String encodeFields = annotation.encodeFields();//注解的加密属性处理
if(StringUtils.isNotBlank(encodeFields)){
String[] split = encodeFields.split(",");
if(split != null && split.length > 0){
for (String s : split) {
Map sqlEncryptFiledMap = new HashMap<String, Object>();
sqlEncryptFiledMap.put("mapid", className+"."+method.getName());
sqlEncryptFiledMap.put("field", s);
annoSqlEncryptFileds.add(sqlEncryptFiledMap);
Map sqlEncryptFieldMap = new HashMap<String, Object>();
sqlEncryptFieldMap.put("mapid", className+"."+method.getName());
sqlEncryptFieldMap.put("field", s);
annoSqlEncryptFields.add(sqlEncryptFieldMap);
}
}
}
String decodeFileds = annotation.decodeFileds();//注解的解密属性处理
if(StringUtils.isNotBlank(decodeFileds)){
String[] split = decodeFileds.split(",");
String decodeFields = annotation.decodeFields();//注解的解密属性处理
if(StringUtils.isNotBlank(decodeFields)){
String[] split = decodeFields.split(",");
if(split != null && split.length > 0) {
for (String s : split) {
Map sqlDecryptFiledMap = new HashMap<String, Object>();
sqlDecryptFiledMap.put("mapid", className+"."+method.getName());
sqlDecryptFiledMap.put("field", s);
annoSqlDecryptFileds.add(sqlDecryptFiledMap);
Map sqlDecryptFieldMap = new HashMap<String, Object>();
sqlDecryptFieldMap.put("mapid", className+"."+method.getName());
sqlDecryptFieldMap.put("field", s);
annoSqlDecryptFields.add(sqlDecryptFieldMap);
}
}
}
boolean singleEncrypt = annotation.singleEncryptFileds();//注解的仅一个参数加密属性
boolean singleEncrypt = annotation.singleEncryptFields();//注解的仅一个参数加密属性
if(singleEncrypt){
annoSqlSingleEncryptFileds.add(className+"."+method.getName());
annoSqlSingleEncryptFields.add(className+"."+method.getName());
}
boolean singleDecrypt = annotation.singleDecryptFileds();//注解的仅有要给返回值解密属性
boolean singleDecrypt = annotation.singleDecryptFields();//注解的仅有要给返回值解密属性
if(singleDecrypt){
annoSqlSingleDecryptFileds.add(className+"."+method.getName());
annoSqlSingleDecryptFields.add(className+"."+method.getName());
}
}
}
......@@ -122,10 +122,10 @@ public class EncryptAdapterBuilder {
}
}
}
if(CollectionUtils.isNotEmpty(cryptProperties.getSqlSingleEncryptFileds())){
for (String filed : cryptProperties.getSqlSingleEncryptFileds()) {
if(CollectionUtils.isNotEmpty(cryptProperties.getSqlSingleEncryptFields())){
for (String field : cryptProperties.getSqlSingleEncryptFields()) {
String name = method.getDeclaringClass().getName()+"."+method.getName();
if(StringUtils.isNotBlank(name) && name.endsWith(filed)){
if(StringUtils.isNotBlank(name) && name.endsWith(field)){
return true;
}
}
......@@ -166,10 +166,10 @@ public class EncryptAdapterBuilder {
if(annotation != null){
return true;
}
if(CollectionUtils.isNotEmpty(cryptProperties.getSqlSingleDecryptFileds())){
for (String filed : cryptProperties.getSqlSingleDecryptFileds()) {
if(CollectionUtils.isNotEmpty(cryptProperties.getSqlSingleDecryptFields())){
for (String field : cryptProperties.getSqlSingleDecryptFields()) {
String name = method.getDeclaringClass().getName()+"."+method.getName();
if(StringUtils.isNotBlank(name) && name.endsWith(filed)){
if(StringUtils.isNotBlank(name) && name.endsWith(field)){
return true;
}
}
......
......@@ -126,24 +126,24 @@ public class EncryptInterceptor implements Interceptor {
dbEncryptXmlConfig.getGlobalEnableFields();
dbEncryptXmlConfig.getGlobalDisableMapFields();
dbEncryptXmlConfig.getGlobalDisableEntityFields();
dbEncryptXmlConfig.getSqlFileds();
dbEncryptXmlConfig.getSqlEncryptFileds();
dbEncryptXmlConfig.getSqlDecryptFileds();
dbEncryptXmlConfig.getEntityFileds();
dbEncryptXmlConfig.getSqlSingleEncryptFileds();
dbEncryptXmlConfig.getSqlSingleDecryptFileds();
dbEncryptXmlConfig.getSqlFields();
dbEncryptXmlConfig.getSqlEncryptFields();
dbEncryptXmlConfig.getSqlDecryptFields();
dbEncryptXmlConfig.getEntityFields();
dbEncryptXmlConfig.getSqlSingleEncryptFields();
dbEncryptXmlConfig.getSqlSingleDecryptFields();
//添加预置的字段
dbEncryptXmlConfig.addBaseConfigFileds();
dbEncryptXmlConfig.addBaseConfigFields();
//根据注解获取加解密配置
dbEncryptXmlConfig.addAnnotationConfigFileds();
dbEncryptXmlConfig.addAnnotationConfigFields();
this.cryptProperties.setGlobalEnableFields(dbEncryptXmlConfig.getGlobalEnableFields());
this.cryptProperties.setGlobalDisableMapFields(dbEncryptXmlConfig.getGlobalDisableMapFields());
this.cryptProperties.setGlobalDisableEntityFields(dbEncryptXmlConfig.getGlobalDisableEntityFields());
this.cryptProperties.setSqlFileds(dbEncryptXmlConfig.getSqlFileds());
this.cryptProperties.setSqlEncryptFileds(dbEncryptXmlConfig.getSqlEncryptFileds());
this.cryptProperties.setSqlDecryptFileds(dbEncryptXmlConfig.getSqlDecryptFileds());
this.cryptProperties.setEntityFileds(dbEncryptXmlConfig.getEntityFileds());
this.cryptProperties.setSqlSingleEncryptFileds(dbEncryptXmlConfig.getSqlSingleEncryptFileds());
this.cryptProperties.setSqlSingleDecryptFileds(dbEncryptXmlConfig.getSqlSingleDecryptFileds());
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());
}
}
......@@ -108,8 +108,8 @@ public class CommonEncryptAdapter implements EncryptAdapter {
if (MapUtils.isEmpty(cryptFieldMap)) {
return param;
}
Map<String, Crypt> needCryptFiledMap = this.getNeedCryptFiledMap(cryptFieldMap, example);
if (MapUtils.isEmpty(needCryptFiledMap)) {
Map<String, Crypt> needCryptFieldMap = this.getNeedCryptFieldMap(cryptFieldMap, example);
if (MapUtils.isEmpty(needCryptFieldMap)) {
return param;
}*/
List<String> cryptFieldList = this.getCryptFieldList(fields,entityclass);
......
......@@ -11,13 +11,13 @@ public @interface Encrypt {
//分组 分组之后才能进行加解密
String group();
//方法上使用的字段 对sql中的字段进行加解密
String fileds() default "";
String fields() default "";
//方法上使用的字段 对sql中入参的字段进行加密
String encodeFileds() default "";
String encodeFields() default "";
//方法上使用的字段 对sql中返回值的字段进行解密
String decodeFileds() default "";
String decodeFields() default "";
//方法上使用的字段 在只有一个参数时加密
boolean singleEncryptFileds() default false;
boolean singleEncryptFields() default false;
//方法上使用的字段 在只有一个参数时解密
boolean singleDecryptFileds() default false;
boolean singleDecryptFields() default false;
}
......@@ -11,17 +11,17 @@ public interface BaseConfig {
//全局加密字段 正向
List<String> getGlobalEnableFields();
//sql加解密字段 正向
List<Map> getSqlFileds();
List<Map> getSqlFields();
//sql加密字段 正向
List<Map> getSqlEncryptFileds();
List<Map> getSqlEncryptFields();
//sql解密字段 正向
List<Map> getSqlDecryptFileds();
List<Map> getSqlDecryptFields();
//实体加解密字段 正向
List<Map> getEntityFileds();
List<Map> getEntityFields();
//单一string作为参数加密 正向
List<String> getSqlSingleEncryptFileds();
List<String> getSqlSingleEncryptFields();
//单一string作为返回值解密 正向
List<String> getSqlSingleDecryptFileds();
List<String> getSqlSingleDecryptFields();
//全局加密字段在sql中的反向配置(配置在其中的不进行加解密处理) 反向
List<Map> getGlobalDisableMapFields();
......
......@@ -19,22 +19,22 @@ public class QlrConfig implements BaseConfig {
}
@Override
public List<Map> getSqlFileds() {
public List<Map> getSqlFields() {
return null;
}
@Override
public List<Map> getSqlEncryptFileds() {
public List<Map> getSqlEncryptFields() {
return null;
}
@Override
public List<Map> getSqlDecryptFileds() {
public List<Map> getSqlDecryptFields() {
return null;
}
@Override
public List<Map> getEntityFileds() {
public List<Map> getEntityFields() {
List<Map> result = new ArrayList<Map>();
Map map = new HashMap<String,Object>();
map.put("entity","cn.gtmap.bdcdj.core.entity.BdcZs");
......@@ -44,12 +44,12 @@ public class QlrConfig implements BaseConfig {
}
@Override
public List<String> getSqlSingleEncryptFileds() {
public List<String> getSqlSingleEncryptFields() {
return null;
}
@Override
public List<String> getSqlSingleDecryptFileds() {
public List<String> getSqlSingleDecryptFields() {
return null;
}
......
......@@ -16,32 +16,32 @@ public class QlrlxdhConfig implements BaseConfig{
}
@Override
public List<Map> getSqlFileds() {
public List<Map> getSqlFields() {
return null;
}
@Override
public List<Map> getSqlEncryptFileds() {
public List<Map> getSqlEncryptFields() {
return null;
}
@Override
public List<Map> getSqlDecryptFileds() {
public List<Map> getSqlDecryptFields() {
return null;
}
@Override
public List<Map> getEntityFileds() {
public List<Map> getEntityFields() {
return null;
}
@Override
public List<String> getSqlSingleEncryptFileds() {
public List<String> getSqlSingleEncryptFields() {
return null;
}
@Override
public List<String> getSqlSingleDecryptFileds() {
public List<String> getSqlSingleDecryptFields() {
return null;
}
......
......@@ -16,32 +16,32 @@ public class ZlConfig implements BaseConfig{
}
@Override
public List<Map> getSqlFileds() {
public List<Map> getSqlFields() {
return null;
}
@Override
public List<Map> getSqlEncryptFileds() {
public List<Map> getSqlEncryptFields() {
return null;
}
@Override
public List<Map> getSqlDecryptFileds() {
public List<Map> getSqlDecryptFields() {
return null;
}
@Override
public List<Map> getEntityFileds() {
public List<Map> getEntityFields() {
return null;
}
@Override
public List<String> getSqlSingleEncryptFileds() {
public List<String> getSqlSingleEncryptFields() {
return null;
}
@Override
public List<String> getSqlSingleDecryptFileds() {
public List<String> getSqlSingleDecryptFields() {
return null;
}
......
......@@ -31,11 +31,11 @@ public class BeanCryptHandler implements CryptHandler<Object> {
LOGGER.error("BeanCryptHandler.encrypt.getresult"+var11.getMessage());
}
List<Field> filedList = this.getEncryptDecryptFields(result.getClass(),cryptProperties);
if (CollectionUtils.isEmpty(filedList)) {
List<Field> fieldList = this.getEncryptDecryptFields(result.getClass(),cryptProperties);
if (CollectionUtils.isEmpty(fieldList)) {
return bean;
} else {
for (Field field : filedList) {
for (Field field : fieldList) {
try {
field.setAccessible(true);
Object o = field.get(result);
......@@ -60,9 +60,9 @@ public class BeanCryptHandler implements CryptHandler<Object> {
if (param == null) {
return null;
} else {
List<Field> filedList = this.getEncryptDecryptFields(param.getClass(),cryptProperties);
if(CollectionUtils.isNotEmpty(filedList)){
for (Field field : filedList) {
List<Field> fieldList = this.getEncryptDecryptFields(param.getClass(),cryptProperties);
if(CollectionUtils.isNotEmpty(fieldList)){
for (Field field : fieldList) {
try {
field.setAccessible(true);
Object o = field.get(param);
......@@ -83,9 +83,9 @@ public class BeanCryptHandler implements CryptHandler<Object> {
//对bean来说,加密字段和解密字段应该一致
private List<Field> getEncryptDecryptFields(Class clazz, CryptProperties cryptProperties) {
List<Field> filedList = new ArrayList();
List<Field> fieldList = new ArrayList();
if (clazz == null) {
return filedList;
return fieldList;
} else {
Field[] fields = clazz.getDeclaredFields();
String fieldName = "";
......@@ -94,11 +94,11 @@ public class BeanCryptHandler implements CryptHandler<Object> {
for (Field field : fields) {
fieldName = field.getName();
if(cryptProperties.isEncryptDecryptEntityField(className,fieldName)){
filedList.add(field);
fieldList.add(field);
}
}
}
return filedList;
return fieldList;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论