Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
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
gechengyang
nouiWithSpringMVC
Commits
fcef01f2
Commit
fcef01f2
authored
Jan 05, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整对资源浏览放越权前后端加密方式由md5改为sm3
parent
7080e084
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
ResourceAccessFilter.java
...rg/sss/presentation/noui/filter/ResourceAccessFilter.java
+21
-2
No files found.
src/main/java/org/sss/presentation/noui/filter/ResourceAccessFilter.java
View file @
fcef01f2
package
org
.
sss
.
presentation
.
noui
.
filter
;
package
org
.
sss
.
presentation
.
noui
.
filter
;
import
cfca.sadk.algorithm.sm2.SM3Digest
;
import
log.Log
;
import
log.Log
;
import
log.LogFactory
;
import
log.LogFactory
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
...
@@ -184,7 +185,8 @@ public class ResourceAccessFilter implements Filter {
...
@@ -184,7 +185,8 @@ public class ResourceAccessFilter implements Filter {
raw
.
append
(
rawuid
);
raw
.
append
(
rawuid
);
raw
.
append
(
SALT
);
raw
.
append
(
SALT
);
raw
.
append
(
res
);
raw
.
append
(
res
);
String
rawsec
=
StringUtil
.
encryptMD5
(
raw
.
toString
());
// String rawsec = StringUtil.encryptMD5(raw.toString());
String
rawsec
=
sm3
(
raw
.
toString
());
if
(!
rawsec
.
equals
(
sec
))
{
if
(!
rawsec
.
equals
(
sec
))
{
log
.
warn
(
"rawsec is:"
+
rawsec
+
",sec is:"
+
sec
);
log
.
warn
(
"rawsec is:"
+
rawsec
+
",sec is:"
+
sec
);
return
false
;
return
false
;
...
@@ -212,7 +214,8 @@ public class ResourceAccessFilter implements Filter {
...
@@ -212,7 +214,8 @@ public class ResourceAccessFilter implements Filter {
raw
.
append
(
rawuid
);
raw
.
append
(
rawuid
);
raw
.
append
(
SALT
);
raw
.
append
(
SALT
);
raw
.
append
(
res
);
raw
.
append
(
res
);
String
rawsec
=
StringUtil
.
encryptMD5
(
raw
.
toString
());
// String rawsec = StringUtil.encryptMD5(raw.toString());
String
rawsec
=
sm3
(
raw
.
toString
());
if
(!
rawsec
.
equals
(
sec
))
{
if
(!
rawsec
.
equals
(
sec
))
{
log
.
warn
(
"rawsec is:"
+
rawsec
+
",sec is:"
+
sec
);
log
.
warn
(
"rawsec is:"
+
rawsec
+
",sec is:"
+
sec
);
return
false
;
return
false
;
...
@@ -297,4 +300,20 @@ public class ResourceAccessFilter implements Filter {
...
@@ -297,4 +300,20 @@ public class ResourceAccessFilter implements Filter {
public
void
destroy
()
{
public
void
destroy
()
{
}
}
private
String
sm3
(
String
msg
)
{
byte
[]
z
=
msg
.
getBytes
(
StandardCharsets
.
UTF_8
);
SM3Digest
sm3
=
new
SM3Digest
();
sm3
.
update
(
z
,
0
,
z
.
length
);
byte
[]
hash
=
new
byte
[
32
];
sm3
.
doFinal
(
hash
,
0
);
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
hash
.
length
;
i
++)
{
if
((
hash
[
i
]
&
0xff
)
<
0x10
)
{
buf
.
append
(
"0"
);
}
buf
.
append
(
Long
.
toString
(
hash
[
i
]
&
0xff
,
16
));
}
return
buf
.
toString
();
}
}
}
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