|
|
@@ -195,54 +195,32 @@ public class TtCalllbackController extends BaseController { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/{appId}/callback") |
|
|
|
@PostMapping(value = "/{appId}/callback") |
|
|
|
@ApiOperation("消息回调") |
|
|
|
public void callback(@PathVariable("appId") String appId, HttpServletRequest request, HttpServletResponse response) throws IOException { |
|
|
|
public void callback(@PathVariable("appId") String appId, @RequestBody Map<String, String> params) throws IOException { |
|
|
|
logger.info("[" + getIpAddr() + "]接收微信APP回调 /{appId}/callback"); |
|
|
|
String timestamp = request.getParameter("timestamp"); |
|
|
|
String nonce = request.getParameter("nonce"); |
|
|
|
String signature = request.getParameter("signature"); |
|
|
|
String encType = request.getParameter("encrypt_type"); |
|
|
|
String openid = request.getParameter("openid"); |
|
|
|
String msgSignature = request.getParameter("msg_signature"); |
|
|
|
|
|
|
|
// 第三方平台一定接收的是加密的消息 |
|
|
|
if (!StringUtils.equalsIgnoreCase("aes", encType) |
|
|
|
|| !openService.getTtOpenComponentService().checkSignature(timestamp, nonce,encType, signature)) { |
|
|
|
String nonce = params.get("Nonce"); |
|
|
|
String timestamp = params.get("TimeStamp"); |
|
|
|
// String signature = params.get("signature"); |
|
|
|
String encrypt = params.get("Encrypt"); |
|
|
|
String msgSignature = params.get("MsgSignature"); |
|
|
|
|
|
|
|
if (!openService.getTtOpenComponentService().checkSignature(timestamp, nonce, encrypt, msgSignature)) { |
|
|
|
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); |
|
|
|
} |
|
|
|
// aes加密的消息, 解密 |
|
|
|
TtOpenNotifyMsg openTicket = openService.getTtOpenComponentService().decrypt(encrypt); |
|
|
|
|
|
|
|
// String resultxml = getRequestXML(request); |
|
|
|
|
|
|
|
// logger.info("接收微信APP回调:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}]," |
|
|
|
// + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", |
|
|
|
// appId, openid, signature, encType, msgSignature, timestamp, nonce, resultxml); |
|
|
|
|
|
|
|
|
|
|
|
// String out = ""; |
|
|
|
// // aes加密的消息, 解密 |
|
|
|
// WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(resultxml, |
|
|
|
// openService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); |
|
|
|
// logger.info("接收微信APP回调,消息解密后内容为:\n{}", inMessage.toString()); |
|
|
|
|
|
|
|
handleTicket(openTicket); |
|
|
|
|
|
|
|
|
|
|
|
// // 实际 消息 处理 |
|
|
|
// //handleCallbackMessage(appId, response, inMessage); |
|
|
|
// WxMpXmlOutMessage outMessage = openService.getWxOpenMessageRouter().route(inMessage, appId); |
|
|
|
// if(outMessage == null) { |
|
|
|
// PrintWriter printWriter = response.getWriter(); |
|
|
|
// wechatWriteSuccess(printWriter); |
|
|
|
// } |
|
|
|
PrintWriter printWriter = response.getWriter(); |
|
|
|
wechatWriteSuccess(printWriter); |
|
|
|
} |
|
|
|
|
|
|
|
private void wechatWriteSuccess(PrintWriter printWriter) { |
|
|
|
printWriter.print("success"); |
|
|
|
printWriter.flush(); |
|
|
|
printWriter.close(); |
|
|
|
} |
|
|
|
// private void wechatWriteSuccess(PrintWriter printWriter) { |
|
|
|
// printWriter.print("success"); |
|
|
|
// printWriter.flush(); |
|
|
|
// printWriter.close(); |
|
|
|
// } |
|
|
|
|
|
|
|
// /** |
|
|
|
// * 测试账号特殊处理 |
|
|
|