mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
JWTUtil的parseToken增加空值异常抛出
This commit is contained in:
@@ -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." +
|
||||
|
Reference in New Issue
Block a user