|
@@ -127,7 +127,12 @@ struct TimeSynTask : ITaskSp
|
|
|
pEvent->param1 = AccessAuthorization_UserErrorCode_AccessAuth_NULL;
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
CSimpleStringA strMsg(true);
|
|
|
- strMsg = CSimpleStringA::Format("准入服务地址为空,请下载集中配置或重启应用");
|
|
|
+ if (!m_fsm->IsCenterSettingFilesExist()) {
|
|
|
+ strMsg = CSimpleStringA::Format("集中配置文件不存在,请下载集中配置后重启应用");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strMsg = CSimpleStringA::Format("准入服务地址为空,请下载集中配置或重启应用");
|
|
|
+ }
|
|
|
m_fsm->doWarnMsg(AccessAuthorization_UserErrorCode_AccessAuth_NULL, strMsg.GetData(), true);
|
|
|
return;
|
|
|
}
|
|
@@ -143,6 +148,7 @@ struct TimeSynTask : ITaskSp
|
|
|
timeSynReq.terminalNo = si.strTerminalID.GetData();
|
|
|
timeSynReq.curTime = CSmallDateTime::GetNow().GetTime64();
|
|
|
timeSynReq.m_url = m_fsm->GetmAccessAuthHost();
|
|
|
+ //timeSynReq.m_url += "/api/v2/sessionkey";
|
|
|
timeSynReq.m_url += "/api/v3/sessionkey";//v3 新接口,返回title、content
|
|
|
long beg = GetTickCount();
|
|
|
bool ret = client->Post(timeSynReq, timeSynRet);
|
|
@@ -269,6 +275,8 @@ struct TimeSynTask : ITaskSp
|
|
|
LogWarn(Severity_Low, Error_Debug, ERROR_ACCESSAUTH_ACS_DIGINFO, errDetail.c_str());
|
|
|
}
|
|
|
}
|
|
|
+ /*m_fsm->doWarnMsg(ERROR_ACCESSAUTH_CONNECT_ACS,
|
|
|
+ GetOutPutStr("%s%s", "连接总行ACS准入服务失败(TimeSynTask).", result.WhatError().c_str()).c_str(), true);*/
|
|
|
m_fsm->AuthLogWarn(result, config.GetRequestUri(), "获取会话密钥");
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("TimeSynTask Connect Failed.");
|
|
|
|
|
@@ -302,11 +310,41 @@ struct UpdateWKTask : ITaskSp
|
|
|
CAccessAuthUpdateWKReq updateWKReq;
|
|
|
updateWKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();//first是加密的,seconde是没加密的
|
|
|
-
|
|
|
updateWKReq.encRandom = tmkpair.first;
|
|
|
+
|
|
|
+ PinPadService_ClientBase* pPinPad = new PinPadService_ClientBase(this->m_entity);
|
|
|
+ auto errRc = pPinPad->Connect();
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ PinPadService_GetCheckCode_Req req = {};
|
|
|
+ PinPadService_GetCheckCode_Ans ans = {};
|
|
|
+
|
|
|
+ req.mSN.Init(1);
|
|
|
+ req.wSN.Init(1);
|
|
|
+ req.mSN[0] = 1;
|
|
|
+ req.wSN[0] = 0;
|
|
|
+ errRc = (*pPinPad)(EntityResource::getLink().upgradeLink())->GetCheckCode(req, ans, 10000);
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
+ updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ pPinPad->GetFunction()->CloseSession();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ }
|
|
|
+
|
|
|
CAccessAuthUpdateWKRet updateWKRet;
|
|
|
updateWKReq.m_url = m_fsm->GetmAccessAuthHost();
|
|
|
- updateWKReq.m_url += "/api/v3/wkupdate";
|
|
|
+ updateWKReq.m_url += "/api/v5/wkupdate";
|
|
|
long beg = GetTickCount();
|
|
|
bool ret = client->Post(updateWKReq, updateWKRet);
|
|
|
long end = GetTickCount();
|
|
@@ -327,7 +365,7 @@ struct UpdateWKTask : ITaskSp
|
|
|
|
|
|
|
|
|
ErrorCodeEnum eLoadErr = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKRet.tpk,
|
|
|
- updateWKRet.edk, updateWKRet.index);
|
|
|
+ updateWKRet.edk, updateWKRet.keyIndex);
|
|
|
if (eLoadErr == Error_Succeed) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("LoadKeysToPinPadNew")
|
|
|
("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
@@ -336,7 +374,7 @@ struct UpdateWKTask : ITaskSp
|
|
|
}
|
|
|
else {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("LoadKeysToPinPadNew")
|
|
|
- ("UpdateWKTask 加载秘钥到密码键盘失败,请检查密码键盘连接状态. error = %08X", eLoadErr);
|
|
|
+ ("UpdateWKTask LoadKeysToPinPadNew error = %08X", eLoadErr);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -356,9 +394,12 @@ struct UpdateWKTask : ITaskSp
|
|
|
#else
|
|
|
struct UpdateWKReq
|
|
|
{
|
|
|
- std::string terminalNo;
|
|
|
- std::string encRandom;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom)
|
|
|
+ string terminalNo;
|
|
|
+ string encRandom;
|
|
|
+ string tpkKeyCheck; //tpk密钥校验值
|
|
|
+ string edkKeyCheck; //edk密钥校验值
|
|
|
+ string keyIndex; //密钥序号
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
} updateWKReq;
|
|
|
|
|
|
struct UpdateWKAns
|
|
@@ -366,17 +407,49 @@ struct UpdateWKTask : ITaskSp
|
|
|
string tmk;
|
|
|
string tpk;
|
|
|
string edk;
|
|
|
- string index;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, index)
|
|
|
+ string tpkKeyCheck; //密钥校验值
|
|
|
+ string edkKeyCheck; //edk密钥校验值
|
|
|
+ string keyIndex; //密钥序号
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
} updateWKAns;
|
|
|
|
|
|
updateWKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();//first是加密的,seconde是没加密的
|
|
|
updateWKReq.encRandom = tmkpair.first;
|
|
|
|
|
|
+ PinPadService_ClientBase* pPinPad = new PinPadService_ClientBase(this->m_entity);
|
|
|
+ auto errRc = pPinPad->Connect();
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ PinPadService_GetCheckCode_Req req = {};
|
|
|
+ PinPadService_GetCheckCode_Ans ans = {};
|
|
|
+
|
|
|
+ req.mSN.Init(1);
|
|
|
+ req.wSN.Init(1);
|
|
|
+ req.mSN[0] = 1;
|
|
|
+ req.wSN[0] = 0;
|
|
|
+ errRc = (*pPinPad)(EntityResource::getLink().upgradeLink())->GetCheckCode(req, ans, 10000);
|
|
|
+ if (errRc == Error_Succeed)
|
|
|
+ {
|
|
|
+ updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
+ updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ pPinPad->GetFunction()->CloseSession();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ }
|
|
|
+
|
|
|
HttpClientResponseResult result;
|
|
|
HttpClientRequestConfig config(HttpRequestMethod::POST, m_fsm->GetmAccessAuthHost().GetData());
|
|
|
- config.SetChildUri("/api/v3/wkupdate");
|
|
|
+ config.SetChildUri("/api/v5/wkupdate");
|
|
|
|
|
|
SP::Module::Restful::FulfillRequestJsonBody(&config, updateWKReq);
|
|
|
|
|
@@ -401,15 +474,19 @@ struct UpdateWKTask : ITaskSp
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tmk=%s %d", updateWKAns.tmk.c_str(), updateWKAns.tmk.size());
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpk=%s %d", updateWKAns.tpk.c_str(), updateWKAns.tpk.size());
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edk=%s %d", updateWKAns.edk.c_str(), updateWKAns.edk.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("index=%s %d", updateWKAns.index.c_str(), updateWKAns.index.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpkKeyCheck=%s %d", updateWKAns.tpkKeyCheck.c_str(), updateWKAns.tpkKeyCheck.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edkKeyCheck=%s %d", updateWKAns.edkKeyCheck.c_str(), updateWKAns.edkKeyCheck.size());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("index=%s %d", updateWKAns.keyIndex.c_str(), updateWKAns.keyIndex.size());
|
|
|
|
|
|
- DWORD rc = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKAns.tpk, updateWKAns.edk, updateWKAns.index);
|
|
|
+ DWORD rc = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKAns.tpk, updateWKAns.edk, updateWKAns.keyIndex);
|
|
|
if (rc == Error_Succeed) {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
|
+ /*FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_UpdateWKSucc);
|
|
|
+ m_fsm->PostEventFIFO(pEvent);*/
|
|
|
return;
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask 加载秘钥到密码键盘失败,请检查密码键盘连接状态. error = %08X", rc);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask LoadKeysToPinPadNew error = %08X", rc);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -420,6 +497,7 @@ struct UpdateWKTask : ITaskSp
|
|
|
|
|
|
UpdateWKRetError:
|
|
|
|
|
|
+ //FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_UpdateWKFail);
|
|
|
FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_ReqTokenCancel);
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
#endif // RVC_OS_WIN
|
|
@@ -441,7 +519,12 @@ struct GetTokenTask : ITaskSp
|
|
|
pEvent->param1 = AccessAuthorization_UserErrorCode_AccessAuth_NULL;
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
CSimpleStringA strMsg(true);
|
|
|
- strMsg = CSimpleStringA::Format("准入服务地址为空,请下载集中配置或尝试重启应用");
|
|
|
+ if (!m_fsm->IsCenterSettingFilesExist()) {
|
|
|
+ strMsg = CSimpleStringA::Format("集中配置文件不存在,请下载集中配置后重启应用");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strMsg = CSimpleStringA::Format("准入服务地址为空,请下载集中配置或尝试重启应用");
|
|
|
+ }
|
|
|
m_fsm->doWarnMsg(AccessAuthorization_UserErrorCode_AccessAuth_NULL, strMsg.GetData(), true);
|
|
|
return;
|
|
|
}
|
|
@@ -460,6 +543,7 @@ struct GetTokenTask : ITaskSp
|
|
|
|
|
|
CAccessAuthGetTokenRet getTokenRet;
|
|
|
getTokenReq.m_url = m_fsm->GetmAccessAuthHost();
|
|
|
+ //getTokenReq.m_url += "/api/v2/access";
|
|
|
getTokenReq.m_url += "/api/v3/access"; //v3新接口,返回title,content
|
|
|
|
|
|
long beg = GetTickCount();
|
|
@@ -585,6 +669,10 @@ struct GetTokenTask : ITaskSp
|
|
|
SP::Module::Restful::CommResponseJson responseStatus;
|
|
|
SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);
|
|
|
if (!responseStatus.IsOperatedOK()) {
|
|
|
+ /*m_fsm->doWarnMsg(ERR_ACCESSAUTH_LOCK_STATE,
|
|
|
+ GetOutPutStr("%s%s%s%s", "GetTokenTask", responseStatus.errorCode.c_str(),
|
|
|
+ "message", responseStatus.errorMsg.c_str()).c_str(), true);*/
|
|
|
+
|
|
|
m_fsm->AuthLogWarn(result, config.GetRequestUri(), "获取准入token");
|
|
|
return;
|
|
|
}
|
|
@@ -636,6 +724,8 @@ struct GetTokenTask : ITaskSp
|
|
|
LogWarn(Severity_Low, Error_Debug, ERROR_ACCESSAUTH_ACS_DIGINFO, errDetail.c_str());
|
|
|
}
|
|
|
}
|
|
|
+ /*m_fsm->doWarnMsg(ERROR_ACCESSAUTH_CONNECT_ACS,
|
|
|
+ GetOutPutStr("%s%s", "连接总行ACS准入服务失败(GetTokenTask).", result.WhatError().c_str()).c_str(), true);*/
|
|
|
|
|
|
m_fsm->AuthLogWarn(result, config.GetRequestUri(), "获取准入token");
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTokenTask Connect Failed.");
|
|
@@ -802,7 +892,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
|
|
|
auto pEntity = (CAccessAuthEntity*)m_pEntity;
|
|
|
if (pEvent->param1 == AccessAuthorization_UserErrorCode_AccessAuth_NULL)
|
|
|
{
|
|
|
- CSimpleStringA strMsg = CSimpleStringA::Format("准入Url为空");
|
|
|
+ CSimpleStringA strMsg = CSimpleStringA::Format("准入Url为空,集中配置文件:%s", IsCenterSettingFilesExist() ? "存在" : "不存在");
|
|
|
pEntity->SetAuthErrMsg(strMsg);
|
|
|
}
|
|
|
else if (pEvent->param1 == AccessAuthorization_UserErrorCode_ACS_FAIL)
|
|
@@ -1402,6 +1492,8 @@ void CAccessAuthFSM::UpdateWK()
|
|
|
CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
bool bHasPinPad = false;
|
|
|
pEntity->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, bHasPinPad);
|
|
|
+ //int capability = pEntity->GetPinPadCapability();
|
|
|
+ //Dbg("GetPinPadCapability:%d", capability);
|
|
|
if (bHasPinPad) {
|
|
|
CSmartPointer<UpdateWKTask> updateWKTask = new UpdateWKTask(this, pEntity);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(updateWKTask.GetRawPointer());
|
|
@@ -1441,6 +1533,17 @@ void CAccessAuthFSM::GetDiffSyncTimeFromCenterSettings()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+BOOL CAccessAuthFSM::IsCenterSettingFilesExist()
|
|
|
+{
|
|
|
+ BOOL result(FALSE);
|
|
|
+ CSimpleStringA strPath;
|
|
|
+ GetEntityBase()->GetFunction()->GetPath("CenterSetting", strPath);
|
|
|
+ if (!strPath.IsNullOrEmpty() && ExistsFileA(strPath)) {
|
|
|
+ result = TRUE;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
template<class T>
|
|
|
void CAccessAuthFSM::AuthLogWarn(const T& ret, const string& url, const string& method, bool bNeedEvent)
|
|
|
{
|
|
@@ -1491,7 +1594,72 @@ void CAccessAuthFSM::AuthLogWarn(const T& ret, const string& url, const string&
|
|
|
void CAccessAuthFSM::GetNetMsg(SpReqAnsContext<AccessAuthService_GetNetMsg_Req, AccessAuthService_GetNetMsg_Ans>::Pointer& ctx)
|
|
|
{
|
|
|
CSimpleStringA tmp;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
ctx->Ans.netStatus = 1; //成功
|
|
|
+#else
|
|
|
+ ErrorCodeEnum ec = Error_Succeed;
|
|
|
+ int netType = 0; //默认未知
|
|
|
+
|
|
|
+ CSimpleStringA tmpVendor(""), tmpDevSN(""), tmpDLLVersion("");
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBVendor", tmpVendor);
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBDevSN", tmpDevSN);
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("FWBVersion", tmpDLLVersion);
|
|
|
+
|
|
|
+
|
|
|
+ if (tmpDLLVersion.GetLength() < 2)
|
|
|
+ tmpDLLVersion = "8.1";
|
|
|
+ if (tmpDevSN.GetLength() > 12 && tmpDevSN.IndexOf("FWB") > 2)
|
|
|
+ {
|
|
|
+ Dbg("This is fwb device.");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int i = 0;
|
|
|
+ int sockfd;
|
|
|
+ struct ifconf ifconf;
|
|
|
+ struct ifreq* ifreq;
|
|
|
+ char buf[1024];
|
|
|
+
|
|
|
+ //初始化ifconf
|
|
|
+ ifconf.ifc_len = 1024;
|
|
|
+ ifconf.ifc_buf = buf;
|
|
|
|
|
|
+ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
+ {
|
|
|
+ perror("socket error");
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有接口信息
|
|
|
+ ioctl(sockfd, SIOCGIFCONF, &ifconf);
|
|
|
+
|
|
|
+ //逐个获取Ip地址
|
|
|
+ int size = ifconf.ifc_len / sizeof(struct ifreq);
|
|
|
+ ifreq = (struct ifreq*)buf;
|
|
|
+ string netName(ifreq->ifr_name);
|
|
|
+
|
|
|
+ if (size == 1 && netName == "lo") //只有逻辑地址 -- 网线被拔出
|
|
|
+ {
|
|
|
+ netType = 0;
|
|
|
+ tmp = "无网络";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (i = size; i > 0; i--)
|
|
|
+ {
|
|
|
+ string netName(ifreq->ifr_name); //有其他网卡 -- 有线
|
|
|
+ if (netName != "lo")
|
|
|
+ {
|
|
|
+ netType = 1;
|
|
|
+ tmp = "网络已连接";
|
|
|
+ }
|
|
|
+ ifreq++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx->Ans.netStatus = netType;
|
|
|
+ }
|
|
|
+ ctx->Ans.netMsg = tmp;
|
|
|
+#endif // RVC_OS_WIN
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|