Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-cloud-core
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
xingmin
yd-cloud-core
Commits
5926990e
Commit
5926990e
authored
Oct 20, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
idP
parent
aa98e103
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
yd-auth-core/src/main/java/com/yd/auth/core/security/JwtTokenProvider.java
+7
-10
No files found.
yd-auth-core/src/main/java/com/yd/auth/core/security/JwtTokenProvider.java
View file @
5926990e
...
@@ -138,22 +138,19 @@ public class JwtTokenProvider {
...
@@ -138,22 +138,19 @@ public class JwtTokenProvider {
}
}
/**
/**
* 验证令牌有效性
* 验证令牌有效性。
*
* <p>语义:true=有效;false=无效(签名不符/过期/格式错等)。无效 token 不在此抛异常,
* 由调用过滤器按"未认证"处理——受保护资源经授权层返回 401、白名单路径正常放行。
* 避免一个坏 token 抛异常中断整条请求(旧实现会把 permitAll 路径也打成 401/500)。</p>
*/
*/
public
boolean
validateToken
(
String
token
)
{
public
boolean
validateToken
(
String
token
)
{
try
{
try
{
Jwts
.
parserBuilder
().
setSigningKey
(
getSigningKey
()).
build
().
parseClaimsJws
(
token
);
Jwts
.
parserBuilder
().
setSigningKey
(
getSigningKey
()).
build
().
parseClaimsJws
(
token
);
return
true
;
return
true
;
}
catch
(
SecurityException
|
MalformedJwtException
e
)
{
throw
new
JwtAuthenticationException
(
"无效的JWT签名"
);
}
catch
(
ExpiredJwtException
e
)
{
throw
new
JwtAuthenticationException
(
"JWT令牌已过期"
);
}
catch
(
UnsupportedJwtException
e
)
{
throw
new
JwtAuthenticationException
(
"不支持的JWT令牌"
);
}
catch
(
IllegalArgumentException
e
)
{
throw
new
JwtAuthenticationException
(
"JWT令牌无效"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
JwtAuthenticationException
(
"无效的JWT令牌: "
+
e
.
getMessage
());
log
.
debug
(
"JWT 校验未通过,按未认证处理:{}"
,
e
.
getMessage
());
return
false
;
}
}
}
}
...
...
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