Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
hooloo
ms
soss
Commits
b5ec1978
Commit
b5ec1978
authored
Aug 18, 2023
by
caiyt-byte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token key方式更改
parent
0e43c84b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
+12
-2
No files found.
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
View file @
b5ec1978
...
...
@@ -18,7 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.servlet.http.HttpServletRequest
;
import
java.security.Key
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -52,6 +55,13 @@ public class TokenService {
@Autowired
private
RedisCache
redisCache
;
private
Key
secretKey
;
@PostConstruct
public
void
init
()
{
secretKey
=
new
SecretKeySpec
(
secret
.
getBytes
(),
SignatureAlgorithm
.
HS512
.
getJcaName
());
}
/**
* 获取用户身份信息
*
...
...
@@ -162,7 +172,7 @@ public class TokenService {
private
String
createToken
(
Map
<
String
,
Object
>
claims
)
{
String
token
=
Jwts
.
builder
()
.
setClaims
(
claims
)
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
).
compact
();
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
Key
).
compact
();
return
token
;
}
...
...
@@ -174,7 +184,7 @@ public class TokenService {
*/
private
Claims
parseToken
(
String
token
)
{
return
Jwts
.
parser
()
.
setSigningKey
(
secret
)
.
setSigningKey
(
secret
Key
)
.
parseClaimsJws
(
token
)
.
getBody
();
}
...
...
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