Commit b0ab32a0 by 陶光胜

取数平台调整

parent 22be29c7
package com.gic.cloud.data.hook.service; package com.gic.cloud.data.hook.service;
import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.dubbo.common.utils.StringUtils;
import com.gic.cloud.data.hook.api.entity.FlatQueryCondition;
import com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl;
import com.gic.data.shield.SdkEnv; import com.gic.data.shield.SdkEnv;
import com.gic.data.shield.decrypt.DataDecryptionClient; import com.gic.data.shield.decrypt.DataDecryptionClient;
import com.gic.data.shield.exception.DecryptException; import com.gic.data.shield.exception.DecryptException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
public class DecryptUtils { public class DecryptUtils {
private static DataDecryptionClient decryptionClient = null; private static DataDecryptionClient decryptionClient = null;
...@@ -50,5 +54,18 @@ public class DecryptUtils { ...@@ -50,5 +54,18 @@ public class DecryptUtils {
return stringBuffer.toString(); return stringBuffer.toString();
} }
public static boolean isName(String columnName, List<FlatQueryCondition> allFields){
if(StringUtils.isBlank(columnName)){
return false;
}
for(FlatQueryCondition condition : allFields){
if(condition.getFieldMark().equals(columnName)){
if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(condition.getFieldName())){
return true;
}
}
}
return false;
}
} }
...@@ -102,7 +102,7 @@ public class CsvResultSetHelper implements ResultSetHelper { ...@@ -102,7 +102,7 @@ public class CsvResultSetHelper implements ResultSetHelper {
// 数据处理 // 数据处理
if (doDesensi) { // 如果需要脱敏处理 if (doDesensi) { // 如果需要脱敏处理
if(allFields != null && isName(columnName)){ if(allFields != null && isName(columnName)){
result[i] = DecryptUtils.dataSecurityProcessUserName(resultSet.getString(columnName)); result[i] = DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(resultSet.getString(columnName)));
} else if(allFields == null && FreeQueryServiceImpl.FILETERS_USER_NAME.contains(columnName)) { } else if(allFields == null && FreeQueryServiceImpl.FILETERS_USER_NAME.contains(columnName)) {
result[i] = DecryptUtils.dataSecurityProcessUserName(resultSet.getString(columnName)); result[i] = DecryptUtils.dataSecurityProcessUserName(resultSet.getString(columnName));
} else { } else {
......
...@@ -609,15 +609,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -609,15 +609,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
//row.createCell(j).setCellValue(c); //row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1); String cName = rs.getMetaData().getColumnName(j+1);
List<String> cFilters = condition.getDecryptFilters(); List<String> cFilters = condition.getDecryptFilters();
if (task.getQueryDataType() == QueryDataType.FULL && (cFilters.contains(cName) || FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName))) { if (task.getQueryDataType() == QueryDataType.FULL && (cFilters.contains(cName) || DecryptUtils.isName(cName, condition.getConditions()))) {
String tmpResult = rs.getString(j + 1); String tmpResult = rs.getString(j + 1);
if (StringUtils.isNotBlank(tmpResult)) tmpResult = DecryptUtils.getInstance().decrypt(tmpResult); if (StringUtils.isNotBlank(tmpResult)) tmpResult = DecryptUtils.getInstance().decrypt(tmpResult);
row.createCell(j).setCellValue(tmpResult); row.createCell(j).setCellValue(tmpResult);
} else { } else {
if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName)){
String name = DecryptUtils.getInstance().decrypt(rs.getString(j + 1));
DecryptUtils.dataSecurityProcessUserName(name);
}
int cType = rs.getMetaData().getColumnType(j + 1); int cType = rs.getMetaData().getColumnType(j + 1);
switch (cType) { switch (cType) {
case Types.TIMESTAMP: case Types.TIMESTAMP:
...@@ -632,7 +628,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -632,7 +628,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
default: default:
if(cFilters.contains(cName)){ if(cFilters.contains(cName)){
row.createCell(j).setCellValue("******"); row.createCell(j).setCellValue("******");
}else { } else if(DecryptUtils.isName(cName, condition.getConditions())){
row.createCell(j).setCellValue(DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(rs.getString(j + 1))));
} else {
row.createCell(j).setCellValue(rs.getString(j + 1)); row.createCell(j).setCellValue(rs.getString(j + 1));
} }
break; break;
...@@ -802,7 +800,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -802,7 +800,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
//row.createCell(j).setCellValue(c); //row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1); String cName = rs.getMetaData().getColumnName(j+1);
List<String> cFilters = condition.getDecryptFilters(); List<String> cFilters = condition.getDecryptFilters();
if (task.getQueryDataType() == QueryDataType.FULL && cFilters.contains(cName)) { if (task.getQueryDataType() == QueryDataType.FULL && (cFilters.contains(cName) || DecryptUtils.isName(cName, condition.getConditions()))) {
String tmpResult = rs.getString(j + 1); String tmpResult = rs.getString(j + 1);
if (StringUtils.isNotBlank(tmpResult)) tmpResult = DecryptUtils.getInstance().decrypt(tmpResult); if (StringUtils.isNotBlank(tmpResult)) tmpResult = DecryptUtils.getInstance().decrypt(tmpResult);
row.createCell(j).setCellValue(tmpResult); row.createCell(j).setCellValue(tmpResult);
...@@ -821,6 +819,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -821,6 +819,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
default: default:
if(cFilters.contains(cName)){ if(cFilters.contains(cName)){
row.createCell(j).setCellValue("******"); row.createCell(j).setCellValue("******");
}else if(DecryptUtils.isName(cName, condition.getConditions())){
row.createCell(j).setCellValue(DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(rs.getString(j + 1))));
}else { }else {
row.createCell(j).setCellValue(rs.getString(j + 1)); row.createCell(j).setCellValue(rs.getString(j + 1));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment