|
|
package com.yohoufo.common.interceptor;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.crypto.Mac;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
import com.netflix.config.DynamicPropertyFactory;
|
|
|
import com.yoho.core.common.utils.MD5;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yoho.error.event.LogEvent;
|
|
|
import com.yohoufo.common.annotation.IgnoreSignature;
|
|
|
import com.yohoufo.common.exception.SignatureNotMatchException;
|
...
|
...
|
@@ -23,10 +18,13 @@ import org.springframework.web.method.HandlerMethod; |
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
import com.netflix.config.DynamicPropertyFactory;
|
|
|
import com.yoho.core.common.utils.MD5;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.crypto.Mac;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.*;
|
|
|
|
|
|
public class SignatureVerifyInterceptor implements HandlerInterceptor, ApplicationEventPublisherAware {
|
|
|
|
...
|
...
|
@@ -53,6 +51,7 @@ public class SignatureVerifyInterceptor implements HandlerInterceptor, Applicati |
|
|
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
|
|
|
//(1) 验签开关, 控制是否需要验签. 默认需要验证
|
|
|
boolean isSignatureVerifyEnable = configReader.getBoolean("gateway.security.isSignatureVerifyEnable", true);
|
|
|
logger.info("isDebugEnable is {},request param debug is {}",isDebugEnable,httpServletRequest.getParameter("debug"));//TODO test
|
|
|
if(!isSignatureVerifyEnable){
|
|
|
logger.debug("gateway.security.isSignatureVerifyEnable is false");
|
|
|
return true;
|
...
|
...
|
|