Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
e269851f
Commit
e269851f
authored
Apr 21, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加api签名日志
parent
42c35038
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/signature/SignUtils.java
+3
-0
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/signature/SignatureChecker.java
+9
-1
im-sdk/pom.xml
+1
-1
No files found.
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/signature/SignUtils.java
View file @
e269851f
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
signature
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
signature
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
...
@@ -13,6 +15,7 @@ import cn.hutool.core.lang.Assert;
...
@@ -13,6 +15,7 @@ import cn.hutool.core.lang.Assert;
* @Date 2022年04月14日 11:32o
* @Date 2022年04月14日 11:32o
* @Version 1.0
* @Version 1.0
*/
*/
@Slf4j
public
class
SignUtils
{
public
class
SignUtils
{
public
static
final
String
IM_PREFIX
=
"x-im-"
;
public
static
final
String
IM_PREFIX
=
"x-im-"
;
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/signature/SignatureChecker.java
View file @
e269851f
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
signature
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
signature
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
...
@@ -20,6 +22,7 @@ import com.google.common.collect.Maps;
...
@@ -20,6 +22,7 @@ import com.google.common.collect.Maps;
* @Date 2022年04月14日 17:31
* @Date 2022年04月14日 17:31
* @Version 1.0
* @Version 1.0
*/
*/
@Slf4j
public
class
SignatureChecker
{
public
class
SignatureChecker
{
/**
/**
...
@@ -46,7 +49,12 @@ public class SignatureChecker {
...
@@ -46,7 +49,12 @@ public class SignatureChecker {
String
resourcePath
=
request
.
getRequestURI
();
String
resourcePath
=
request
.
getRequestURI
();
// request methos
// request methos
String
requestMethod
=
request
.
getMethod
();
String
requestMethod
=
request
.
getMethod
();
String
serverSignature
=
SignUtils
.
buildSignature
(
appSecret
,
requestMethod
,
resourcePath
,
headers
,
params
);
String
canonicalString
=
SignUtils
.
buildCanonicalString
(
requestMethod
,
resourcePath
,
headers
,
params
);
log
.
info
(
"服务端api签名字符串: {}"
,
canonicalString
);
String
serverSignature
=
new
HmacSHA256Signature
().
computeSignature
(
appSecret
,
canonicalString
);
log
.
info
(
"服务端api签名结果: {}"
,
serverSignature
);
if
(!
serverSignature
.
equals
(
clientSignature
))
{
if
(!
serverSignature
.
equals
(
clientSignature
))
{
// 返回给用户的response中告诉用户正确的用于验证加密的签名字符串
// 返回给用户的response中告诉用户正确的用于验证加密的签名字符串
throw
new
AuthenticationException
(
"token 错误"
);
throw
new
AuthenticationException
(
"token 错误"
);
...
...
im-sdk/pom.xml
View file @
e269851f
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<dependency>
<dependency>
<groupId>
com.squareup.okio
</groupId>
<groupId>
com.squareup.okio
</groupId>
<artifactId>
okio
</artifactId>
<artifactId>
okio
</artifactId>
<version>
2.0.0
</version>
<version>
2.
1
0.0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
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