|
@@ -8,7 +8,6 @@
|
|
|
#include "fileutil.h"
|
|
|
#include "iniutil.h"
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
-#include "CommEntityRestful.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
#include "comm.h"
|
|
|
#include "PinPad_client_g.h"
|
|
@@ -133,20 +132,8 @@ struct TimeSynTask : ITaskSp
|
|
|
CSystemStaticInfo si;
|
|
|
m_fsm->GetEntityBase()->GetFunction()->GetSystemStaticInfo(si);
|
|
|
|
|
|
- struct TimeSynReqStructJson
|
|
|
- {
|
|
|
- std::string terminalNo;
|
|
|
- int curTime;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, curTime)
|
|
|
- } timeSyncReq;
|
|
|
- struct TimeSyncAnsStructJson
|
|
|
- {
|
|
|
- int timeDiff;
|
|
|
- int authVersion;
|
|
|
- std::string sessionKey;
|
|
|
- std::string reserved;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(timeDiff, authVersion, sessionKey, reserved)
|
|
|
- }timeSyncAns;
|
|
|
+ CSessionkeySynReq timeSyncReq;
|
|
|
+ CSessionkeySynAns timeSyncAns;
|
|
|
|
|
|
timeSyncReq.terminalNo = si.strTerminalID.GetData();
|
|
|
timeSyncReq.curTime = CSmallDateTime::GetNow().GetTime64();
|
|
@@ -269,26 +256,8 @@ struct UpdateWKTask : ITaskSp
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- struct UpdateWKReq
|
|
|
- {
|
|
|
- std::string terminalNo;
|
|
|
- std::string encRandom;
|
|
|
- string tpkKeyCheck; //tpk密钥校验值
|
|
|
- string edkKeyCheck; //edk密钥校验值
|
|
|
- string keyIndex; //密钥序号
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
- } updateWKReq;
|
|
|
-
|
|
|
- struct UpdateWKAns
|
|
|
- {
|
|
|
- string tmk;
|
|
|
- string tpk;
|
|
|
- string edk;
|
|
|
- string tpkKeyCheck; //密钥校验值
|
|
|
- string edkKeyCheck; //edk密钥校验值
|
|
|
- string keyIndex; //密钥序号
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
- } updateWKAns;
|
|
|
+ CAccessAuthUpdateWKReq updateWKReq;
|
|
|
+ CAccessAuthUpdateWKAns updateWKAns;
|
|
|
|
|
|
updateWKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();//first是加密的,seconde是没加密的
|
|
@@ -397,42 +366,7 @@ struct GetTokenTask : ITaskSp
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- struct GetTokenReq
|
|
|
- {
|
|
|
- string installVersion;//终端版本(新加字段)
|
|
|
- string terminalCharacter;
|
|
|
- string terminalNo;
|
|
|
- string sessionTempPubKey;
|
|
|
- string encTerminalInfo;
|
|
|
- string publicKeySM;
|
|
|
- string pinPadID;
|
|
|
- string existPinPad;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(installVersion, terminalCharacter, terminalNo,
|
|
|
- sessionTempPubKey, encTerminalInfo, publicKeySM, pinPadID, existPinPad)
|
|
|
- } getTokenReqJson;
|
|
|
-
|
|
|
- struct AccessTokenJson
|
|
|
- {
|
|
|
- string enToken;
|
|
|
- string retHash;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(enToken, retHash)
|
|
|
- };
|
|
|
- struct SharedKeyJson
|
|
|
- {
|
|
|
- string enToken;
|
|
|
- string sharedSK;
|
|
|
- string retHash;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(enToken, sharedSK, retHash)
|
|
|
- };
|
|
|
-
|
|
|
- struct GetTokenAns
|
|
|
- {
|
|
|
- AccessTokenJson accessToken;
|
|
|
- SharedKeyJson sharedKey;
|
|
|
- bool flag;
|
|
|
- string warnMessage;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(accessToken, sharedKey, flag, warnMessage)
|
|
|
- } getTokenAns;
|
|
|
+ CAccessAuthGetTokenAns getTokenAns;
|
|
|
|
|
|
HttpClientResponseResult result;
|
|
|
HttpClientRequestConfig config(HttpRequestMethod::POST, m_fsm->GetmAccessAuthHost().GetData(), &SpGetToken);
|
|
@@ -450,17 +384,7 @@ struct GetTokenTask : ITaskSp
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- getTokenReqJson.installVersion = getTokenReq.installVersion;
|
|
|
- getTokenReqJson.terminalCharacter = getTokenReq.terminalCharacter;
|
|
|
- getTokenReqJson.terminalNo = getTokenReq.terminalNo;
|
|
|
- getTokenReqJson.sessionTempPubKey = getTokenReq.sessionTempPubKey;
|
|
|
- getTokenReqJson.encTerminalInfo = getTokenReq.encTerminalInfo;
|
|
|
- getTokenReqJson.publicKeySM = getTokenReq.publicKeySM;
|
|
|
- getTokenReqJson.pinPadID = getTokenReq.pinPadID;
|
|
|
- getTokenReqJson.existPinPad = getTokenReq.existPinPad;
|
|
|
-
|
|
|
-
|
|
|
- SP::Module::Restful::FulfillRequestJsonBody(&config, getTokenReqJson);
|
|
|
+ SP::Module::Restful::FulfillRequestJsonBody(&config, getTokenReq);
|
|
|
|
|
|
std::string test;
|
|
|
test = config.GetRequestUri();
|
|
@@ -531,18 +455,6 @@ struct GetTokenTask : ITaskSp
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-struct InitDeviceTask :public ITaskSp
|
|
|
-{
|
|
|
- CAccessAuthFSM* m_fsm;
|
|
|
- InitDeviceReq m_req;
|
|
|
- InitDeviceTask(CAccessAuthFSM* fsm, InitDeviceReq req) :m_fsm(fsm), m_req(req) {}
|
|
|
-
|
|
|
- void Process()
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
bool isChineseChar(const char* p) {
|
|
@@ -902,112 +814,45 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
+DWORD CAccessAuthFSM::GetEncTerminalInfoWithKey(CBlob& encInfo, BYTE* key)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- RequestTokenReq1 req1;
|
|
|
- memset(&req1, 0, sizeof(req1));
|
|
|
- BYTE* pBuf = (BYTE*)&req1.encTerminalInfo;
|
|
|
-
|
|
|
- // 设置长度
|
|
|
- sprintf((char*)pBuf, "%.4d", sizeof(RequestTokenInfo));
|
|
|
-
|
|
|
- RequestTokenInfo* pInfo = (RequestTokenInfo*)(pBuf + 4);
|
|
|
-
|
|
|
- CSystemStaticInfo si;
|
|
|
- m_pEntity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
- strncpy(pInfo->szTerminalNo, (const char*)si.strTerminalID, sizeof(pInfo->szTerminalNo) - 1);
|
|
|
-
|
|
|
- CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
- bool isPinPadMac = false, bPinPadOnline = false;
|
|
|
- int nRet = ((CAccessAuthEntity*)m_pEntity)->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, isPinPadMac, bPinPadOnline);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPinPadIDAndDeviceID ret: %d, PinPadID: %s, DeviceID: %s", nRet, strPinPadID.GetData(), strDeviceID.GetData());
|
|
|
- if (nRet == 2 || nRet == 3) {
|
|
|
- strncpy(pInfo->szPadDeviceID, (const char*)strDeviceID, sizeof(pInfo->szPadDeviceID) - 1);
|
|
|
- }
|
|
|
-
|
|
|
- strncpy(pInfo->szMachineType, (const char*)si.strMachineType, sizeof(pInfo->szMachineType) - 1);
|
|
|
-
|
|
|
- // 设备版本,低两位为小版本号,高两位为大版本号 Binary 4
|
|
|
- DWORD ver32 = si.MachineVersion.GetVersion32();
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
- pInfo->machineVersion[3 - i] = ((BYTE*)&ver32)[i];
|
|
|
- }
|
|
|
-
|
|
|
- // 安装版本,其中包含软件框架版本 binary 8
|
|
|
- __int64 ver64 = si.InstallVersion.GetVersion64();
|
|
|
- for (int i = 0; i < 8; i++) {
|
|
|
- pInfo->installVersion[7 - i] = ((BYTE*)&ver64)[i];
|
|
|
- }
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- hostent* ent = gethostbyname(NULL);
|
|
|
- if (ent && ent->h_addr_list[0] != NULL) {
|
|
|
- int i = 0;
|
|
|
- for (; ent->h_addr_list[i] != NULL; ++i) {
|
|
|
- struct in_addr* in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
- //99开头行内办公网,10开头行内业务网。规范出自《招商银行总行网络规范汇编(2017年版).pdf》
|
|
|
- if (in->S_un.S_un_b.s_b1 == 99 || in->S_un.S_un_b.s_b1 == 10)
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (ent->h_addr_list[i] == NULL)
|
|
|
- i = 0;
|
|
|
-
|
|
|
- auto in = (struct in_addr*)ent->h_addr_list[i];
|
|
|
+ ErrorCodeEnum rc = Error_Succeed;
|
|
|
+ CSimpleStringA ip, mac, pinpadModel, cpuId, mainBoardId, hardDiskId, osType, osVersion;
|
|
|
+ std::map<std::string, std::string> termInfo;
|
|
|
+
|
|
|
+ auto pEntity = ((CAccessAuthEntity*)m_pEntity);
|
|
|
+ CSimpleStringA strPinPadModel = "";
|
|
|
+ bool bPinPadOnline = false;
|
|
|
+ pEntity->GetPinPadModel(strPinPadModel, bPinPadOnline);
|
|
|
+
|
|
|
+ GetIPandMac(ip, mac);
|
|
|
+ GetHardWareInfo(cpuId, mainBoardId, hardDiskId);
|
|
|
+
|
|
|
+ osVersion = GetOsVersion();
|
|
|
|
|
|
- pInfo->ip[0] = in->S_un.S_un_b.s_b1;
|
|
|
- pInfo->ip[1] = in->S_un.S_un_b.s_b2;
|
|
|
- pInfo->ip[2] = in->S_un.S_un_b.s_b3;
|
|
|
- pInfo->ip[3] = in->S_un.S_un_b.s_b4;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ip:%d.%d.%d.%d", pInfo->ip[0], pInfo->ip[1], pInfo->ip[2], pInfo->ip[3]);
|
|
|
- }
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ termInfo["OSType"] = "Windows";
|
|
|
#else
|
|
|
- char ip[32] = { 0 };
|
|
|
- if (getIPFromLinux(ip)) DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Get IP From Linux Error ex.");
|
|
|
- else {
|
|
|
- if (ip2byte(ip, pInfo->ip)) DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Ip 2 Byte Error");
|
|
|
- else {
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ip[%d]=%d", i, (int)pInfo->ip[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-#endif //#ifdef RVC_OS_WIN
|
|
|
- strncpy(pInfo->szSites, si.strSite, sizeof(pInfo->szSites) - 1);
|
|
|
-
|
|
|
- si.EnrolGPS.GetBinaryLongitude(&pInfo->currentGPS[0]);
|
|
|
- si.EnrolGPS.GetBinaryLatitude(&pInfo->currentGPS[4]);
|
|
|
-
|
|
|
- CSimpleStringA ts;
|
|
|
- DWORD rc = m_pEntity->GetFunction()->GetSysVar("TerminalStage", ts);
|
|
|
- if (rc != Error_Succeed)
|
|
|
- {
|
|
|
- string outStr = GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "TerminalStage", ts.GetData());
|
|
|
- doWarnMsg(ERR_ACCESSAUTH_GET_SYS_VAR, outStr.c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(outStr.c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_SYS_VAR;
|
|
|
- }
|
|
|
- assert(ts.GetLength() >= 1);
|
|
|
- pInfo->chTerminalState = ts[0];
|
|
|
+ termInfo["OSType"] = "UOS";
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+ termInfo["osVersion"] = osVersion.GetData();
|
|
|
+ termInfo["ip"] = ip.GetData();
|
|
|
+ termInfo["mac"] = mac.GetData();
|
|
|
+ termInfo["cpuId"] = cpuId.GetData();
|
|
|
+ termInfo["mainBoardId"] = mainBoardId.GetData();
|
|
|
+ termInfo["hardDiskId"] = hardDiskId.GetData();
|
|
|
|
|
|
- CSimpleStringA rs;
|
|
|
- rc = m_pEntity->GetFunction()->GetSysVar("RunState", rs);
|
|
|
- if (rc != Error_Succeed)
|
|
|
- {
|
|
|
- string outStr = GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "RunState", rs.GetData());
|
|
|
- doWarnMsg(ERR_ACCESSAUTH_GET_SYS_VAR, outStr.c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(outStr.c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_SYS_VAR;
|
|
|
- }
|
|
|
- assert(rs.GetLength() >= 1);
|
|
|
- pInfo->chRunState = rs[0];
|
|
|
+ std::pair<bool, std::string> strResult;
|
|
|
+ strResult = generateJsonStr(termInfo);
|
|
|
|
|
|
+ char* pBuf = new char[2048];
|
|
|
+ strcpy(pBuf, strResult.second.c_str());
|
|
|
+ int len = strResult.second.size();
|
|
|
|
|
|
CBlob raw;
|
|
|
- auto pEntity = ((CAccessAuthEntity*)m_pEntity);
|
|
|
- // 使用会话密钥加密
|
|
|
- raw.Refer(pBuf, sizeof(RequestTokenInfo) + 4);
|
|
|
- rc = pEntity->EncryptDataWithSessionKey(raw, encInfo);
|
|
|
+ raw.Refer(pBuf, len);
|
|
|
+ rc = pEntity->EncryptDataWithKey(raw, encInfo, key);
|
|
|
|
|
|
if (rc != Error_Succeed)
|
|
|
{
|
|
@@ -1057,26 +902,14 @@ DWORD CAccessAuthFSM::GetTokenReq(CAccessAuthGetTokenReq* getTokenReq)
|
|
|
CSystemStaticInfo si;
|
|
|
pEntity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
|
|
|
- getTokenReq->installVersion = si.InstallVersion.ToString();
|
|
|
-
|
|
|
- BYTE fingerPrint[32] = { 0 };
|
|
|
- int nBufLen = sizeof(fingerPrint);
|
|
|
- if (!pEntity->GetTerminalFingerPrint(fingerPrint, nBufLen))
|
|
|
- {
|
|
|
- doWarnMsg(ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
- GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5203")
|
|
|
- (GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT;
|
|
|
- }
|
|
|
- char tmp[256] = { 0 };
|
|
|
- char* fingerPrintHex = Str2Hex((char*)fingerPrint, 64);
|
|
|
- memcpy(tmp, fingerPrintHex, 64);
|
|
|
- getTokenReq->terminalCharacter = tmp;
|
|
|
- delete fingerPrintHex;
|
|
|
+ getTokenReq->terminalVersion = si.InstallVersion.ToString();
|
|
|
+ getTokenReq->terminalNo = si.strTerminalID.GetData();
|
|
|
|
|
|
CBlob encInfo;
|
|
|
- if ((rc = GetEncTerminalInfo(encInfo)) != Error_Succeed)
|
|
|
+ // 使用会话密钥加密
|
|
|
+ char sessionKey[KEY_SIZE] = { 0 };
|
|
|
+ memcpy(sessionKey, pEntity->m_AuthSessionKey, KEY_SIZE);
|
|
|
+ if ((rc = GetEncTerminalInfoWithKey(encInfo, (BYTE*)sessionKey)) != Error_Succeed)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetEncTerminalInfo failed:%d", rc);
|
|
|
return rc;
|
|
@@ -1084,23 +917,14 @@ DWORD CAccessAuthFSM::GetTokenReq(CAccessAuthGetTokenReq* getTokenReq)
|
|
|
char* pTmp = Str2Hex((char*)encInfo.m_pData, encInfo.m_iLength);
|
|
|
getTokenReq->encTerminalInfo = pTmp;
|
|
|
delete pTmp;
|
|
|
- getTokenReq->terminalNo = si.strTerminalID.GetData();
|
|
|
- string tmpStr = "";
|
|
|
- if ((rc = GetTmk(tmpStr)) != Error_Succeed) return rc;
|
|
|
- getTokenReq->sessionTempPubKey = tmpStr;
|
|
|
|
|
|
- CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
- bool isPinPadMac = false, bPinPadOnline = false;
|
|
|
- int nRet = ((CAccessAuthEntity*)m_pEntity)->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, isPinPadMac, bPinPadOnline);
|
|
|
- getTokenReq->pinPadID = strPinPadID.GetData();
|
|
|
- if (pEntity->HasPinPad())
|
|
|
- {
|
|
|
- getTokenReq->existPinPad = "1";
|
|
|
- }
|
|
|
- else
|
|
|
+ string tmpStr = "";
|
|
|
+ if ((rc = GetTmk(tmpStr)) != Error_Succeed)
|
|
|
{
|
|
|
- getTokenReq->existPinPad = "0";
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTmk failed:%d", rc);
|
|
|
+ return rc;
|
|
|
}
|
|
|
+ getTokenReq->sessionTempPubKey = tmpStr;
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
@@ -1108,9 +932,9 @@ void CAccessAuthFSM::UpdateWK()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
auto pEntity = ((CAccessAuthEntity*)m_pEntity);
|
|
|
- CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
- bool isPinPadMac = false, bPinPadOnline = false;
|
|
|
- pEntity->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, isPinPadMac, bPinPadOnline);
|
|
|
+ CSimpleStringA strPinPadModel = "";
|
|
|
+ bool bPinPadOnline = false;
|
|
|
+ pEntity->GetPinPadModel(strPinPadModel, bPinPadOnline);
|
|
|
if (bPinPadOnline) {
|
|
|
CSmartPointer<UpdateWKTask> updateWKTask = new UpdateWKTask(this, pEntity);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(updateWKTask.GetRawPointer());
|
|
@@ -1258,7 +1082,7 @@ void CAccessAuthFSM::GetIPandMac(CSimpleStringA& ip, CSimpleStringA& mac)
|
|
|
void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & mainBoard, CSimpleStringA & disk)
|
|
|
{
|
|
|
auto pEntity = (CAccessAuthEntity*)m_pEntity;
|
|
|
-
|
|
|
+ std::map<std::string, std::string> errInfo;
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
char szTmp[1024] = {};
|
|
|
string strTmp;
|
|
@@ -1274,8 +1098,15 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
return;
|
|
|
}
|
|
|
runInfoPath += SPLIT_SLASH_STR "runcfg";
|
|
|
+
|
|
|
+ //CPU
|
|
|
if (!get_cpu_id_by_system(strTmp, runInfoPath.GetData()))
|
|
|
{
|
|
|
+ errInfo["errcode"] = "RTA5213";
|
|
|
+ errInfo["msg"] = "调用系统api获取CPU序号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ cpu = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
strErrMsg = CSimpleStringA::Format("查询CPU ID失败,请重启机器并重新初始化");
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1285,12 +1116,18 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
(GetOutPutStr("%s%s", "Processor", "False").c_str());
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
cpu = strTmp.c_str();
|
|
|
strRet = strTmp.c_str();
|
|
|
strTmp.clear();
|
|
|
+
|
|
|
+ //主板
|
|
|
if (!get_board_serial_by_system(strTmp, runInfoPath.GetData()))
|
|
|
{
|
|
|
+ errInfo["errcode"] = "RTA5214";
|
|
|
+ errInfo["msg"] = "调用系统api获取主板ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ mainBoard = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
strErrMsg = CSimpleStringA::Format("查询主板序列号失败, 请重启机器并重新初始化");
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1300,14 +1137,20 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
(GetOutPutStr("%s%s", "BaseBoard", "False").c_str());
|
|
|
return;
|
|
|
}
|
|
|
- strRet += "|";
|
|
|
-
|
|
|
mainBoard = strTmp.c_str();
|
|
|
+ strRet += "|";
|
|
|
strRet += strTmp.c_str();
|
|
|
+
|
|
|
+ //硬盘
|
|
|
vector<string> diskArr;
|
|
|
int errCode = 0;
|
|
|
if (!get_disk_serial_by_system(diskArr, errCode, runInfoPath.GetData()))
|
|
|
{
|
|
|
+ errInfo["errcode"] = "RTA5215";
|
|
|
+ errInfo["msg"] = "调用系统api获取硬盘ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ disk = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_disk_serial_by_system errCode:%d", errCode);
|
|
|
strErrMsg = CSimpleStringA::Format("查询磁盘序列号失败, 请重启机器并重新初始化");
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
@@ -1319,7 +1162,6 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
return;
|
|
|
}
|
|
|
strRet += "|";
|
|
|
-
|
|
|
strTmp = "";
|
|
|
vector<string>::iterator it = diskArr.begin();
|
|
|
while (it != diskArr.end()) {
|
|
@@ -1329,19 +1171,11 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
strRet += strTmp.c_str();
|
|
|
disk = strTmp.c_str();
|
|
|
|
|
|
- BYTE m_btTermSysInfoSM3[32] = { 0 };
|
|
|
- if (!SM3Hash(reinterpret_cast<BYTE*>(const_cast<char*>(strRet.GetData())), strRet.GetLength(), m_btTermSysInfoSM3))
|
|
|
- {
|
|
|
- strErrMsg = "get sm3 hash as fingerprint fail";
|
|
|
- pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
- spFunction->SetSysVar("AuthErrMsg", (const char*)strErrMsg, true);
|
|
|
- doWarnMsg(ERROR_ACCESSAUTH_GETSM3HASH, (const char*)strErrMsg);
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
#else
|
|
|
//oilyang@20231008 to get system info from runcfg first
|
|
|
//no matter calculating from runcfg succeed or not,we also get system info from system api for update runcfg
|
|
|
- bool bCalcFromRunCfg = false;
|
|
|
+ bool bGetFromRunCfg = false;
|
|
|
CSimpleString csInfo, strErrMsg, strRet;
|
|
|
CSmartPointer<IConfigInfo> pConfigRun;
|
|
|
ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->OpenConfig(Config_Run, pConfigRun);
|
|
@@ -1353,6 +1187,7 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
cpu = sysInfo[0];
|
|
|
mainBoard = sysInfo[1];
|
|
|
disk = sysInfo[2];
|
|
|
+ bGetFromRunCfg = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -1364,6 +1199,13 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
CSmartPointer<IEntityFunction> spFunction = GetEntityBase()->GetFunction();
|
|
|
if (!QueryWMIDevice(Processor, "ProcessorId", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5213";
|
|
|
+ errInfo["msg"] = "调用系统api获取CPU序号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ cpu = generateJsonStr(errInfo).second.c_str();
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 cpu id 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1381,6 +1223,13 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(BaseBoard, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5214";
|
|
|
+ errInfo["msg"] = "调用系统api获取主板ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ mainBoard = generateJsonStr(errInfo).second.c_str();
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 baseboard sn 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1400,6 +1249,13 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(DiskDrive, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5215";
|
|
|
+ errInfo["msg"] = "调用系统api获取硬盘ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ disk = generateJsonStr(errInfo).second.c_str();
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 harddisk sn 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
pEntity->SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1414,7 +1270,7 @@ void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & main
|
|
|
strRet += szTmp;
|
|
|
disk = szTmp;
|
|
|
|
|
|
- if (!bCalcFromRunCfg || csInfo.Compare(strRet) != 0)
|
|
|
+ if (!bGetFromRunCfg || csInfo.Compare(strRet) != 0)
|
|
|
{
|
|
|
eErr = pConfigRun->WriteConfigValue("system", "info", strRet.GetData());
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("device info changed,before[%s],current[%s],write to runcfg:%d"
|