|
@@ -24,9 +24,6 @@ using namespace PinPad;
|
|
|
#include "DeviceBaseClass.h"
|
|
|
#endif
|
|
|
|
|
|
-#define KEY_SIZE 16
|
|
|
-#define BUF_SIZE 256
|
|
|
-
|
|
|
extern int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len);
|
|
|
extern int StrBuf2HexBuf(LPCTSTR strBuf, PBYTE* hexBuf);
|
|
|
|
|
@@ -40,8 +37,8 @@ struct InitializerInitMKTask : ITaskSp
|
|
|
{
|
|
|
CSystemStaticInfo si;
|
|
|
m_fsm->GetEntityBase()->GetFunction()->GetSystemStaticInfo(si);
|
|
|
- CInitlizerMKReq initMKReq;//oiltest dev module count
|
|
|
- bool initFlag = m_entity->SendInitMKReqACS(initMKReq);
|
|
|
+ CInitlizerMKReq instanceReq;//oiltest dev module count
|
|
|
+ bool initFlag = m_entity->SendInitMKReqACS(instanceReq);
|
|
|
if (!initFlag)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5204")("连接密码键盘异常");
|
|
@@ -56,87 +53,29 @@ struct InitializerInitMKTask : ITaskSp
|
|
|
}
|
|
|
|
|
|
auto tmkpair = m_entity->GenerateTmkToKMC();
|
|
|
- struct InstanceReqJson
|
|
|
- {
|
|
|
- string enrolAddr;
|
|
|
- string enrolGPS;
|
|
|
- string installVersion;
|
|
|
- string ip;
|
|
|
- string machineModel;
|
|
|
- string machineType;
|
|
|
- string padDeviceID;
|
|
|
- string site;
|
|
|
- string terminalNo;
|
|
|
- string factory;
|
|
|
- string modal;
|
|
|
- string type;
|
|
|
- string version;
|
|
|
- string terminalCharacter; //终端特征值(fingerPrint + fingerPrintSM)
|
|
|
- string pinPadID;
|
|
|
- string publicKey;
|
|
|
- string user; //操作人
|
|
|
- string password; //密码
|
|
|
- string auth;//预留鉴权
|
|
|
- int loginWay;//1表示错误页发起,需要传入登录密码;0表示用户桌面发起,不需要传入登录密码
|
|
|
- string encRandom; //tmk pk加密的随机密钥
|
|
|
- string tpkKeyCheck; //密钥校验值
|
|
|
- string edkKeyCheck; //密钥校验值
|
|
|
- string keyIndex; //密钥序号
|
|
|
-
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(enrolAddr, enrolGPS, installVersion, ip, machineModel, machineType,
|
|
|
- padDeviceID, site, terminalNo, factory, modal, type, version, terminalCharacter, pinPadID, publicKey,
|
|
|
- user, password, auth, loginWay, encRandom, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
-
|
|
|
- } instanceReq;
|
|
|
-
|
|
|
- instanceReq.enrolAddr = initMKReq.enrolAddr;
|
|
|
- instanceReq.enrolGPS = initMKReq.enrolGPS;
|
|
|
- instanceReq.installVersion = initMKReq.installVersion;
|
|
|
- instanceReq.ip = initMKReq.ip;
|
|
|
- instanceReq.machineModel = initMKReq.machineModel;
|
|
|
- instanceReq.machineType = initMKReq.machineType;
|
|
|
- instanceReq.padDeviceID = initMKReq.padDeviceID;
|
|
|
- instanceReq.site = initMKReq.site;
|
|
|
- instanceReq.terminalNo = initMKReq.terminalNo;
|
|
|
- instanceReq.factory = initMKReq.factory;
|
|
|
- instanceReq.modal = initMKReq.modal;
|
|
|
- instanceReq.type = initMKReq.type;
|
|
|
- instanceReq.version = initMKReq.version;
|
|
|
- instanceReq.terminalCharacter = initMKReq.terminalCharacter;
|
|
|
- instanceReq.pinPadID = initMKReq.pinPadID;
|
|
|
- instanceReq.publicKey = initMKReq.publicKey;
|
|
|
- instanceReq.user = initMKReq.user;
|
|
|
- instanceReq.password = initMKReq.password;
|
|
|
- instanceReq.auth = initMKReq.auth;
|
|
|
- instanceReq.loginWay = initMKReq.loginWay;
|
|
|
instanceReq.encRandom = tmkpair.first;
|
|
|
- instanceReq.tpkKeyCheck = initMKReq.tpkKeyCheck;
|
|
|
- instanceReq.edkKeyCheck = initMKReq.edkKeyCheck;
|
|
|
- instanceReq.keyIndex = initMKReq.keyIndex;
|
|
|
|
|
|
- struct InstanceAnsJson
|
|
|
- {
|
|
|
- string TMK;
|
|
|
- string TPK;
|
|
|
- string EDK;
|
|
|
- string tpkKeyCheck;
|
|
|
- string edkKeyCheck;
|
|
|
- string keyIndex;
|
|
|
- string reserved;
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(TMK, TPK, EDK, tpkKeyCheck, edkKeyCheck, keyIndex)
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("tmk", "tpk", "edk", "tpkKeyCheck", "edkKeyCheck", "keyIndex")
|
|
|
- } instanceAns;
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("iniTerminalInfo: %s", instanceReq.iniTerminalInfo.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("auth:%s", instanceReq.auth.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("curEdkKeyCheck: %s", instanceReq.curEdkKeyCheck.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("curKeyIndex: %s", instanceReq.curKeyIndex.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("curTpkKeyCheck: %s", instanceReq.curTpkKeyCheck.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("encRandom: %s", instanceReq.encRandom.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("publicKey: %s", instanceReq.publicKey.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("terminalNo: %s", instanceReq.terminalNo.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("terminalVersion: %s", instanceReq.terminalVersion.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("user: %s", instanceReq.user.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("loginWay: %d", instanceReq.loginWay);
|
|
|
+
|
|
|
+ CInitlizerMKAns instanceAns;
|
|
|
|
|
|
HttpClientResponseResult result;
|
|
|
HttpClientRequestConfig config(HttpRequestMethod::POST, m_entity->GetInitUrl().GetData(), &SpGetToken);
|
|
|
- config.SetChildUri("/api/v5/initmk");
|
|
|
+ config.SetChildUri("/api/v6/initmk");
|
|
|
SP::Module::Restful::FulfillRequestJsonBody(&config, instanceReq);
|
|
|
-
|
|
|
- std::string test;
|
|
|
- test = config.GetRequestUri();
|
|
|
-
|
|
|
RestfulClient client = RestfulClient::getInstance();
|
|
|
config.PreDo();
|
|
|
+
|
|
|
client.Do(&config, &result);
|
|
|
if (result.ResponseOK()) {
|
|
|
SP::Module::Restful::CommResponseJson responseStatus;
|
|
@@ -179,7 +118,6 @@ struct InitializerInitMKTask : ITaskSp
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
struct GetTermSysInfoTask : ITaskSp
|
|
|
{
|
|
|
CAccessAuthEntity* m_entity;
|
|
@@ -187,10 +125,9 @@ struct GetTermSysInfoTask : ITaskSp
|
|
|
|
|
|
void Process()
|
|
|
{
|
|
|
- m_entity->GetTermSysInfo();
|
|
|
+ m_entity->GetHardWareInfo();
|
|
|
}
|
|
|
};
|
|
|
-#endif // RVC_OS_WIN
|
|
|
|
|
|
typedef struct _REG_TZI_FORMAT
|
|
|
{
|
|
@@ -264,11 +201,9 @@ void CAccessAuthEntity::OnStarted()
|
|
|
GetOutPutStr("%s%08X", "获取系统静态信息错误", rc).c_str(), strErrMsg.GetData());
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%08X", "获取系统静态信息错误", rc).c_str());
|
|
|
}
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- spFunction->RegistSysVarEvent("NetState", this);
|
|
|
+
|
|
|
CSmartPointer<GetTermSysInfoTask> getTermSysInfoTask = new GetTermSysInfoTask(this);
|
|
|
GetFunction()->PostThreadPoolTask(getTermSysInfoTask.GetRawPointer());
|
|
|
-#endif // RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
void CAccessAuthEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
@@ -279,9 +214,6 @@ void CAccessAuthEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPoin
|
|
|
|
|
|
void CAccessAuthEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- GetFunction()->UnregistSysVarEvent("NetState");
|
|
|
-#endif // RVC_OS_WIN
|
|
|
m_FSM.PostExitEvent();
|
|
|
pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
}
|
|
@@ -619,8 +551,8 @@ static BYTE* ConvertHexStrToBytes(const char *pszStr)
|
|
|
return pRet;
|
|
|
}
|
|
|
|
|
|
-// 使用准入会话密钥加密
|
|
|
-ErrorCodeEnum CAccessAuthEntity::EncryptDataWithSessionKey(const CBlob &raw, CBlob &enc)
|
|
|
+// 使用密钥加密
|
|
|
+ErrorCodeEnum CAccessAuthEntity::EncryptDataWithKey(const CBlob &raw, CBlob &enc, BYTE* key)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
//这里不需要delete,由CBlob析构函数去执行
|
|
@@ -630,14 +562,10 @@ ErrorCodeEnum CAccessAuthEntity::EncryptDataWithSessionKey(const CBlob &raw, CBl
|
|
|
char* pPlainInfo = Str2Hex((char*)raw.m_pData, raw.m_iLength);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("raw Length=%d", raw.m_iLength);
|
|
|
delete[] pPlainInfo;
|
|
|
-
|
|
|
- char sessionKey[KEY_SIZE] = { 0 };
|
|
|
- memcpy(sessionKey,m_AuthSessionKey,KEY_SIZE);
|
|
|
- char* tmpKey = Str2Hex((char*)m_AuthSessionKey, KEY_SIZE);
|
|
|
- delete[] tmpKey;
|
|
|
|
|
|
- if (!EncWithSM4_ECB((BYTE*)sessionKey, (BYTE*)(raw.m_pData), raw.m_iLength, pEncData, &pEncDataSize)) {
|
|
|
+ if (!EncWithSM4_ECB(key, (BYTE*)(raw.m_pData), raw.m_iLength, pEncData, &pEncDataSize)) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("会话密钥加密准入信息失败!");
|
|
|
+ SetAuthErrMsg("会话密钥加密准入信息失败");
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
|
|
@@ -680,112 +608,6 @@ static char* ConvertBytesToHexStr(BYTE *pBuf, int nLen)
|
|
|
return pRet;
|
|
|
}
|
|
|
|
|
|
-bool CAccessAuthEntity::GetTerminalFingerPrint(BYTE *pBuf, int &nBufLen)
|
|
|
-{
|
|
|
-#ifdef RVC_OS_LINUX
|
|
|
- char szTmp[1024] = {};
|
|
|
- string strTmp;
|
|
|
- int nTmpBufLen = 1024;
|
|
|
- CSimpleStringA strErrMsg;
|
|
|
- CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
|
|
|
-
|
|
|
- CSimpleStringA strRet;
|
|
|
- CSimpleStringA runInfoPath;
|
|
|
- auto rc = GetFunction()->GetPath("runinfo", runInfoPath);
|
|
|
- if (rc != Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", rc);
|
|
|
- return false;
|
|
|
- }
|
|
|
- runInfoPath += SPLIT_SLASH_STR "runcfg";
|
|
|
- if (!get_cpu_id_by_system(strTmp, runInfoPath.GetData()))
|
|
|
- {
|
|
|
- strErrMsg = CSimpleStringA::Format("查询CPU ID失败,请重启机器并重新初始化");
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
-
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_GETCPUID,
|
|
|
- GetOutPutStr("%s%s", "Processor", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5213")
|
|
|
- (GetOutPutStr("%s%s", "Processor", "False").c_str());
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- strRet = strTmp.c_str();
|
|
|
- strTmp.clear();
|
|
|
- if (!get_board_serial_by_system(strTmp, runInfoPath.GetData()))
|
|
|
- {
|
|
|
- strErrMsg = CSimpleStringA::Format("查询主板序列号失败, 请重启机器并重新初始化");
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
-
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_GETBASEBOARDSN,
|
|
|
- GetOutPutStr("%s%s", "BaseBoard", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5214")
|
|
|
- (GetOutPutStr("%s%s", "BaseBoard", "False").c_str());
|
|
|
- return false;
|
|
|
- }
|
|
|
- strRet += "|";
|
|
|
-
|
|
|
- strRet += strTmp.c_str();
|
|
|
- vector<string> disk;
|
|
|
- int errCode = 0;
|
|
|
- if (!get_disk_serial_by_system(disk, errCode, runInfoPath.GetData()))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_disk_serial_by_system errCode:%d", errCode);
|
|
|
- strErrMsg = CSimpleStringA::Format("查询磁盘序列号失败, 请重启机器并重新初始化");
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
-
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_DISKDRIVESN,
|
|
|
- GetOutPutStr("%s%s", "DiskDrive", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5215")
|
|
|
- (GetOutPutStr("%s%s", "DiskDrive", "False").c_str());
|
|
|
- return false;
|
|
|
- }
|
|
|
- strRet += "|";
|
|
|
-
|
|
|
- strTmp = "";
|
|
|
- vector<string>::iterator it = disk.begin();
|
|
|
- while (it != disk.end()) {
|
|
|
- strTmp += *it;
|
|
|
- it++;
|
|
|
- }
|
|
|
- strRet += 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";
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
- spFunction->SetSysVar("AuthErrMsg", (const char*)strErrMsg, true);
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_GETSM3HASH, (const char*)strErrMsg);
|
|
|
- return false;
|
|
|
- }
|
|
|
-#endif // RVC_OS_LINUX
|
|
|
- if (nBufLen < 32)
|
|
|
- {
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_GETSM3HASH, "buf len is too small fail");
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("buf len is too small fail");
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- while (1)
|
|
|
- {
|
|
|
- if (m_iGetTermSysInfo == -1)
|
|
|
- return false;
|
|
|
- else if (m_iGetTermSysInfo == 1)
|
|
|
- break;
|
|
|
- else if (m_iGetTermSysInfo == 0)
|
|
|
- Sleep(1000);//oiltmp@20220917 之前的逻辑是不跳出去,现在要加么?暂时不加,连调用系统接口都有问题,让其他逻辑处理
|
|
|
- }
|
|
|
-#endif // RVC_OS_WIN
|
|
|
- nBufLen = 32;
|
|
|
- memcpy(pBuf, m_btTermSysInfoSM3, nBufLen);
|
|
|
-
|
|
|
- char *pszSM3 = ConvertBytesToHexStr(m_btTermSysInfoSM3, nBufLen);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("fringerprint: [%s]", pszSM3);
|
|
|
- free(pszSM3);
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
// 生成RSA密钥对,并导出公钥
|
|
|
bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& pubkey)
|
|
|
{
|
|
@@ -887,18 +709,20 @@ bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& p
|
|
|
|
|
|
//oilyang@20210510 嵌入"bool CAccessAuthEntity::HasPinPad()"的逻辑
|
|
|
// 返回1:只有PinPadID;2:只有DeviceID;3:两者都有;0:没有;-1表示失败
|
|
|
-int CAccessAuthEntity::GetPinPadIDAndDeviceID(CSimpleStringA &strPinPadID, CSimpleStringA &strDeviceID, bool& isPinPadMac, bool& bPinPadOnline)
|
|
|
+ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, bool& bPinPadOnline)
|
|
|
{
|
|
|
- isPinPadMac = false;
|
|
|
bPinPadOnline = false;
|
|
|
CSimpleStringA strErrMsg;
|
|
|
CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
|
|
|
-
|
|
|
+ std::map<std::string, std::string> errInfo;
|
|
|
//oilyang@20210514
|
|
|
if (!IsMachineTypeConfigurePinPad(m_info.strMachineType))
|
|
|
- return 0;
|
|
|
+ {
|
|
|
+ pinpadModel = "";
|
|
|
+ return Error_Succeed;
|
|
|
+ }
|
|
|
|
|
|
- int nRet = -1;
|
|
|
+ ErrorCodeEnum nRet = Error_Unexpect;
|
|
|
auto pPinPadClient = new PinPadService_ClientBase(this);
|
|
|
bool bPinPadID = false;
|
|
|
bool bDeviceID = false;
|
|
@@ -908,10 +732,15 @@ int CAccessAuthEntity::GetPinPadIDAndDeviceID(CSimpleStringA &strPinPadID, CSimp
|
|
|
CSimpleStringA strBluetoothID;
|
|
|
CSimpleStringA strPID;
|
|
|
CSimpleStringA strMID;
|
|
|
- isPinPadMac = true;
|
|
|
auto rc = 0;
|
|
|
if ((rc = pPinPadClient->Connect()) == Error_Succeed)
|
|
|
{
|
|
|
+ //初始错误信息
|
|
|
+ errInfo["errcode"] = "RTA5205";
|
|
|
+ errInfo["msg"] = "调用PinPad发生错误";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
PinPadService_GetDevInfo_Req req = {};
|
|
|
PinPadService_GetDevInfo_Ans ans = {};
|
|
|
|
|
@@ -919,69 +748,26 @@ int CAccessAuthEntity::GetPinPadIDAndDeviceID(CSimpleStringA &strPinPadID, CSimp
|
|
|
if (rc == Error_Succeed)
|
|
|
{
|
|
|
bPinPadOnline = true;
|
|
|
- nRet = 0;
|
|
|
+ nRet = Error_Succeed;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad model: %s", ans.model.GetData());
|
|
|
|
|
|
// CM = V2.0#PM = V1.0#MID = 75500001#PID = 12345678#FWID = V1234567#Vendor = nantian
|
|
|
// 密码键盘ID,PID,8到16字节; 设备ID,MID,8到16字节; 固件版本号,FWID,8字节
|
|
|
- CSimpleStringA str = ans.model;
|
|
|
- if (!str.IsNullOrEmpty())
|
|
|
- {
|
|
|
- auto arr = str.Split('#');
|
|
|
- if (arr.GetCount() > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < arr.GetCount(); i++)
|
|
|
- {
|
|
|
- auto arr2 = arr[i].Split('=');
|
|
|
- if (arr2.GetCount() != 2)
|
|
|
- continue;
|
|
|
-
|
|
|
- //if (arr2[0] == "PID")
|
|
|
- if (!strnicmp((LPCTSTR)arr2[0], "PID", strlen("PID")))
|
|
|
- {
|
|
|
- strPID = arr2[1];
|
|
|
-
|
|
|
- if (!strPID.IsNullOrEmpty())
|
|
|
- bPinPadID = true;
|
|
|
- }
|
|
|
- //else if (arr2[0] == "MID")
|
|
|
- else if (!strnicmp((LPCTSTR)arr2[0], "MID", strlen("MID")))
|
|
|
- {
|
|
|
- strMID = arr2[1];
|
|
|
-
|
|
|
- if (!strMID.IsNullOrEmpty())
|
|
|
- bDeviceID = true;
|
|
|
- }
|
|
|
- //else if (arr2[0] == "Vendor")
|
|
|
- else if (!strnicmp((LPCTSTR)arr2[0], "Vendor", strlen("Vendor")))
|
|
|
- {
|
|
|
- strVendor = arr2[1];
|
|
|
-
|
|
|
- if (!strVendor.IsNullOrEmpty())
|
|
|
- bVendor = true;
|
|
|
- }
|
|
|
- else if (!strnicmp((LPCTSTR)arr2[0], "FWBID", strlen("FWBID")))
|
|
|
- {
|
|
|
- strBluetoothID = arr2[1];
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("strBluetoothID=%s", strBluetoothID.GetData());
|
|
|
- if (!strBluetoothID.IsNullOrEmpty())
|
|
|
- bBluetooth = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ pinpadModel = ans.model;
|
|
|
}
|
|
|
else if(rc == Error_NotInit)
|
|
|
{
|
|
|
- if (!HasPinPad())
|
|
|
- isPinPadMac = false;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad NOT INIT!, state: %d", ans.state);
|
|
|
- return nRet; //此时nRet = -1, pinpad调用失败
|
|
|
+ strErrMsg = "PinPad打开失败";
|
|
|
+ SetAuthErrMsg(strErrMsg.GetData());
|
|
|
+
|
|
|
+ string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
|
|
|
+ m_FSM.doWarnMsg(ERR_ACCESSAUTH_FROM_PINPAD, outStr.c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
|
|
|
+ return nRet;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (!HasPinPad())
|
|
|
- isPinPadMac = false;
|
|
|
strErrMsg = "调用PinPad实体的GetDevInfo方法失败";
|
|
|
SetAuthErrMsg(strErrMsg.GetData());
|
|
|
|
|
@@ -989,15 +775,29 @@ int CAccessAuthEntity::GetPinPadIDAndDeviceID(CSimpleStringA &strPinPadID, CSimp
|
|
|
m_FSM.doWarnMsg(ERR_ACCESSAUTH_FROM_PINPAD, outStr.c_str());
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
|
|
|
|
|
|
- return nRet; //此时nRet = -1, pinpad调用失败
|
|
|
+ return nRet;
|
|
|
}
|
|
|
|
|
|
pPinPadClient->GetFunction()->CloseSession();
|
|
|
}
|
|
|
+ else if (rc == Error_NetBroken)
|
|
|
+ {
|
|
|
+ strErrMsg = "PinPad实体未启动, 连接密码键盘失败";
|
|
|
+ SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+
|
|
|
+ m_FSM.doWarnMsg(ERR_ACCESSAUTH_CONNECT_PINPAD_UNLOAD,
|
|
|
+ GetOutPutStr("%s%08X%s%s", "Connect", rc, "strErrMsg", "PinPad实体未启动, 连接密码键盘失败").c_str());
|
|
|
+ pPinPadClient->SafeDelete();
|
|
|
+
|
|
|
+ errInfo["errcode"] = "RTA5218";
|
|
|
+ errInfo["msg"] = "PinPad实体未启动";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ return nRet;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- if (!HasPinPad())
|
|
|
- isPinPadMac = false;
|
|
|
strErrMsg = "连接PinPad实体失败";
|
|
|
SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
@@ -1006,39 +806,16 @@ int CAccessAuthEntity::GetPinPadIDAndDeviceID(CSimpleStringA &strPinPadID, CSimp
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5204")("连接密码键盘异常");
|
|
|
pPinPadClient->SafeDelete();
|
|
|
|
|
|
+ errInfo["errcode"] = "RTA5204";
|
|
|
+ errInfo["msg"] = "PinPad实体启动成功,但连接PinPad实体失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ pinpadModel = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
return nRet; //此时nRet = -1, pinpad调用失败
|
|
|
}
|
|
|
|
|
|
pPinPadClient = NULL;
|
|
|
|
|
|
- if (bPinPadID)
|
|
|
- {
|
|
|
- if (bVendor)
|
|
|
- strPinPadID = strVendor + "_" + strPID;
|
|
|
- else
|
|
|
- strPinPadID = strPID;
|
|
|
-
|
|
|
- nRet += 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (bDeviceID)
|
|
|
- {
|
|
|
- if (bVendor)
|
|
|
- strDeviceID = strVendor + "_" + strMID;
|
|
|
- else
|
|
|
- strDeviceID = strMID;
|
|
|
-
|
|
|
- if (bBluetooth)
|
|
|
- strDeviceID = strDeviceID + "_" + strBluetoothID;
|
|
|
-
|
|
|
- nRet += 2;
|
|
|
- }
|
|
|
- else if (bBluetooth)
|
|
|
- {
|
|
|
- strDeviceID = strDeviceID + "_" + strBluetoothID;
|
|
|
- nRet += 2;
|
|
|
- }
|
|
|
-
|
|
|
return nRet;
|
|
|
}
|
|
|
|
|
@@ -1248,89 +1025,30 @@ bool CAccessAuthEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
CSmartPointer<IEntityFunction> pFunc = GetFunction();
|
|
|
- CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
- bool isPinPadMac, bPinPadOnline;
|
|
|
- int nRet = 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 < 0)
|
|
|
- {
|
|
|
- return false; //具有pinpad的设备调用pinpad失败
|
|
|
+ ErrorCodeEnum nRet = Error_Unexpect;
|
|
|
+
|
|
|
+ CBlob encInfo;
|
|
|
+ char* hexStr = "21009872C31CBC00D0C8F421D09CF707";
|
|
|
+ BYTE key[KEY_SIZE] = { 0 };
|
|
|
+ memcpy(key, ConvertHexStrToBytes(hexStr), KEY_SIZE);
|
|
|
+ //char key[KEY_SIZE] = { 0 };
|
|
|
+ //memcpy(key, "1234567890123456234", KEY_SIZE);
|
|
|
+ nRet = (ErrorCodeEnum)m_FSM.GetEncTerminalInfoWithKey(encInfo, key);
|
|
|
+ if (nRet != Error_Succeed)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetEncTerminalInfo failed:%d", nRet);
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- // 从系统获取设备信息和硬件信息
|
|
|
- // 变长结构初始化
|
|
|
- char buf2[512];
|
|
|
- memset(buf2, 0, 512);
|
|
|
+ char* pTmp = Str2Hex((char*)encInfo.m_pData, encInfo.m_iLength);
|
|
|
+ initMKReq.iniTerminalInfo = pTmp;
|
|
|
|
|
|
CSystemStaticInfo si;
|
|
|
pFunc->GetSystemStaticInfo(si);
|
|
|
-
|
|
|
- initMKReq.enrolGPS = "00000A4500000A4E";//oiltmp
|
|
|
- initMKReq.enrolAddr = si.strEnrolAddr;
|
|
|
- initMKReq.installVersion = si.InstallVersion.ToString();
|
|
|
-
|
|
|
-#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];
|
|
|
- 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];
|
|
|
- char xIP[64] = {};
|
|
|
- sprintf(xIP, "%d.%d.%d.%d", in->S_un.S_un_b.s_b1, in->S_un.S_un_b.s_b2, in->S_un.S_un_b.s_b3, in->S_un.S_un_b.s_b4);
|
|
|
- initMKReq.ip = xIP;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ip:%s", xIP);
|
|
|
- }
|
|
|
-#else
|
|
|
- BYTE xIP[64] = {};
|
|
|
- char ip[32] = { 0 };
|
|
|
- if (getIPFromLinux(ip)) DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get IP From Linux Error ex.");
|
|
|
- else {
|
|
|
- if (ip2byte(ip, xIP)) DbgWithLink(LOG_LEVEL_INFO, 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, xIP[i]);
|
|
|
- }
|
|
|
- char strIP[64];
|
|
|
- memset(strIP, 0, 64);
|
|
|
- sprintf(strIP, "%d.%d.%d.%d", xIP[0], xIP[1], xIP[2], xIP[3]);
|
|
|
- initMKReq.ip = strIP;
|
|
|
- }
|
|
|
- }
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
- initMKReq.machineType = si.strMachineType;
|
|
|
-
|
|
|
- if (nRet == 2 || nRet == 3)
|
|
|
- initMKReq.padDeviceID = strDeviceID;
|
|
|
- initMKReq.site = si.strSite;
|
|
|
- initMKReq.terminalNo = si.strTerminalID;
|
|
|
-
|
|
|
- BYTE fingerPrint[32] = { 0 };
|
|
|
- int nBufLen = sizeof(fingerPrint);
|
|
|
- if (!GetTerminalFingerPrint(fingerPrint, nBufLen))
|
|
|
- {
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
- GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT;
|
|
|
- }
|
|
|
- initMKReq.terminalCharacter = ConvertBytesToHexStr(fingerPrint, nBufLen);
|
|
|
-
|
|
|
- if (nRet == 1 || nRet == 3)
|
|
|
- initMKReq.pinPadID = strPinPadID;
|
|
|
+ initMKReq.terminalVersion = si.InstallVersion.ToString();
|
|
|
+ initMKReq.terminalNo = si.strTerminalID.GetData();
|
|
|
|
|
|
BYTE xPublicKey[148];
|
|
|
- nBufLen = sizeof(xPublicKey);
|
|
|
+ int nBufLen = sizeof(xPublicKey);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SendInitMKReqACS")("开始获取公钥。。。");
|
|
|
memset(xPublicKey, 0, nBufLen);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SendInitMKReqACS")("nBufLen=%d", nBufLen);
|
|
@@ -1338,10 +1056,10 @@ bool CAccessAuthEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
{
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_PUBKEY,
|
|
|
GetOutPutStr("%s%s", "GetTerminalPublicKey", "False").c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_TERMINAL_PUBKEY;
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
initMKReq.user = m_strUserID.GetData();
|
|
|
- initMKReq.password = m_strPassword.GetData();
|
|
|
if (!m_strUserID.IsNullOrEmpty() && !m_strPassword.IsNullOrEmpty())
|
|
|
{
|
|
|
LogWarn(Severity_Low, Error_Succeed, AccessAuthorization_UserErrorCode_Init_From_ClosePage, "Init by ClosePage.");
|
|
@@ -1367,8 +1085,8 @@ bool CAccessAuthEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
errRc = (*pPinPad)(EntityResource::getLink().upgradeLink())->GetCheckCode(req, ans, 10000);
|
|
|
if (errRc == Error_Succeed)
|
|
|
{
|
|
|
- initMKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
- initMKReq.keyIndex = ans.index[0].GetData();
|
|
|
+ initMKReq.curTpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
+ initMKReq.curKeyIndex = ans.index[0].GetData();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1388,14 +1106,15 @@ bool CAccessAuthEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
void CAccessAuthEntity::EndInitMK(DWORD rc, const char *pszErrMsg)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("EndInitMK:rc:%d,errMsg:%s", rc, pszErrMsg);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode(AccessAuthService_LogCode_InitializeNew)
|
|
|
+ ("EndInitMK:rc:%d,errMsg:%s", rc, pszErrMsg);
|
|
|
GetFunction()->KillTimer(22);
|
|
|
|
|
|
m_strLastErrMsg = pszErrMsg;
|
|
|
|
|
|
if (rc != Error_Succeed)
|
|
|
{
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_FAILED,
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, rc,
|
|
|
GetOutPutStr("%s%08X%s%s", "EndInitMK", rc,"pszErrMsg", pszErrMsg).c_str());
|
|
|
|
|
|
GetFunction()->ShowFatalError(pszErrMsg);
|
|
@@ -1579,96 +1298,229 @@ pair<string, string> CAccessAuthEntity::EncryptedByPubKey(CSimpleStringA pubKey,
|
|
|
return make_pair(pBlock, strRam);
|
|
|
}
|
|
|
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
-void CAccessAuthEntity::GetTermSysInfo()
|
|
|
+void CAccessAuthEntity::GetHardWareInfo()
|
|
|
{
|
|
|
+ std::map<std::string, std::string> errInfo;
|
|
|
+
|
|
|
//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 = GetFunction()->OpenConfig(Config_Run, pConfigRun);
|
|
|
if (eErr == Error_Succeed && pConfigRun->ReadConfigValue("system", "info", csInfo) == Error_Succeed && !csInfo.IsNullOrEmpty()) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("read device info from runcfg: [%s]", csInfo.GetData());
|
|
|
-
|
|
|
- ZeroMemory(m_btTermSysInfoSM3, sizeof(m_btTermSysInfoSM3));
|
|
|
- if (!SM3Hash(reinterpret_cast<BYTE*>(const_cast<char*>(csInfo.GetData())), csInfo.GetLength(), m_btTermSysInfoSM3))
|
|
|
+ CAutoArray<CSimpleStringA> sysInfo = csInfo.Split('|');
|
|
|
+ if (sysInfo.GetCount() == 3)
|
|
|
{
|
|
|
- strErrMsg = "get sm3 hash as fingerprint fail";
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
- this->GetFunction()->SetSysVar("AuthErrMsg", (const char*)strErrMsg, true);
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, ERROR_ACCESSAUTH_GETSM3HASH, (const char*)strErrMsg);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTerminalFingerPrint")((const char*)strErrMsg);
|
|
|
- m_iGetTermSysInfo = -1;
|
|
|
+ m_cpuId = sysInfo[0];
|
|
|
+ m_mainBoardId = sysInfo[1];
|
|
|
+ m_hardDiskId = sysInfo[2];
|
|
|
+ bGetFromRunCfg = true;
|
|
|
+ m_iGetTermSysInfo = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_iGetTermSysInfo = 1;
|
|
|
- bCalcFromRunCfg = true;
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTerminalFingerPrint")("get sm3 hash as fingerprint fail");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTermSysInfo, OpenConfig Config_Run error=%d.", eErr);
|
|
|
|
|
|
- ULONGLONG ullStart = GetTickCount64();
|
|
|
+#ifdef RVC_OS_LINUX
|
|
|
char szTmp[1024] = {};
|
|
|
+ string strTmp;
|
|
|
int nTmpBufLen = 1024;
|
|
|
- CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
|
|
|
|
|
|
+ CSimpleStringA runInfoPath;
|
|
|
+ auto rc = GetFunction()->GetPath("runinfo", runInfoPath);
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", rc);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ runInfoPath += SPLIT_SLASH_STR "runcfg";
|
|
|
+
|
|
|
+ //CPU
|
|
|
+ if (!get_cpu_id_by_system(strTmp, runInfoPath.GetData()))
|
|
|
+ {
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5213";
|
|
|
+ errInfo["msg"] = "调用系统api获取CPU序号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_cpuId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ strErrMsg = CSimpleStringA::Format("查询CPU ID失败,请重启机器并重新初始化");
|
|
|
+ SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
+ GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "Processor", GetLastError()).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5213")
|
|
|
+ (GetOutPutStr("%s%s", "Processor", "False").c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_cpuId = strTmp.c_str();
|
|
|
+ strRet = strTmp.c_str();
|
|
|
+ strTmp.clear();
|
|
|
+
|
|
|
+ //主板
|
|
|
+ if (!get_board_serial_by_system(strTmp, runInfoPath.GetData()))
|
|
|
+ {
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5214";
|
|
|
+ errInfo["msg"] = "调用系统api获取主板ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_mainBoardId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
+ strErrMsg = CSimpleStringA::Format("查询主板序列号失败, 请重启机器并重新初始化");
|
|
|
+ SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
+ GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5214")
|
|
|
+ (GetOutPutStr("%s%s", "BaseBoard", "False").c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_mainBoardId = strTmp.c_str();
|
|
|
+ strRet += "|";
|
|
|
+ strRet += strTmp.c_str();
|
|
|
+
|
|
|
+ //硬盘
|
|
|
+ vector<string> diskArr;
|
|
|
+ int errCode = 0;
|
|
|
+ if (!get_disk_serial_by_system(diskArr, errCode, runInfoPath.GetData()))
|
|
|
+ {
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5215";
|
|
|
+ errInfo["msg"] = "调用系统api获取硬盘ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_hardDiskId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_disk_serial_by_system errCode:%d", errCode);
|
|
|
+ strErrMsg = CSimpleStringA::Format("查询磁盘序列号失败, 请重启机器并重新初始化");
|
|
|
+ SetAuthErrMsg((const char*)strErrMsg);
|
|
|
+
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
+ GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5215")
|
|
|
+ (GetOutPutStr("%s%s", "DiskDrive", "False").c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ strRet += "|";
|
|
|
+ strTmp = "";
|
|
|
+ vector<string>::iterator it = diskArr.begin();
|
|
|
+ while (it != diskArr.end()) {
|
|
|
+ strTmp += *it;
|
|
|
+ it++;
|
|
|
+ }
|
|
|
+ strRet += strTmp.c_str();
|
|
|
+ m_hardDiskId = strTmp.c_str();
|
|
|
+#else
|
|
|
+ ULONGLONG ullStart = GetTickCount64();
|
|
|
+ char szTmp[1024] = {};
|
|
|
+ int nTmpBufLen = 1024;
|
|
|
if (!QueryWMIDevice(Processor, "ProcessorId", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5213";
|
|
|
+ errInfo["msg"] = "调用系统api获取CPU序号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_cpuId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 cpu id 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect,ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "Processor", GetLastError()).c_str());
|
|
|
-
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5203")
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5213")
|
|
|
(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "Processor", GetLastError()).c_str());
|
|
|
- if (!bCalcFromRunCfg)
|
|
|
- m_iGetTermSysInfo = -1;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
strRet = szTmp;
|
|
|
+ m_cpuId = szTmp;
|
|
|
|
|
|
nTmpBufLen = 1024;
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(BaseBoard, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5214";
|
|
|
+ errInfo["msg"] = "调用系统api获取主板ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_mainBoardId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 baseboard sn 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5203")
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5214")
|
|
|
(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
|
|
|
- if (!bCalcFromRunCfg)
|
|
|
- m_iGetTermSysInfo = -1;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
strRet += "|";
|
|
|
strRet += szTmp;
|
|
|
+ m_mainBoardId = szTmp;
|
|
|
|
|
|
nTmpBufLen = 1024;
|
|
|
memset(szTmp, 0, sizeof(szTmp));
|
|
|
if (!QueryWMIDevice(DiskDrive, "SerialNumber", szTmp, &nTmpBufLen))
|
|
|
{
|
|
|
+ if (!bGetFromRunCfg)
|
|
|
+ {
|
|
|
+ errInfo["errcode"] = "RTA5215";
|
|
|
+ errInfo["msg"] = "调用系统api获取硬盘ID号失败";
|
|
|
+ errInfo["getLastErr"] = GetLastError();
|
|
|
+ m_hardDiskId = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ m_iGetTermSysInfo = -1;
|
|
|
+ }
|
|
|
strErrMsg = CSimpleStringA::Format("查询 harddisk sn 失败: %d, 请尝试重启应用", GetLastError());
|
|
|
SetAuthErrMsg((const char*)strErrMsg);
|
|
|
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "DiskDrive", GetLastError()).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "DiskDrive", GetLastError()).c_str());
|
|
|
- if (!bCalcFromRunCfg)
|
|
|
- m_iGetTermSysInfo = -1;
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5215")
|
|
|
+ (GetOutPutStr("%s%s", "DiskDrive", "False").c_str());
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
strRet += "|";
|
|
|
strRet += szTmp;
|
|
|
+ m_hardDiskId = szTmp;
|
|
|
+
|
|
|
+ ULONGLONG ullEnd = GetTickCount64();
|
|
|
+ if (ullEnd - ullStart > 5000)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5201")
|
|
|
+ ("获取系统信息耗时过长:%d秒", (ullEnd - ullStart) / 1000);
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, AccessAuthorization_UserErrorCode_GetTermCostTooLong,
|
|
|
+ CSimpleStringA::Format("获取系统信息耗时过长:%d秒", (ullEnd - ullStart) / 1000));
|
|
|
+ }
|
|
|
+#endif // RVC_OS_LINUX
|
|
|
|
|
|
- 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"
|
|
@@ -1677,33 +1529,11 @@ void CAccessAuthEntity::GetTermSysInfo()
|
|
|
else
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device info: [%s]", strRet.GetData());
|
|
|
|
|
|
-
|
|
|
- if (!bCalcFromRunCfg)
|
|
|
- {
|
|
|
- ZeroMemory(m_btTermSysInfoSM3, sizeof(m_btTermSysInfoSM3));
|
|
|
- if (!SM3Hash(reinterpret_cast<BYTE*>(const_cast<char*>(strRet.GetData())), strRet.GetLength(), m_btTermSysInfoSM3))
|
|
|
- {
|
|
|
- strErrMsg = "get sm3 hash as fingerprint fail";
|
|
|
- SetAuthErrMsg((const char*)strErrMsg);
|
|
|
- spFunction->SetSysVar("AuthErrMsg", (const char*)strErrMsg, true);
|
|
|
- m_FSM.doWarnMsg(ERROR_ACCESSAUTH_GETSM3HASH, (const char*)strErrMsg);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)((const char*)strErrMsg);
|
|
|
- m_iGetTermSysInfo = -1;
|
|
|
- }
|
|
|
- else
|
|
|
- m_iGetTermSysInfo = 1;
|
|
|
- }
|
|
|
- ULONGLONG ullEnd = GetTickCount64();
|
|
|
- if (ullEnd - ullStart > 5000)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5201")
|
|
|
- ("获取系统信息耗时过长:%d秒", (ullEnd - ullStart) / 1000);
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, AccessAuthorization_UserErrorCode_GetTermCostTooLong,
|
|
|
- CSimpleStringA::Format("获取系统信息耗时过长:%d秒", (ullEnd - ullStart) / 1000));
|
|
|
- }
|
|
|
+ m_iGetTermSysInfo = 1;
|
|
|
+
|
|
|
return;
|
|
|
+
|
|
|
}
|
|
|
-#endif // RVC_OS_WIN
|
|
|
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
SP_ENTITY(CAccessAuthEntity)
|