|
@@ -1,48 +0,0 @@
|
|
|
-package com.fdkankan.ucenter.interceptor;
|
|
|
-
|
|
|
-
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.http.ContentType;
|
|
|
-import cn.hutool.http.HttpResponse;
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.util.JwtUtil;
|
|
|
-import com.fdkankan.redis.util.RedisUtil;
|
|
|
-import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
|
-import com.fdkankan.ucenter.common.Result;
|
|
|
-import com.fdkankan.ucenter.constant.LoginConstant;
|
|
|
-import java.awt.PageAttributes.MediaType;
|
|
|
-import java.io.IOException;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
-
|
|
|
-@Component
|
|
|
-@Slf4j
|
|
|
-public class InnerApiInterceptor implements HandlerInterceptor {
|
|
|
-
|
|
|
- @Value("${inner.customToken}")
|
|
|
- private String customToken;
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
|
- response.setContentType("application/json;charset=UTF-8");
|
|
|
- String customToken = request.getHeader("custom-token");
|
|
|
- if(StrUtil.isEmpty(customToken) || !customToken.equals(this.customToken)){
|
|
|
- response.getWriter().append(JSON.toJSONString(Result.failure(ErrorCode.HAVE_NO_RIGHT.code(), ErrorCode.HAVE_NO_RIGHT.message())));
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|