|
|
|
@@ -67,7 +67,6 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少加密串"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); |
|
|
|
if(StringUtils.isBlank(body)){ |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少参数"); |
|
|
|
@@ -87,29 +86,30 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请求过期"); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("sign={}"+signature); |
|
|
|
|
|
|
|
for (String key:notKeys) { |
|
|
|
if(parameterMap.containsKey(key)){ |
|
|
|
parameterMap.remove(key); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("parameterMap={}"+parameterMap.toString()); |
|
|
|
|
|
|
|
String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5"); |
|
|
|
logger.info("newSignature={}"+newSignature); |
|
|
|
//加密串不匹配 |
|
|
|
if (!signature.equals(newSignature)) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"加密串校验失败"); |
|
|
|
} |
|
|
|
Integer cache = RedisCacheUtils.getCacheInteger(redisTemplate, Constant.publicApiNonce+signature); |
|
|
|
logger.info("cache={}"+cache.toString()); |
|
|
|
|
|
|
|
if (null != cache) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"重复调用"); |
|
|
|
} |
|
|
|
RedisCacheUtils.cache(redisTemplate, Constant.publicApiNonce+signature, 1, 300); |
|
|
|
return true; |
|
|
|
|
|
|
|
}catch(Exception e){ |
|
|
|
}catch(MallinkException e){ |
|
|
|
throw e; |
|
|
|
} |
|
|
|
catch(Exception e){ |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); |
|
|
|
} |
|
|
|
|
|
|
|
|