Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schbrain-parent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
schbrain-parent
Commits
4e9e91b5
Commit
4e9e91b5
authored
Sep 05, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Release 3.0.5.4
parent
8ce24d32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
20 deletions
+8
-20
commons/web-common/src/main/java/com/schbrain/common/web/support/signature/AbstractSignatureValidationInterceptor.java
...ort/signature/AbstractSignatureValidationInterceptor.java
+7
-19
pom.xml
pom.xml
+1
-1
No files found.
commons/web-common/src/main/java/com/schbrain/common/web/support/signature/AbstractSignatureValidationInterceptor.java
View file @
4e9e91b5
...
...
@@ -2,7 +2,6 @@ package com.schbrain.common.web.support.signature;
import
cn.hutool.crypto.digest.DigestUtil
;
import
com.schbrain.common.util.StreamUtils
;
import
com.schbrain.common.web.servlet.ContentCachingRequest
;
import
com.schbrain.common.web.support.BaseHandlerInterceptor
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.method.HandlerMethod
;
...
...
@@ -15,7 +14,6 @@ import java.util.Objects;
import
static
cn
.
hutool
.
core
.
text
.
StrPool
.
UNDERLINE
;
import
static
com
.
schbrain
.
common
.
web
.
utils
.
RequestContentCachingUtils
.
getRequestBody
;
import
static
org
.
springframework
.
web
.
util
.
WebUtils
.
getNativeRequest
;
public
abstract
class
AbstractSignatureValidationInterceptor
<
T
extends
SignatureContext
>
extends
BaseHandlerInterceptor
{
...
...
@@ -26,12 +24,10 @@ public abstract class AbstractSignatureValidationInterceptor<T extends Signature
@Override
protected
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
HandlerMethod
handler
)
{
ContentCachingRequest
wrappedRequest
=
getWrappedRequest
(
request
);
String
appKey
=
wrappedRequest
.
getHeader
(
SCH_APP_KEY
);
String
timestamp
=
wrappedRequest
.
getHeader
(
SCH_TIMESTAMP
);
String
signature
=
wrappedRequest
.
getHeader
(
SCH_SIGNATURE
);
String
expireTime
=
wrappedRequest
.
getHeader
(
SCH_EXPIRE_TIME
);
String
appKey
=
request
.
getHeader
(
SCH_APP_KEY
);
String
timestamp
=
request
.
getHeader
(
SCH_TIMESTAMP
);
String
signature
=
request
.
getHeader
(
SCH_SIGNATURE
);
String
expireTime
=
request
.
getHeader
(
SCH_EXPIRE_TIME
);
// 空校验
if
(
StringUtils
.
isAnyBlank
(
appKey
,
timestamp
,
signature
,
expireTime
))
{
...
...
@@ -49,9 +45,9 @@ public abstract class AbstractSignatureValidationInterceptor<T extends Signature
throw
new
SignatureValidationException
(
"appSecret不存在!"
);
}
String
requestUri
=
wrappedR
equest
.
getRequestURI
();
String
queryString
=
wrappedR
equest
.
getQueryString
();
String
requestBody
=
getRequestBody
(
wrappedR
equest
);
String
requestUri
=
r
equest
.
getRequestURI
();
String
queryString
=
r
equest
.
getQueryString
();
String
requestBody
=
getRequestBody
(
r
equest
);
// 校验签名
String
calculatedSignature
=
signParams
(
requestUri
,
queryString
,
requestBody
,
timestamp
,
appKey
,
context
.
getAppSecret
());
...
...
@@ -76,12 +72,4 @@ public abstract class AbstractSignatureValidationInterceptor<T extends Signature
protected
abstract
T
getSignatureContext
(
String
appKey
);
private
ContentCachingRequest
getWrappedRequest
(
HttpServletRequest
request
)
{
ContentCachingRequest
wrapper
=
getNativeRequest
(
request
,
ContentCachingRequest
.
class
);
if
(
wrapper
==
null
)
{
throw
new
SignatureValidationException
(
"请求异常"
);
}
return
wrapper
;
}
}
pom.xml
View file @
4e9e91b5
...
...
@@ -43,7 +43,7 @@
</distributionManagement>
<properties>
<revision>
3.0.5.
3
</revision>
<revision>
3.0.5.
4
</revision>
<java.version>
11
</java.version>
<!-- 2th part versions -->
<schbrain-apollo.version>
${revision}
</schbrain-apollo.version>
...
...
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