|
@ -111,20 +111,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
String nonce = request.getParameter(ModuleConstant.NONCE); |
|
|
String nonce = request.getParameter(ModuleConstant.NONCE); |
|
|
String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); |
|
|
String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); |
|
|
String signature = request.getParameter(ModuleConstant.SIGNATURE); |
|
|
String signature = request.getParameter(ModuleConstant.SIGNATURE); |
|
|
log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); |
|
|
|
|
|
// 从请求中读取整个post数据
|
|
|
// 从请求中读取整个post数据
|
|
|
InputStream inputStream; |
|
|
InputStream inputStream; |
|
|
String postData = null; |
|
|
String postData = null; |
|
|
inputStream = request.getInputStream(); |
|
|
inputStream = request.getInputStream(); |
|
|
postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); |
|
|
postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); |
|
|
log.info("postData = "+postData); |
|
|
|
|
|
WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); |
|
|
WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); |
|
|
String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); |
|
|
String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); |
|
|
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); |
|
|
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); |
|
|
// 将xml转为map
|
|
|
// 将xml转为map
|
|
|
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); |
|
|
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); |
|
|
String infotype = result.get(ModuleConstant.INFO_TYPE); |
|
|
String infotype = result.get(ModuleConstant.INFO_TYPE); |
|
|
log.info(infotype); |
|
|
|
|
|
switch (infotype){ |
|
|
switch (infotype){ |
|
|
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
|
|
|
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
|
|
|
String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); |
|
|
String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); |
|
@ -353,7 +350,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
Map map = JSON.parseObject(data, HashMap.class); |
|
|
Map map = JSON.parseObject(data, HashMap.class); |
|
|
if (!map.containsKey(ModuleConstant.ERR_CODE)) { |
|
|
if (!map.containsKey(ModuleConstant.ERR_CODE)) { |
|
|
log.info(REFRESH_AUTH_ACCESS_TOKEN); |
|
|
log.info(REFRESH_AUTH_ACCESS_TOKEN); |
|
|
//authorizer_access_token
|
|
|
|
|
|
String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); |
|
|
String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); |
|
|
String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString(); |
|
|
String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString(); |
|
|
String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString(); |
|
|
String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString(); |
|
@ -372,7 +368,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
//先逻辑删除,在插入
|
|
|
//先逻辑删除,在插入
|
|
|
authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType); |
|
|
authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType); |
|
|
authorizationInfoDao.insertAuthorizerAccessToken(formDTO); |
|
|
authorizationInfoDao.insertAuthorizerAccessToken(formDTO); |
|
|
|
|
|
|
|
|
//缓存 refreshAuthorizerAccessToken
|
|
|
//缓存 refreshAuthorizerAccessToken
|
|
|
redisThird.setAuthorizerRefreshToken(authorizationInfo); |
|
|
redisThird.setAuthorizerRefreshToken(authorizationInfo); |
|
|
} |
|
|
} |
|
@ -396,28 +391,26 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
String expiresIn = authCodeAndTime.getExpiresIn(); |
|
|
String expiresIn = authCodeAndTime.getExpiresIn(); |
|
|
String customerId = this.getLoginUserCustomerId(tokenDto); |
|
|
String customerId = this.getLoginUserCustomerId(tokenDto); |
|
|
Date expiresInTime = this.countExpirationTime(expiresIn); |
|
|
Date expiresInTime = this.countExpirationTime(expiresIn); |
|
|
if (StringUtils.isBlank(customerId)||StringUtils.isBlank(clientType)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ |
|
|
|
|
|
log.info("客户ID = "+customerId+", 客户端类型为 = "+clientType+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); |
|
|
|
|
|
} |
|
|
|
|
|
//authCode存数据库
|
|
|
//authCode存数据库
|
|
|
AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); |
|
|
AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); |
|
|
formDTO.setAuthCode(authCode); |
|
|
formDTO.setAuthCode(authCode); |
|
|
formDTO.setExpiresInTime(expiresInTime); |
|
|
formDTO.setExpiresInTime(expiresInTime); |
|
|
formDTO.setClientType(clientType); |
|
|
formDTO.setClientType(clientType); |
|
|
//授权方AppId
|
|
|
|
|
|
formDTO.setCustomerId(customerId); |
|
|
formDTO.setCustomerId(customerId); |
|
|
log.info(formDTO.toString()); |
|
|
log.info(formDTO.toString()); |
|
|
authCodeDao.deleteCustomerAuthCode(customerId,clientType); |
|
|
authCodeDao.deleteCustomerAuthCode(customerId,clientType); |
|
|
authCodeDao.insertRedirectAuthCode(formDTO); |
|
|
authCodeDao.insertRedirectAuthCode(formDTO); |
|
|
//authCode存缓存
|
|
|
//authCode存缓存
|
|
|
redisThird.setAuthCode(formDTO); |
|
|
redisThird.setAuthCode(formDTO); |
|
|
|
|
|
// 1. 开始获取授权信息(使用授权码)
|
|
|
AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType); |
|
|
AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType); |
|
|
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); |
|
|
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); |
|
|
// todo ================================================
|
|
|
// 2. 创建开放平台账号并绑定 或者 直接绑定开放平台
|
|
|
AuthCodeResultDTO authCodeResultDTO = authorizationInfoDao.selectCustomerIdByAuthAppId(authAppId); |
|
|
|
|
|
this.createAndBindOpenAccount(customerId,authAppId,clientType); |
|
|
this.createAndBindOpenAccount(customerId,authAppId,clientType); |
|
|
|
|
|
// 3. 更新 customer_mp 表授权状态和AuthAppId
|
|
|
this.updateCustomerMpAppId(customerId,authAppId,clientType); |
|
|
this.updateCustomerMpAppId(customerId,authAppId,clientType); |
|
|
authCodeDao.updateAppId(customerId,clientType,authAppId); |
|
|
authCodeDao.updateAppId(customerId,clientType,authAppId); |
|
|
|
|
|
// 4. 保存授权方账户信息
|
|
|
this.saveAuthAccountInfo(customerId,authAppId,clientType); |
|
|
this.saveAuthAccountInfo(customerId,authAppId,clientType); |
|
|
log.info("回调结束"); |
|
|
log.info("回调结束"); |
|
|
} |
|
|
} |
|
@ -546,7 +539,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class); |
|
|
Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class); |
|
|
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); |
|
|
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); |
|
|
if (bindStatus != true) { |
|
|
if (bindStatus != true) { |
|
|
log.info("开始创建开放平台账号并绑定"); |
|
|
log.info(CREATE_AND_BIND_SUCCESS); |
|
|
List<String> authCount = customerMpDao.selectAuthCount(customerId); |
|
|
List<String> authCount = customerMpDao.selectAuthCount(customerId); |
|
|
String openPlatformId = null; |
|
|
String openPlatformId = null; |
|
|
if (authCount.size() > 0) { |
|
|
if (authCount.size() > 0) { |
|
|