3 changed files with 109 additions and 0 deletions
@ -0,0 +1,39 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.exception.AesException; |
|||
import com.epmet.service.WarrantService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.dom4j.Document; |
|||
import org.dom4j.DocumentException; |
|||
import org.dom4j.DocumentHelper; |
|||
import org.dom4j.Element; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/7/10 10:41 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("warrant") |
|||
public class WarrantController { |
|||
|
|||
@Autowired |
|||
private WarrantService warrantService; |
|||
|
|||
@RequestMapping(value ="/{AppId}/callback") |
|||
public void acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid, |
|||
HttpServletResponse response)throws IOException, DocumentException, AesException { |
|||
warrantService.acceptMessageAndEvent(request, appid, response); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.exception.AesException; |
|||
import org.dom4j.DocumentException; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/7/10 11:03 |
|||
*/ |
|||
public interface WarrantService { |
|||
|
|||
void acceptMessageAndEvent(HttpServletRequest request,String appid,HttpServletResponse response)throws IOException, DocumentException, AesException; |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.exception.AesException; |
|||
import com.epmet.service.WarrantService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.dom4j.Document; |
|||
import org.dom4j.DocumentException; |
|||
import org.dom4j.DocumentHelper; |
|||
import org.dom4j.Element; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/7/10 11:03 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class WarrantServiceImpl implements WarrantService { |
|||
@Override |
|||
public void acceptMessageAndEvent(HttpServletRequest request, String appid, HttpServletResponse response)throws IOException, DocumentException, AesException { |
|||
String msgSignature = request.getParameter("msg_signature"); |
|||
log.info("第三方平台全网发布-------------{appid}/callback-----------验证开始。。。。msg_signature=" + msgSignature); |
|||
if (!StringUtils.isNotBlank(msgSignature)) { |
|||
return;// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
|
|||
} |
|||
StringBuilder sb =new StringBuilder(); |
|||
BufferedReader in = request.getReader(); |
|||
String line; |
|||
while ((line = in.readLine()) !=null) { |
|||
sb.append(line); |
|||
} |
|||
in.close(); |
|||
|
|||
String xml = sb.toString(); |
|||
Document doc = DocumentHelper.parseText(xml); |
|||
Element rootElt = doc.getRootElement(); |
|||
String toUserName = rootElt.elementText("ToUserName"); |
|||
|
|||
//微信全网测试账号
|
|||
// if (StringUtils.equalsIgnoreCase(toUserName, APPID)) {
|
|||
log.info("全网发布接入检测消息反馈开始---------------APPID=" + appid +"------------------------toUserName=" + toUserName); |
|||
// checkWeixinAllNetworkCheck(request, response, xml);
|
|||
// }
|
|||
} |
|||
} |
Loading…
Reference in new issue