|
@@ -37,32 +37,17 @@ public class WebHandlerAdapter implements HandlerInterceptor {
|
|
@Override
|
|
@Override
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
- //推送数据的签名校验
|
|
|
|
- PushDataCheck[] pushDataChecks = handlerMethod.getMethod().getAnnotationsByType(PushDataCheck.class);
|
|
|
|
- if (pushDataChecks.length != 0){
|
|
|
|
- log.error("PushDataCheck注解拿到了, 长度为 : {}", pushDataChecks.length);
|
|
|
|
|
|
+ //数据推送请求加密验证
|
|
|
|
+ PushDataCheck pushDataCheck = handlerMethod.getMethod().getAnnotation(PushDataCheck.class);
|
|
|
|
+ if (pushDataCheck != null) {
|
|
this.pushCheck(request);
|
|
this.pushCheck(request);
|
|
}
|
|
}
|
|
- log.error("PushDataCheck注解为kong");
|
|
|
|
- //排除签名认证接口注解
|
|
|
|
- UnSignCheck[] unSignChecks = handlerMethod.getMethod().getAnnotationsByType(UnSignCheck.class);
|
|
|
|
- if (unSignChecks.length != 0){
|
|
|
|
- log.error("UnSignCheck注解拿到了, 长度为 : {}", unSignChecks.length);
|
|
|
|
- return Boolean.TRUE;
|
|
|
|
|
|
+ //接口签名验证
|
|
|
|
+ UnSignCheck unSignCheck = handlerMethod.getMethod().getAnnotation(UnSignCheck.class);
|
|
|
|
+ if (unSignCheck == null) {
|
|
|
|
+ return this.signCheck(request);
|
|
}
|
|
}
|
|
- log.error("UnSignCheck注解为kong");
|
|
|
|
- return this.signCheck(request);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// UnSignCheck unSignCheck = handlerMethod.getMethod().getAnnotation(UnSignCheck.class);
|
|
|
|
-// //接口签名验证
|
|
|
|
-// if (unSignCheck == null) {
|
|
|
|
-// return this.signCheck(request);
|
|
|
|
-// }
|
|
|
|
-// log.error("UnSignCheck注解获取到不是kong");
|
|
|
|
-// return Boolean.TRUE;
|
|
|
|
|
|
+ return Boolean.TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
private boolean signCheck(HttpServletRequest request) throws Exception {
|
|
private boolean signCheck(HttpServletRequest request) throws Exception {
|
|
@@ -135,7 +120,7 @@ public class WebHandlerAdapter implements HandlerInterceptor {
|
|
String mySign = SignUtil.MD5(str);
|
|
String mySign = SignUtil.MD5(str);
|
|
//签名对比
|
|
//签名对比
|
|
if (!Objects.equals(mySign, sign)) {
|
|
if (!Objects.equals(mySign, sign)) {
|
|
- log.error("非法参数, 签名错误, mySign : {}, sign : {}, str : {}", mySign, sign, str);
|
|
|
|
|
|
+ log.error("非法参数, pushCheck签名错误, mySign : {}, sign : {}, str : {}", mySign, sign, str);
|
|
throw new BaseException(HttpStatusEnum.INVALID_PARAMS.getMsg());
|
|
throw new BaseException(HttpStatusEnum.INVALID_PARAMS.getMsg());
|
|
}
|
|
}
|
|
}
|
|
}
|