Sfoglia il codice sorgente

circle

release_toaliyun_real
xhxu 5 anni fa
parent
commit
c9e89ee946
1 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. +6
    -6
      mallinkPublicApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java

+ 6
- 6
mallinkPublicApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java Vedi File

@@ -67,7 +67,6 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少加密串"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少加密串");
} }



String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); String body = ((BodyReaderHttpServletRequestWrapper) request).getBody();
if(StringUtils.isBlank(body)){ if(StringUtils.isBlank(body)){
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少参数"); 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(),"请求过期"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请求过期");
} }


logger.info("sign={}"+signature);

for (String key:notKeys) { for (String key:notKeys) {
if(parameterMap.containsKey(key)){ if(parameterMap.containsKey(key)){
parameterMap.remove(key); parameterMap.remove(key);
} }
} }
logger.info("parameterMap={}"+parameterMap.toString());


String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5"); String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5");
logger.info("newSignature={}"+newSignature);
//加密串不匹配 //加密串不匹配
if (!signature.equals(newSignature)) { if (!signature.equals(newSignature)) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"加密串校验失败"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"加密串校验失败");
} }
Integer cache = RedisCacheUtils.getCacheInteger(redisTemplate, Constant.publicApiNonce+signature); Integer cache = RedisCacheUtils.getCacheInteger(redisTemplate, Constant.publicApiNonce+signature);
logger.info("cache={}"+cache.toString());
if (null != cache) { if (null != cache) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"重复调用"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"重复调用");
} }
RedisCacheUtils.cache(redisTemplate, Constant.publicApiNonce+signature, 1, 300); RedisCacheUtils.cache(redisTemplate, Constant.publicApiNonce+signature, 1, 300);
return true; return true;


}catch(Exception e){
}catch(MallinkException e){
throw e;
}
catch(Exception e){
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确");
} }




Caricamento…
Annulla
Salva