JWTUtil的parseToken增加空值异常抛出

This commit is contained in:
Looly 2022-08-27 00:34:33 +08:00
parent 2b9da605a7
commit 2327af84ca
3 changed files with 9 additions and 1 deletions

View File

@ -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() 修改为使用toPlainStringpr#775@Gitee
* 【extra 】 QrCodeUtil新增SVG格式、Ascii Art字符画格式pr#763@Gitee
* 【jwt 】 JWTUtil的parseToken增加空值异常抛出issue#I5OCQB@Gitee
*
### 🐞Bug修复
* 【http 】 修复https下可能的Patch、Get请求失效问题issue#I3Z3DH@Gitee

View File

@ -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);

View File

@ -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." +