| | |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.multipart.MultipartResolver; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartResolver; |
| | | import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | //签名验证 |
| | | @Around("execution(public * com.yeshi.buwan.controller.api.*.*(..))") |
| | | public Object verifySign(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = servletContainer.getRequest(); |
| | | HttpServletResponse response = servletContainer.getResponse(); |
| | | RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); |
| | | HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse(); |
| | | PrintWriter out = null; |
| | | AcceptData acceptData = null; |
| | | Object[] args = joinPoint.getArgs(); |
| | |
| | | //布丸3.8.7之后调用新的签名方法 |
| | | if (acceptData != null && "android".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() >= 105) { |
| | | Map<String, String[]> params = request.getParameterMap(); |
| | | //签名 |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | | //签名 |
| | | for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | if ("sign".equalsIgnoreCase(key)) |
| | | continue; |
| | | list.add(key + "=" + params.get(key)[0]); |
| | | } |
| | | |
| | | Collections.sort(list); |
| | | String str = StringUtil.concat(list, "&"); |
| | | String sign = StringUtil.Md5(str + "8888B&*@-uWan88/',@@^"); |