/**
 * 
 */
package net.wyun.wcrs.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import net.wyun.wcrs.jsj.JSJFormInfo;
import net.wyun.wcrs.model.User;
import net.wyun.wcrs.model.UserRepository;

/**
 * @author Xuecheng
 *
 */
@RequestMapping("/secure")
@RestController
public class WechatController {
	
	private static final Logger logger = LoggerFactory.getLogger(WechatController.class);
	
	@Autowired
	UserRepository userRepo;
	
	@RequestMapping(value= "/wechat", method=RequestMethod.POST)
	String saveUser(@RequestBody String data){
		logger.info("wechat data: " + data);
		return data;
	}

}

@@ -36,24 +36,175 @@
 ontroller;%0A%0A
+import java.io.IOException;%0Aimport java.io.PrintWriter;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A
 import org.s
@@ -212,24 +212,24 @@
 f4j.Logger;%0A
-
 import org.s
@@ -734,16 +734,54 @@
 ository;
+%0Aimport net.wyun.wcrs.wechat.SignUtil;
 %0A%0A/**%0A *
@@ -1156,16 +1156,16 @@
  data);%0A
-
 %09%09return
@@ -1173,12 +1173,808 @@
 data;%0A%09%7D
+%0A%09%0A%09@RequestMapping(value= %22/wechat%22, method=RequestMethod.GET)%0A%09void handShake(HttpServletRequest request, HttpServletResponse response) throws IOException%7B%0A%09%09// %E5%BE%AE%E4%BF%A1%E5%8A%A0%E5%AF%86%E7%AD%BE%E5%90%8D%0A%09%09String signature = request.getParameter(%22signature%22);%0A%09%09// %E6%97%B6%E9%97%B4%E6%88%B3%0A%09%09String timestamp = request.getParameter(%22timestamp%22);%0A%09%09// %E9%9A%8F%E6%9C%BA%E6%95%B0%0A%09%09String nonce = request.getParameter(%22nonce%22);%0A%09%09// %E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%0A%09%09String echostr = request.getParameter(%22echostr%22);%0A%09%09%0A%09%09logger.debug(%22signature, timestamp, echostr: %22 + signature + %22, %22 + timestamp + %22, %22 + echostr);%0A%0A%09%09PrintWriter out = response.getWriter();%0A%09%09// %E8%AF%B7%E6%B1%82%E6%A0%A1%E9%AA%8C%EF%BC%8C%E8%8B%A5%E6%A0%A1%E9%AA%8C%E6%88%90%E5%8A%9F%E5%88%99%E5%8E%9F%E6%A0%B7%E8%BF%94%E5%9B%9Eechostr%EF%BC%8C%E8%A1%A8%E7%A4%BA%E6%8E%A5%E5%85%A5%E6%88%90%E5%8A%9F%EF%BC%8C%E5%90%A6%E5%88%99%E6%8E%A5%E5%85%A5%E5%A4%B1%E8%B4%A5%0A%09%09if (SignUtil.checkSignature(signature, timestamp, nonce)) %7B%0A%09%09%09out.print(echostr);%0A%09%09%7Delse%7B%0A%09%09%09logger.info(%22signature check fails!%22 + request.getRemoteHost());%0A%09%09%7D%0A%09%09out.close();%0A%09%09out = null;%0A%0A%09%7D
 %0A%0A%7D%0A

add log.