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
91783cbb
Commit
91783cbb
authored
Apr 28, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解析token
parent
f688e8ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
+34
-3
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
+1
-0
No files found.
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
View file @
91783cbb
package
com
.
wecloud
.
im
.
tillo
.
netty
.
handler
;
import
com.alibaba.fastjson.JSONObject
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.tillo.app_ws.AppImHandler
;
import
com.wecloud.im.tillo.app_ws.model.Constants
;
import
com.wecloud.im.tillo.app_ws.model.RequestHeaderConstants
;
import
com.wecloud.im.tillo.app_ws.utils.FullHttpRequestUtils
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.http.FullHttpRequest
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Base64
;
import
java.util.Map
;
/**
...
...
@@ -24,13 +32,20 @@ import java.util.Map;
public
class
NettyApiRequest
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NettyApiRequest
.
class
);
// @Resource
// private AppUserChannelsService appUserChannelsService;
// @Resource
// private AppUserChannelsService appUserChannelsService;
@Autowired
private
StringRedisTemplate
redisTemplate
;
@Resource
private
AppImHandler
appImHandler
;
@Autowired
private
ImClientService
imClientService
;
@Autowired
private
ImApplicationService
imApplicationService
;
/**
* http请求接收
*
...
...
@@ -76,6 +91,22 @@ public class NettyApiRequest {
String
token
=
paramMap
.
get
(
Constants
.
TOKEN
);
String
deviceId
=
paramMap
.
get
(
RequestHeaderConstants
.
DEVICE_ID
);
DecodedJWT
jwtInfo
=
JwtUtil
.
getJwtInfo
(
token
);
String
payload
=
jwtInfo
.
getPayload
();
Base64
.
Decoder
decoder
=
Base64
.
getDecoder
();
payload
=
new
String
(
decoder
.
decode
(
payload
),
"UTF-8"
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
payload
);
String
appKey
=
(
String
)
jsonObject
.
get
(
"appKey"
);
String
id
=
(
String
)
jsonObject
.
get
(
"username"
);
// redisTemplate.opsForValue().set("client:" + imApplication.getAppKey() + ":" + clientId, generateToken);
// 设置uri前缀
httpRequest
.
setUri
(
Constants
.
APP_WS_URL
);
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/util/JwtUtil.java
View file @
91783cbb
...
...
@@ -98,6 +98,7 @@ public class JwtUtil {
// 签发的目标
.
withAudience
(
jwtProperties
.
getAudience
())
.
withClaim
(
"test1"
,
"ddddddd"
)
.
withClaim
(
"appKey"
,
"elLwpel1gWCHDqZy"
)
// 签名时间
.
withIssuedAt
(
new
Date
())
// token过期时间
...
...
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