mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
JWTUtil的parseToken增加空值异常抛出
This commit is contained in:
parent
2b9da605a7
commit
2327af84ca
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.8.6.M1 (2022-08-26)
|
||||
# 5.8.6.M1 (2022-08-27)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 CollUtil新增addIfAbsent方法(pr#750@Gitee)
|
||||
@ -16,6 +16,7 @@
|
||||
* 【jwt 】 JWT补充部分算法(pr#2546@Github)
|
||||
* 【core 】 NumberUtil.roundStr() 修改为使用toPlainString(pr#775@Gitee)
|
||||
* 【extra 】 QrCodeUtil新增SVG格式、Ascii Art字符画格式(pr#763@Gitee)
|
||||
* 【jwt 】 JWTUtil的parseToken增加空值异常抛出(issue#I5OCQB@Gitee)
|
||||
*
|
||||
### 🐞Bug修复
|
||||
* 【http 】 修复https下可能的Patch、Get请求失效问题(issue#I3Z3DH@Gitee)
|
||||
|
@ -92,6 +92,7 @@ public class JWT implements RegisteredPayload<JWT> {
|
||||
* @return this
|
||||
*/
|
||||
public JWT parse(String token) {
|
||||
Assert.notBlank(token, "Token String must be not blank!");
|
||||
final List<String> tokens = splitToken(token);
|
||||
this.tokens = tokens;
|
||||
this.header.parse(tokens.get(0), this.charset);
|
||||
|
@ -43,6 +43,12 @@ public class JWTUtilTest {
|
||||
Assert.assertEquals(true, jwt.getPayload("admin"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void parseNullTest(){
|
||||
// https://gitee.com/dromara/hutool/issues/I5OCQB
|
||||
JWTUtil.parseToken(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyTest(){
|
||||
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
|
||||
|
Loading…
Reference in New Issue
Block a user