forked from chanjarster/weixin-java-tools
-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
CP_WxCpConfigStorage
Binary Wang edited this page Jan 30, 2024
·
8 revisions
WxCpConfigStorage
是维护企业微信相关信息的地方,里面有以下信息:
- corpid
- corpsecret
- agentid
- token
- aes encoding key
- access token
在Quick Start的例子里我们使用的是
WxCpDefaultConfigImpl
。在正式生产环境中,你可以提供自己的实现,比如在集群环境下将这些信息存储到数据库或分布式缓存里,以便各个节点能够共享access token。
String encType = request.getParameter("encrypt_type");
String nonce = request.getParameter("nonce");
String timestamp = request.getParameter("timestamp");
String msgSignature = request.getParameter("msg_signature");
String signature = request.getParameter("signature");
String openid = request.getParameter("openid");
log.info("接收微信请求:[openid=[{}], [openid=[{}],[signature=[{}], encType=[{}], msgSignature=[{}],"
+ " timestamp=[{}], nonce=[{}], requestBody=[{}] ",
appid, openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
// 请求里面没有对应信息。 // if (!this.wxMpService.switchover(appid)) { //appid // throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid)); // }
if (!wxMpService.checkSignature(timestamp, nonce, signature)) {
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
}
return ResponseEntity.ok("");