parent
e76b48a450
commit
75f34f6d14
@ -0,0 +1,47 @@ |
|||||||
|
package com.order.controller.notify; |
||||||
|
|
||||||
|
import com.hfkj.common.utils.WxUtils; |
||||||
|
|
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/wxNotify") |
||||||
|
@Api(value = "微信通知") |
||||||
|
public class WxNotifyController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(WxNotifyController.class); |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "验证servlet") |
||||||
|
public String verifyWxToken( |
||||||
|
@RequestParam(name = "signature", required = false) String signature, |
||||||
|
@RequestParam(name = "timestamp", required = false) String timestamp, |
||||||
|
@RequestParam(name = "nonce", required = false) String nonce, |
||||||
|
@RequestParam(name = "echostr", required = false) String echostr |
||||||
|
) { |
||||||
|
|
||||||
|
try { |
||||||
|
|
||||||
|
String signatureStr = WxUtils.getSHA1("PHGWX" , timestamp , nonce); |
||||||
|
log.info("signatureStr!!!!!" + signatureStr); |
||||||
|
log.info("signature!!!!!" + signature); |
||||||
|
if (signature.equals(signatureStr)) { |
||||||
|
log.info("验证通过!!!!!"); |
||||||
|
return echostr; |
||||||
|
} |
||||||
|
log.info("验证失败!!!!!"); |
||||||
|
return null; |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue