This commit is contained in:
Looly 2022-08-27 00:40:11 +08:00
parent 923da89622
commit aae154461e
3 changed files with 25 additions and 4 deletions

View File

@ -3,7 +3,7 @@
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 6.0.0.M1 (2022-07-17) # 6.0.0.M1 (2022-08-27)
### 计划实现 ### 计划实现
* 【poi 】 PDF相关基于PdfBox * 【poi 】 PDF相关基于PdfBox
@ -11,6 +11,7 @@
* 【poi 】 Markdown相关如HTML转换等基于commonmark-java * 【poi 】 Markdown相关如HTML转换等基于commonmark-java
* 【db 】 增加DDL封装 * 【db 】 增加DDL封装
* 【json 】 实现自定义的类型转换,不影响全局的转换器 * 【json 】 实现自定义的类型转换,不影响全局的转换器
* 【core 】 Functional接口重新定义
### ❌不兼容特性 ### ❌不兼容特性

View File

@ -88,10 +88,12 @@ public class JWT implements RegisteredPayload<JWT> {
/** /**
* 解析JWT内容 * 解析JWT内容
* *
* @param token JWT Token字符串格式为xxxx.yyyy.zzzz * @param token JWT Token字符串格式为xxxx.yyyy.zzzz不能为空
* @return this * @return this
* @throws IllegalArgumentException 给定字符串为空
*/ */
public JWT parse(final String token) { public JWT parse(final String token) throws IllegalArgumentException {
Assert.notBlank(token, "Token String must be not blank!");
final List<String> tokens = splitToken(token); final List<String> tokens = splitToken(token);
this.tokens = tokens; this.tokens = tokens;
this.header.parse(tokens.get(0), this.charset); this.header.parse(tokens.get(0), this.charset);

View File

@ -43,6 +43,24 @@ public class JWTUtilTest {
Assert.assertEquals(true, jwt.getPayload("admin")); Assert.assertEquals(true, jwt.getPayload("admin"));
} }
@Test(expected = IllegalArgumentException.class)
public void parseNullTest(){
// https://gitee.com/dromara/hutool/issues/I5OCQB
JWTUtil.parseToken(null);
}
@Test(expected = IllegalArgumentException.class)
public void parseEmptyTest(){
// https://gitee.com/dromara/hutool/issues/I5OCQB
JWTUtil.parseToken("");
}
@Test(expected = IllegalArgumentException.class)
public void parseBlankTest(){
// https://gitee.com/dromara/hutool/issues/I5OCQB
JWTUtil.parseToken(" ");
}
@Test @Test
public void verifyTest(){ public void verifyTest(){
final String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." + final String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +