记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
3b44432f
Commit
3b44432f
authored
Jun 04, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix token;
parent
7533ab39
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
JwtValidator.java
...in/java/com/liquidnet/commons/lang/core/JwtValidator.java
+11
-2
No files found.
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/core/JwtValidator.java
View file @
3b44432f
...
@@ -27,6 +27,15 @@ public class JwtValidator {
...
@@ -27,6 +27,15 @@ public class JwtValidator {
// private static final long EXPIRE_TIME = 15 * 60 * 1000;
// private static final long EXPIRE_TIME = 15 * 60 * 1000;
// private static final String TOKEN_SECRET = "qZHglvNP0n0aOOckHiQXq5JMD468J4eG";
// private static final String TOKEN_SECRET = "qZHglvNP0n0aOOckHiQXq5JMD468J4eG";
private
SecretKey
secretKey
;
private
SecretKey
initSecretKey
(
String
secret
)
{
if
(
null
==
this
.
secretKey
)
{
this
.
secretKey
=
new
SecretKeySpec
(
secret
.
getBytes
(),
SignatureAlgorithm
.
HS256
.
getJcaName
());
}
return
this
.
secretKey
;
}
/**
/**
* 用户登录成功后生成Jwt token
* 用户登录成功后生成Jwt token
* 使用Hs256算法
* 使用Hs256算法
...
@@ -42,7 +51,7 @@ public class JwtValidator {
...
@@ -42,7 +51,7 @@ public class JwtValidator {
.
setClaims
(
claimsMap
)
.
setClaims
(
claimsMap
)
.
setIssuedAt
(
new
Date
(
nowMillis
))
.
setIssuedAt
(
new
Date
(
nowMillis
))
.
setExpiration
(
new
Date
(
expMillis
))
.
setExpiration
(
new
Date
(
expMillis
))
.
signWith
(
SignatureAlgorithm
.
HS256
,
new
SecretKeySpec
(
secret
.
getBytes
(),
SignatureAlgorithm
.
HS256
.
getJcaName
()
));
.
signWith
(
SignatureAlgorithm
.
HS256
,
this
.
initSecretKey
(
this
.
secret
));
return
builder
.
compact
();
return
builder
.
compact
();
}
}
...
@@ -54,7 +63,7 @@ public class JwtValidator {
...
@@ -54,7 +63,7 @@ public class JwtValidator {
*/
*/
public
Claims
parse
(
String
token
)
{
public
Claims
parse
(
String
token
)
{
return
Jwts
.
parser
()
return
Jwts
.
parser
()
.
setSigningKey
(
new
SecretKeySpec
(
secret
.
getBytes
(),
SignatureAlgorithm
.
HS256
.
getJcaName
()
))
.
setSigningKey
(
this
.
initSecretKey
(
this
.
secret
))
.
parseClaimsJws
(
token
).
getBody
();
.
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