| @@ -16,8 +16,13 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.ResponseBody; | |||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.IOException; | |||||
| import java.io.PrintWriter; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -69,4 +74,34 @@ public class WxMallController extends BaseController { | |||||
| } | } | ||||
| /** | |||||
| * 微信消息服务验证 | |||||
| * @param response | |||||
| * @param request | |||||
| * @throws IOException | |||||
| */ | |||||
| @AuthIgnore | |||||
| @RequestMapping(value = "/signature") | |||||
| @ResponseBody | |||||
| public void signature(HttpServletResponse response, HttpServletRequest request) throws IOException { | |||||
| String signature = request.getParameter("signature"); | |||||
| String timestamp = request.getParameter("timestamp"); | |||||
| String nonce = request.getParameter("nonce"); | |||||
| String echostr = request.getParameter("echostr"); | |||||
| logger.warn("收到的微信服务验证信息:"+signature+"\n"+timestamp+"\n"+nonce+"\n"+echostr); | |||||
| PrintWriter out = response.getWriter(); | |||||
| // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 | |||||
| // 当前无法确定此消息的appId及token, 所以直接返回echostr | |||||
| //if (CheckUtil.checkSignature(wp.getToken(), signature, timestamp, nonce)) { | |||||
| out.print(echostr); | |||||
| logger.warn("微信服务验证成功===================="+echostr); | |||||
| System.out.println("微信服务验证成功!"); | |||||
| //} | |||||
| out.close(); | |||||
| } | |||||
| } | } | ||||