Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-hook
gic-cloud
Commits
6c951e9a
Commit
6c951e9a
authored
Nov 02, 2022
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:下载加密解密过滤
parent
2f2163d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
7 deletions
+37
-7
DecryptUtils.java
...in/java/com/gic/cloud/data/hook/service/DecryptUtils.java
+29
-0
CsvResultSetHelper.java
...ic/cloud/data/hook/service/entity/CsvResultSetHelper.java
+3
-3
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+5
-4
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/DecryptUtils.java
View file @
6c951e9a
package
com
.
gic
.
cloud
.
data
.
hook
.
service
;
import
com.alibaba.dubbo.common.utils.StringUtils
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.cloud.data.hook.api.entity.FlatQueryCondition
;
import
com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl
;
import
com.gic.data.shield.SdkEnv
;
...
...
@@ -50,6 +52,14 @@ public class DecryptUtils {
}
}
public
static
String
decrypt
(
String
enterpriseId
,
String
encryptString
)
{
if
(
DecryptUtils
.
checkDecrypt
(
enterpriseId
)){
return
DecryptUtils
.
decrypt
(
encryptString
);
}
else
{
return
encryptString
;
}
}
public
static
String
dataSecurityProcessUserName
(
String
userName
){
if
(
StringUtils
.
isBlank
(
userName
)){
return
userName
;
...
...
@@ -73,4 +83,23 @@ public class DecryptUtils {
return
false
;
}
/**
* 是否需要解密
* @param enterpriseId
* @return
*/
public
static
boolean
checkDecrypt
(
String
enterpriseId
)
{
Config
appConfig
=
ConfigService
.
getAppConfig
();
String
entIds
=
appConfig
.
getProperty
(
"decrypt-enterprise"
,
"1"
);
if
(
entIds
.
equals
(
"-1"
))
{
return
false
;
}
else
if
(
entIds
.
equals
(
"1"
))
{
return
true
;
}
else
if
(
entIds
.
contains
(
enterpriseId
))
{
return
false
;
}
else
{
return
true
;
}
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/entity/CsvResultSetHelper.java
View file @
6c951e9a
...
...
@@ -169,14 +169,14 @@ public class CsvResultSetHelper implements ResultSetHelper {
// 数据处理
if
(
doDesensi
)
{
// 如果需要脱敏处理
if
(
allFields
!=
null
&&
isName
(
columnName
)){
result
.
add
(
DecryptUtils
.
dataSecurityProcessUserName
(
DecryptUtils
.
decrypt
(
resultSet
.
getString
(
columnName
))));
result
.
add
(
DecryptUtils
.
dataSecurityProcessUserName
(
DecryptUtils
.
decrypt
(
enterpriseId
,
resultSet
.
getString
(
columnName
))));
}
else
if
(
allFields
==
null
&&
FilterFieldUtils
.
FILETERS_USER_NAME
.
contains
(
columnName
))
{
result
.
add
(
DecryptUtils
.
dataSecurityProcessUserName
(
resultSet
.
getString
(
i
+
1
)));
}
else
{
result
.
add
(
"******"
);
if
(
needDecryptByEnt
&&
isPhoneNumber
(
columnName
)){
//导出数据中需要增加加密列,先解密再加密
String
value
=
DecryptUtils
.
getInstance
().
decrypt
(
resultSet
.
getString
(
i
+
1
));
String
value
=
DecryptUtils
.
getInstance
().
decrypt
(
enterpriseId
,
resultSet
.
getString
(
i
+
1
));
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
value
)){
byte
[]
bytes
=
rsa
.
encrypt
(
StrUtil
.
bytes
(
value
,
CharsetUtil
.
UTF_8
),
KeyType
.
PublicKey
);
String
encode
=
Base64
.
encode
(
bytes
);
...
...
@@ -190,7 +190,7 @@ public class CsvResultSetHelper implements ResultSetHelper {
String
tmpResult
=
resultSet
.
getString
(
i
+
1
);
if
(
tmpResult
!=
null
&&
tmpResult
.
length
()
>
0
)
{
//tmpResult = DecryptUtils.getInstance().decrypt(tmpResult);
tmpResult
=
DecryptUtils
.
getInstance
().
decrypt
(
tmpResult
);
tmpResult
=
DecryptUtils
.
getInstance
().
decrypt
(
enterpriseId
,
tmpResult
);
if
(
tmpResult
.
startsWith
(
"0"
)){
tmpResult
=
tmpResult
+
"\t"
;
}
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
6c951e9a
...
...
@@ -241,6 +241,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
log
.
debug
(
"getFlatQueryResult"
,
"自助指标查询来自 "
+
enterpriseIds
.
get
(
0
));
// 定义返回值
FlatQueryResult
result
=
new
FlatQueryResult
();
String
enterpriseId
=
enterpriseIds
.
get
(
0
);
// 定义查询语句
String
queryFull
=
this
.
buildFlatQuerySQL
(
true
,
// 查询用途
...
...
@@ -324,11 +325,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
if
(
queryDataType
==
QueryDataType
.
FULL
){
String
preResult
=
rs
.
getString
(
fieldColumnIndex
);
if
(
dataPermission
==
1
&&
FilterFieldUtils
.
FILTERS_PHONE_ONLY
.
contains
(
fieldName
)){
fieldResult
=
DecryptUtils
.
decrypt
(
preResult
);
fieldResult
=
DecryptUtils
.
decrypt
(
enterpriseId
,
preResult
);
}
else
if
(
dataPermission
==
2
&&
FilterFieldUtils
.
FILTERS_PHONE_AND_CARD
.
contains
(
fieldName
)){
fieldResult
=
DecryptUtils
.
decrypt
(
preResult
);
fieldResult
=
DecryptUtils
.
decrypt
(
enterpriseId
,
preResult
);
}
else
if
(
FilterFieldUtils
.
FILETERS_USER_NAME
.
contains
(
fieldName
)){
fieldResult
=
DecryptUtils
.
decrypt
(
preResult
);
fieldResult
=
DecryptUtils
.
decrypt
(
enterpriseId
,
preResult
);
}
else
fieldResult
=
rs
.
getObject
(
fieldColumnIndex
);
}
else
{
if
(
dataPermission
==
1
&&
FilterFieldUtils
.
FILTERS_PHONE_ONLY
.
contains
(
fieldName
)){
...
...
@@ -336,7 +337,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
else
if
(
dataPermission
==
2
&&
FilterFieldUtils
.
FILTERS_PHONE_AND_CARD
.
contains
(
fieldName
)){
fieldResult
=
"******"
;
}
else
if
(
FilterFieldUtils
.
FILETERS_USER_NAME
.
contains
(
fieldName
)){
fieldResult
=
DecryptUtils
.
dataSecurityProcessUserName
(
DecryptUtils
.
decrypt
(
rs
.
getObject
(
fieldColumnIndex
)+
""
));
fieldResult
=
DecryptUtils
.
dataSecurityProcessUserName
(
DecryptUtils
.
decrypt
(
enterpriseId
,
rs
.
getObject
(
fieldColumnIndex
)+
""
));
}
else
fieldResult
=
rs
.
getObject
(
fieldColumnIndex
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment