多因素
This commit is contained in:
@ -5,6 +5,7 @@ import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.BaseRespVo;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
@ -33,7 +34,7 @@ public interface ICrypConfigureService extends IBaseService<CrypConfigure> {
|
||||
* @param bean
|
||||
* @return true/false
|
||||
*/
|
||||
Boolean callUniInterfaceMessage(CrypBean bean);
|
||||
BaseRespVo callUniInterfaceMessage(CrypBean bean);
|
||||
/**
|
||||
* 加载失败日志再发送
|
||||
* @param
|
||||
|
@ -31,6 +31,7 @@ import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypUniBss;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.BaseRespVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -208,8 +209,9 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean callUniInterfaceMessage(CrypBean bean) {
|
||||
public BaseRespVo callUniInterfaceMessage(CrypBean bean) {
|
||||
log.info("多因素------callUniInterfaceMessage:---入参-----" + JSON.toJSONString(bean));
|
||||
BaseRespVo bodys = new BaseRespVo();
|
||||
BlockChainLog blockChainLog = new BlockChainLog();
|
||||
blockChainLog.setId(PropertyUtils.getSnowflakeId());
|
||||
//天擎地址
|
||||
@ -235,7 +237,7 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
log.info("多因素map------callUniInterfaceMessage:---入参map-----" + JSON.toJSONString(map));
|
||||
|
||||
//传入数据解密
|
||||
String sign = getSignValue(map);
|
||||
// String sign = getSignValue(map);
|
||||
|
||||
// map.put("SIGN", sign);
|
||||
|
||||
@ -244,29 +246,31 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
blockChainLog.setParam(json);//请求参数
|
||||
str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
|
||||
blockChainLog.setResult(str);//返回参数
|
||||
UniBss uniBssRsp = JSONArray.parseObject(str, UniBss.class);
|
||||
CrypUniBss uniBssRsp = JSONArray.parseObject(str, CrypUniBss.class);
|
||||
if (uniBssRsp != null && UniBssConstant.RESP_CODE_00000.equals(uniBssRsp.getUniBssHead().getRespCode())) {
|
||||
System.out.println("返回接口:" + uniBssRsp);
|
||||
Map<String, Object> body = uniBssRsp.getUniBssBodyMap();
|
||||
Object js = body.get("MESSAGE_SEND_VERIFYCODE_REQ".equals(bean.getReqName())?"MESSAGE_SEND_VERIFYCODE_RSP":"MESSAGE_CHECK_VERIFYCODE_RSP");
|
||||
bodys = JSONArray.parseObject(js.toString(),BaseRespVo.class);
|
||||
|
||||
if (str != null && !"".equals(str) && str.indexOf("_RSP\":{\"Code\":200,") >= 0) {
|
||||
if (str != null && !"".equals(str) && str.indexOf("_RSP\":{\"Code\":200,") >= 0
|
||||
&& ("0".equals(bodys.getCode()) || "200".equals(bodys.getCode()) )) {
|
||||
blockChainLog.setStatus(0);//成功
|
||||
this.iBlockChainLogService.save(blockChainLog);
|
||||
return true;
|
||||
return bodys;
|
||||
} else {
|
||||
blockChainLog.setStatus(1);//失败
|
||||
return bodys;
|
||||
}
|
||||
} else {
|
||||
blockChainLog.setStatus(1);//失败
|
||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.assertStringNotNullByKey("天擎多因素接口调用错误," +
|
||||
"RESP_CODE:" + uniBssRsp.getUniBssHead().getRespCode() + "" +
|
||||
"(" + UniBssConstant.getRESP_CODE_Map(uniBssRsp.getUniBssHead().getRespCode()) + ")。" +
|
||||
"RESP_DESC:" + uniBssRsp.getUniBssHead().getRespDesc(), bean);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
blockChainLog.setStatus(1);
|
||||
blockChainLog.setResult(e.getMessage());
|
||||
|
||||
}finally {
|
||||
this.iBlockChainLogService.save(blockChainLog);
|
||||
if(blockChainLog.getStatus().equals(1)){
|
||||
log.error("多因素调用失败!~-----------------");
|
||||
operationLogService.addOperationLog("多因素同步失败信息,参数{}"+json+"返回信息{}"+str,false, EbtpLogBusinessModule.OTHER, EbtpLogType.INSERT);
|
||||
@ -274,7 +278,7 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
return bodys;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -472,7 +476,7 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
*/
|
||||
private String getUniBssMessage(String reqName, Map<String, Object> map) {
|
||||
|
||||
UniBss uniBss = new UniBss();
|
||||
CrypUniBss uniBss = new CrypUniBss();
|
||||
uniBss.setUniBssAttached(new UniBssAttached().setMediaInf(""));
|
||||
//天擎部分head
|
||||
UniBssUtil util = new UniBssUtil(app_id, app_secret);
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.shortmessage.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BaseRespVo {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JSONField(name = "code")
|
||||
private String code;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JSONField(name = "msg")
|
||||
private String msg;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JSONField(name = "data")
|
||||
private String data;
|
||||
|
||||
}
|
@ -2,9 +2,11 @@ package com.chinaunicom.mall.ebtp.extend.shortmessage.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
||||
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.BaseRespVo;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.SmsCheckRequest;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.SmsSendRequest;
|
||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.SignUtil;
|
||||
@ -37,6 +39,10 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
||||
private String sendVerifycodeHttpUrl;
|
||||
@Value("${message.checkVerifycodeHttpUrl}")
|
||||
private String checkVerifycodeHttpUrl;
|
||||
@Value("${message.appCode}")
|
||||
private String appCode;
|
||||
@Value("${message.callBackUrl}")
|
||||
private String callBackUrl;
|
||||
@Autowired
|
||||
private ICrypConfigureService iCrypConfigureService;
|
||||
@Autowired(required = false)
|
||||
@ -45,13 +51,14 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
||||
/**
|
||||
* 业务系统私钥,在SignUtil会用到--这里在切换对接环境时会变化,由集团多因素项目项目组提供
|
||||
*/
|
||||
private static final String PRI_KEY = "MHgCAQECIQCQO3m5phHk2I8SwgCIcQVcF5FkyCjnXWc2uRUz2/54N6AKBggqgRzPVQGCLaFEA0IABOnuKDS5zOzu5dW9bk0881GPpJkCMRa7yK4AopUoAzADZqddHqMmWl9VKI9n2qrIcx8rgRuv08tPGvV2Vo7776Q=";
|
||||
private static final String PRI_KEY = "MHgCAQECIQCA7a1i8iMeG0QoNfLYkAaj3IugsHjBGwcQv9/PmXY+cKAKBggqgRzPVQGCLaFEA0IABDBEOwQYJia5S4b5vbWy8YEh1LebhTTB2s2XlQfpjAEP7o8yYgwXWW20sXR+DcOPLwE1qqj9wUWz4zeeiv1+mzk=";
|
||||
|
||||
@Override
|
||||
public Boolean authCodeSend(String mobile) {
|
||||
String id = PropertyUtils.getSnowflakeId();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
String bizSn = "ebtp"+id+"ebtp"+ LocalDate.now().format(formatter);
|
||||
String s=appCode;
|
||||
BizShortMessage shortMessage = new BizShortMessage();
|
||||
shortMessage.setId(id)
|
||||
.setBizsn(bizSn)
|
||||
@ -71,21 +78,23 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
||||
SmsSendRequest smsSendRequest = new SmsSendRequest();
|
||||
//必传参数
|
||||
//应用标识,调用方使用自己的应用标识
|
||||
smsSendRequest.setAppCode("appCode");
|
||||
smsSendRequest.setAppCode(appCode);
|
||||
//流水号,调用方生成,保持唯一
|
||||
smsSendRequest.setBizSn(bizSn);
|
||||
smsSendRequest.setSign(sign);
|
||||
//手机号 未传时使用应用系统账号查询用户手机号
|
||||
smsSendRequest.setMobile(mobile);
|
||||
//用户状态验证回调url
|
||||
smsSendRequest.setCallBackUrl("http://10.124.150.230:8000/api/chinaUnicom/manageCenter/eshop/mobilecheck/v1");
|
||||
smsSendRequest.setCallBackUrl(callBackUrl);
|
||||
CrypBean bean = new CrypBean();
|
||||
bean.setReqName("MESSAGE_SEND_VERIFYCODE_REQ");
|
||||
bean.setUrl(sendVerifycodeHttpUrl);
|
||||
bean.setObject(smsSendRequest);
|
||||
boolean result = iCrypConfigureService.callUniInterfaceMessage(bean);
|
||||
this.saveOrUpdate(shortMessage.setStatus(result?1:2));
|
||||
return result;
|
||||
BaseRespVo result = iCrypConfigureService.callUniInterfaceMessage(bean);
|
||||
this.saveOrUpdate(shortMessage.setStatus(("0".equals(result.getCode()) || "200".equals(result.getCode()) )?1:2));
|
||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR
|
||||
.customValidName(result.getMsg(),!("0".equals(result.getCode()) || "200".equals(result.getCode()) ));
|
||||
return ("0".equals(result.getCode()) || "200".equals(result.getCode()) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,9 +109,9 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
||||
|
||||
//必传参数
|
||||
//应用标识
|
||||
smsCheckRequest.setAppCode(message.getAppcode());
|
||||
smsCheckRequest.setAppCode(appCode);
|
||||
//流水号,使用发送认证短信时的流水号
|
||||
smsCheckRequest.setBizSn(message.getBizsn());
|
||||
smsCheckRequest.setBizSn(value.toString());
|
||||
//生成签名
|
||||
byte[] signByte = SignUtil.sign(PRI_KEY,value.toString().getBytes(StandardCharsets.UTF_8));
|
||||
String sign = com.cuca.bouncycastle.util.encoders.Base64.toBase64String(signByte);
|
||||
@ -112,13 +121,15 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
||||
//验证码,手机收到的验证码
|
||||
smsCheckRequest.setAuthCode(authCode);
|
||||
CrypBean bean = new CrypBean();
|
||||
bean.setReqName("MESSAGE_SEND_VERIFYCODE_REQ");
|
||||
bean.setReqName("MESSAGE_CHECK_VERIFYCODE_REQ");
|
||||
bean.setUrl(checkVerifycodeHttpUrl);
|
||||
bean.setObject(smsCheckRequest);
|
||||
this.saveOrUpdate(message.setStatus(3));
|
||||
boolean result = iCrypConfigureService.callUniInterfaceMessage(bean);
|
||||
this.saveOrUpdate(message.setStatus(result?4:5));
|
||||
return result;
|
||||
BaseRespVo result = iCrypConfigureService.callUniInterfaceMessage(bean);
|
||||
this.saveOrUpdate(message.setStatus(("0".equals(result.getCode()) || "200".equals(result.getCode()) )?4:5));
|
||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR
|
||||
.customValidName(result.getMsg(),!("0".equals(result.getCode()) || "200".equals(result.getCode()) ));
|
||||
return ("0".equals(result.getCode()) || "200".equals(result.getCode()) );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ spring:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: mall
|
||||
password: unicom
|
||||
password: Unicom160_30
|
||||
jdbc-url: jdbc:mysql://10.125.160.30:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://10.125.160.30:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
filters: stat,wall,log4j
|
||||
@ -157,6 +157,21 @@ ribbon:
|
||||
MaxAutoRetriesNextServer: 1 #切换实例的重试次数 1
|
||||
|
||||
mconfig:
|
||||
wps:
|
||||
bssAppId: ue32TUnBeW
|
||||
bssAppSecret: 23Ue8DKUM4VTR5uz9LiADBTI3lbCJPqF
|
||||
bssAppUrl: http://10.124.150.230:8000
|
||||
appid: AK20230531MTEMAF
|
||||
appKey: 4ab670a08faf182d6a99a82cd8a6e05b
|
||||
bss:
|
||||
appTokenUrl: /api/chinaUnicom/manageCenter/documentCenter/apptoken/v1
|
||||
previewUrl: /api/chinaUnicom/manageCenter/documentCenter/previewUrl/v1
|
||||
editUrl: /api/chinaUnicom/manageCenter/documentCenter/webofficeurl/v1
|
||||
url:
|
||||
appTokenUrl: /auth/v1/app/inscope/token
|
||||
previewUrl: /preview/v2/url
|
||||
editUrl: /weboffice/v2/url
|
||||
downFileUrl: http://10.242.31.158:18022/api/doc/v1.0/files/download
|
||||
workerId: 1
|
||||
datacenterId: 1
|
||||
# 服务名
|
||||
@ -182,7 +197,11 @@ mconfig:
|
||||
app-url: 1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS
|
||||
document:
|
||||
clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749
|
||||
|
||||
message:
|
||||
appCode: WEB9849352
|
||||
sendVerifycodeHttpUrl: http://10.124.150.230:8000/api/chinaUnicom/dataMidPlatform/authenticationCenter/messageSendVerifycode/v1
|
||||
checkVerifycodeHttpUrl: http://10.124.150.230:8000/api/chinaUnicom/dataMidPlatform/authenticationCenter/messageCheckVerifycode/v1
|
||||
callBackUrl: http://10.124.150.230:8000/api/chinaUnicom/manageCenter/eshop/mobilecheck/v1
|
||||
# 用户暴露给 prometheus 的健康数据
|
||||
management:
|
||||
endpoints:
|
||||
@ -209,11 +228,11 @@ xxl:
|
||||
|
||||
unifast:
|
||||
sso:
|
||||
public-key: 11
|
||||
clientId: 1
|
||||
redirectUrl: 1
|
||||
public-key: 0428D625CEEB71CE823BD7D78DFEE7B122F2DA5C4D21E32253AD684D0FE21810394A799639C0CDFBFEB535A1DFD6A366A637E582CE0B1466A5FE7858841135DE6B
|
||||
clientId: p6IPukcJ
|
||||
redirectUrl: http://10.125.86.213:18000/redirect
|
||||
getCode:
|
||||
url: 1
|
||||
url: http://10.125.86.213:18808/outer/v1.0/sso/decide
|
||||
|
||||
|
||||
client:
|
||||
@ -221,4 +240,15 @@ client:
|
||||
allow:
|
||||
apis:
|
||||
- ^GET\./?v1/send/msg/interest/getcode$
|
||||
- ^POST\./?v1/send/msg/interest/code$
|
||||
- ^POST\./?v1/send/msg/interest/code$
|
||||
- ^POST\./?v1/bizshortmessage/send/authCode$
|
||||
- ^POST\./?v1/bizshortmessage/check/authCode$
|
||||
|
||||
|
||||
oss:
|
||||
endpoint: oss-cn-guangzhou-gz-d01-a.ops.super.guangzhou.unicom.local
|
||||
accessKeyId: wikrNkei48gp4buV
|
||||
accessKeySecret: LD8jDhf0qow4iel8vO7wno6bp4ZM7q
|
||||
# accessKeyId: ENC(F3Coanx/L2UF6XjF4Uk7yp/UvkNhAlEDzLsCoBKCStBSsCZNjnzvQhpg28NUvCdG71MJZZbwCoCG5j6R7XX13A==)
|
||||
# accessKeySecret: ENC(QBot3xocahGOFoGM8G7G998htTLPrbLzWa2ud05MdD6hAKPUpFAmbewui8wngQglGvZKbc8Uz+K8TpHJdSJtqw==)
|
||||
bucketName: test-mall3
|
Reference in New Issue
Block a user