替换fastjson为jackson
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.central.oauth.handler;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -36,9 +36,9 @@ public class OauthLogoutSuccessHandler implements LogoutSuccessHandler {
|
||||
} else {
|
||||
response.setStatus(HttpStatus.OK.value());
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
PrintWriter writer = response.getWriter();
|
||||
String jsonStr = JSON.toJSONString(Result.succeed("登出成功"));
|
||||
String jsonStr = JsonUtil.toJSONString(Result.succeed("登出成功"));
|
||||
writer.write(jsonStr);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.central.oauth2.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -16,7 +16,7 @@ public class JwtUtilsTest {
|
||||
@Test
|
||||
public void test() {
|
||||
String jwtToken = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXN0IjoiYWJjIiwidXNlcl9uYW1lIjoiYWRtaW4iLCJzY29wZSI6WyJhcHAiXSwiZXhwIjoxNTYzNjgyMTI4LCJhdXRob3JpdGllcyI6WyJBRE1JTiJdLCJqdGkiOiJlMDFlNGU0Yi1hZDVkLTRlMTQtODhiMC00OGQ4YzBjN2U5YjkiLCJjbGllbnRfaWQiOiJ3ZWJBcHAifQ.Qrh2aEoN4TL_WIQ9UpxDrW12aqqoVqxeY826sjbea2LB24RBNDYQl1J5vwXzMaQlG9AgjHRL4bTQihwBYYfdL-VuJXx0_l0xONbz9sHPq60a3gAhxOnekNS5-Qet5feTw7j4o2OwNlxo-xty5s8u2lsQY21zCe0tes_T4XeM76JTBpRbQUFGUU3EKxtUFi3Nk9AII4zerW1AbQNvLo4YW2Wvj___0lq5a-xNdCcHlJid8vKgzEF3v3wECOv6OjgL-fUN8VpUsYVt1-_QZp8opPAf-t3OVTtrVIWrJZ_vWV9d6DN5mynKtZ7_mDyMwo_5w3roAZ0ahoBKPKrtYQyEwQ";
|
||||
JSONObject claims = JwtUtils.decodeAndVerify(jwtToken);
|
||||
JsonNode claims = JwtUtils.decodeAndVerify(jwtToken);
|
||||
//token内容
|
||||
System.out.println(claims);
|
||||
boolean isValid = JwtUtils.checkExp(claims);
|
||||
|
||||
Reference in New Issue
Block a user