Browse Source

!10618 更新为最新基线
Merge pull request !10618 from 80274480/ST2

陈礼鹏80274480 9 tháng trước cách đây
mục cha
commit
57f23b60a9

+ 2 - 2
Module/mod_CardIssuerStand/CardIssuerFSM.cpp

@@ -3053,7 +3053,7 @@ int CCardIssuerFSM::PreOnline_Contact(SpReqAnsContext<CardIssuerStandService_Pre
 			//	, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 			//CSimpleStringA csErrMsgWithReturnCode = CSimpleStringA::Format("{\"ReturnCode\":\"%s\", \"ErrMsg\":\"%s\", \"Context\":\"%s\"}", SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 			
-			const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":%s, \"Context\":%s}"
+			const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":\"%s\", \"Context\":\"%s\"}"
 				, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 
 			std::map<std::string, std::string> msgInfo;
@@ -3445,7 +3445,7 @@ int CCardIssuerFSM::PreOnline_RF(SpReqAnsContext<CardIssuerStandService_PreOnlin
 			//CSimpleStringA csErrMsgWithReturnCode = CSimpleStringA::Format("{\"ReturnCode\":\"%s\", \"ErrMsg\":\"%s\", \"Context\":\"%s\"}", SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 
 
-			const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":%s, \"Context\":%s}"
+			const CSimpleStringA alarmMsg = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":\"%s\", \"Context\":\"%s\"}"
 				, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 
 			std::map<std::string, std::string> msgInfo;

+ 1 - 1
Module/mod_ContactlessCard/ContactlessFSM.cpp

@@ -1505,7 +1505,7 @@ void CContactlessCardFSM::GetCardProcessLastErr(ErrorCodeEnum& eErrCode, CSimple
 	CSimpleStringA lastApiName = "";
 	m_pCardProcess->getCardAssistLastErr(lastErrCode, lastErrMsg, lastApiName);
 
-	const CSimpleStringA alarmMsgStr = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":%s, \"Context\":%s}"
+	const CSimpleStringA alarmMsgStr = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":\"%s\", \"Context\":\"%s\"}"
 		, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 
 	std::map<std::string, std::string> msgInfo;

+ 1 - 1
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -1669,7 +1669,7 @@ ErrorCodeEnum CIDCertFSM::GetPngBlobEx(CBlob &data, CSimpleStringA fileNamePrefi
 	CSimpleStringA strPath, errMsg, strOldPath;
 	ErrorCodeEnum eErr;
 	eErr = m_pEntity->GetFunction()->GetPath("Dep", strPath);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[Dep]%s,%s", SpStrError(eErr), strPath.GetData());
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[Dep]%s,%s", SpStrError(eErr), strPath.GetData());
 	if (eErr != Error_Succeed)
 	{
 		if (bClear)

+ 15 - 0
Module/mod_ResourceWatcher/ResourceWatcher.xml

@@ -286,6 +286,21 @@
 			<param name="terminalVer" type="string" />
 	      </res>
 	    </twoway>
+		
+		<!--检查文件是否存在-->
+	    <twoway  name="CheckIsFileExists" overlap="true" method_id="21">
+	      <req>
+					<!-- 0: 文件名参数为全路径 -->
+					<!-- 1: 在当前默认音频文件路径(Win: D:/rvc/adData/Audio/; UOS: /opt/rvc/adData/Audio/) 下查找mp3格式文件 -->
+					<!-- 2: 在当前默认视频文件路径(Win: D:/rvc/adData/Video/; UOS: /opt/rvc/adData/Video/) 下查找视频文件 -->
+          <param name="filetype" type="int" />
+					<param name="filename" type="wstring" />
+	      </req>
+        <res>
+          <!-- result	0:成功,其他:windows(GetLastError()),信创:errno -->
+          <param name="result" type="int" />
+        </res>
+	    </twoway>
 	</class>
 
 	<!--缓存清理-->

+ 77 - 67
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -427,20 +427,7 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
     }
 #if defined(RVC_OS_WIN)
     if (m_bFirstRunAfterBoot) {
-		//GetSystemMetrics (SM_CMONITORS) 计数仅显示可见的显示器
-		const int screenNums = GetSystemMetrics(SM_CMONITORS);
-		const int aimScreenNums4Stand2S = 2;
-		const int aimScreenNums4Other = 1;
-		if (0 == m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Stand2S) {
-			LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
-				, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
-                    , m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Stand2S, screenNums));
-        }
-        else if (0 != m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Other) {
-			LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
-				, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
-					, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Other, screenNums));
-        }
+
     }
     
 #endif //RVC_OS_WIN
@@ -486,60 +473,11 @@ void ResourceWatcherFSM::AfterInit()
 		GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
     }
 	DetectVersionHasChangedAndWarnCover();
-
 #else
-    if (m_bFirstRunAfterBoot) {
-        //获取系统激活状态
-        CSimpleStringA value(true);
-        CSimpleStringA warnMsg(true);
-        bool res = GetSysActiveStatus(value);
-        if (!value.IsNullOrEmpty()) {
-            auto elems = value.Split('|');
-            std::map<std::string, std::string> info;
-            info["subject"] = "system_activation";
-            if (elems.GetCount() > 0) {
-                for (int i = 0; i < elems.GetCount(); ++i) {
-                    auto sub_elems = elems[i].Split(':');
-                    if (sub_elems.GetCount() == 2) {
-                        CSimpleStringA val = sub_elems[1].GetData();
-                        CSimpleStringA key(true);
-                        //因为UOS内容用了中文的冒号,而Split函数无法拆分中文冒号(拆出来前面的内容有乱码),只能这样去操作
-                        if (sub_elems[0].IndexOf("服务器") != -1) {
-                            key = "server_addr";
-                        } else if (sub_elems[0].IndexOf("激活状") != -1) {
-                            key = "activation_status";
-                        }
-                        else if(sub_elems[0].IndexOf("授权状") != -1) {
-                            key = "authorization_status";
-                        }
-                        else if(sub_elems[0].IndexOf("到期时") != -1) {
-                            key = "deadline_status";
-                        }
-                        else if (sub_elems[0].IndexOf("序列") != -1) {
-                            key = "serial_number";
-                            if (val.GetLength() >= 23) {
-                                //NNAAA-7AAAY-*****-*****-MT6SK
-                                val[12] = val[13] = val[14] = val[15] = val[16] = '*';
-                                val[18] = val[19] = val[20] = val[21] = val[22] = '*';
-                            }
-                        }
-                        else {
-                            key = CSimpleStringA::Format("other%02d", i);
-                        }
-                        info[key.GetData()] = val.GetData();
-                    }
-                }
-            }
-            info["fetch_status"] = "succ";
-            std::pair<bool, std::string> strResult;
-            strResult = generateJsonStr(info);
-            value = strResult.second.c_str();
-        }
-        else {
-            warnMsg = CSimpleStringA::Format("{\"subject\":\"system_activation\", \"fetch_status\":\"failed\"}");
-        }
-        LogWarn(Severity_Low, Error_Debug, LOG_INFO_SYSTEM_ACTIVATION_INFO, value);
-    }
+	if (m_bFirstRunAfterBoot) {
+		AggerateAutoStatTask* task = new AggerateAutoStatTask(this);
+		GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
+	}
 #endif //RVC_OS_WIN
 }
 
@@ -2033,6 +1971,24 @@ int ResourceWatcherFSM::InitialAutoStartupSetType()
     return ret;
 }
 
+void ResourceWatcherFSM::UploadScreenInfo()
+{
+	//GetSystemMetrics (SM_CMONITORS) 计数仅显示可见的显示器
+	const int screenNums = GetSystemMetrics(SM_CMONITORS);
+	const int aimScreenNums4Stand2S = 2;
+	const int aimScreenNums4Other = 1;
+	if (0 == m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Stand2S) {
+		LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
+			, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
+				, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Stand2S, screenNums));
+	}
+	else if (0 != m_RvcSysinfo.strMachineType.Compare("RVC.Stand2S", true) && screenNums != aimScreenNums4Other) {
+		LogWarn(Severity_Low, Error_Unexpect, LOG_RESOURCEWATCHER_LACK_OF_MONITOR
+			, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
+				, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Other, screenNums));
+	}
+}
+
 void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
 {
 	std::vector<std::string> userlist;
@@ -4794,6 +4750,60 @@ void ResourceWatcherFSM::UploadSysVersionInfo(UINT& ver)
     LogWarn(Severity_Low, Error_Hardware, LOG_RESOURCEWATCHER_SYSTEMINFO, ret.second.c_str());
 }
 
+void ResourceWatcherFSM::UploadSysActivationStatus()
+{
+	//获取系统激活状态
+	CSimpleStringA value(true);
+	CSimpleStringA warnMsg(true);
+	bool res = GetSysActiveStatus(value);
+	if (!value.IsNullOrEmpty()) {
+		auto elems = value.Split('|');
+		std::map<std::string, std::string> info;
+		info["subject"] = "system_activation";
+		if (elems.GetCount() > 0) {
+			for (int i = 0; i < elems.GetCount(); ++i) {
+				auto sub_elems = elems[i].Split(':');
+				if (sub_elems.GetCount() == 2) {
+					CSimpleStringA val = sub_elems[1].GetData();
+					CSimpleStringA key(true);
+					//因为UOS内容用了中文的冒号,而Split函数无法拆分中文冒号(拆出来前面的内容有乱码),只能这样去操作
+					if (sub_elems[0].IndexOf("服务器") != -1) {
+						key = "server_addr";
+					}
+					else if (sub_elems[0].IndexOf("激活状") != -1) {
+						key = "activation_status";
+					}
+					else if (sub_elems[0].IndexOf("授权状") != -1) {
+						key = "authorization_status";
+					}
+					else if (sub_elems[0].IndexOf("到期时") != -1) {
+						key = "deadline_status";
+					}
+					else if (sub_elems[0].IndexOf("序列") != -1) {
+						key = "serial_number";
+						if (val.GetLength() >= 23) {
+							//NNAAA-7AAAY-*****-*****-MT6SK
+							val[12] = val[13] = val[14] = val[15] = val[16] = '*';
+							val[18] = val[19] = val[20] = val[21] = val[22] = '*';
+						}
+					}
+					else {
+						key = CSimpleStringA::Format("other%02d", i);
+					}
+					info[key.GetData()] = val.GetData();
+				}
+			}
+		}
+		info["fetch_status"] = "succ";
+		std::pair<bool, std::string> strResult;
+		strResult = generateJsonStr(info);
+		value = strResult.second.c_str();
+	}
+	else {
+		warnMsg = CSimpleStringA::Format("{\"subject\":\"system_activation\", \"fetch_status\":\"failed\"}");
+	}
+	LogWarn(Severity_Low, Error_Debug, LOG_INFO_SYSTEM_ACTIVATION_INFO, value);
+}
 
 string ResourceWatcherFSM::MemoryProcessStatus()
 {

+ 13 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -287,7 +287,7 @@ public:
 	/** 返回操作系统当前的版本,比如1032,1010,1031*/
 	UINT GetSystemDisplayVersion(CSimpleStringA& strVersion);
 	void UploadSysVersionInfo(UINT& ver);
-
+	void UploadSysActivationStatus();
 	string MemoryProcessStatus();
 	long GetCPURunTime(CPUInfo* cpu);
 	long ReadProcCPURunTime(DWORD pid, ProcCPUInfo* pInfo);
@@ -321,6 +321,7 @@ public:
 	bool GetRegValue(HKEY hKey, LPCTSTR lpcszParam, CSimpleStringA& strValue);
 
 	void DetectAutoStartupCover();
+	void UploadScreenInfo();
 	//0:explorer.exe
 	//1:vbs
 	//2:vtm.exe
@@ -396,6 +397,16 @@ struct DetectSoftwareInstallStatusTask : public ITaskSp
     }
 };
 
+struct AggerateAutoStatTask : public ITaskSp
+{
+	ResourceWatcherFSM* m_pFSM;
+	AggerateAutoStatTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
+	void Process()
+	{
+		m_pFSM->UploadSysActivationStatus();
+	}
+};
+
 #else
 struct CreateLinkTask :public ITaskSp
 {
@@ -423,6 +434,7 @@ struct AggerateAutoStatTask : public ITaskSp
 	AggerateAutoStatTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
 	void Process()
 	{
+		m_pFSM->UploadScreenInfo();
 		m_pFSM->DetectWallpaperAndWarn();
 		m_pFSM->DetectAutoStartupCover();
 		m_pFSM->RegOperation4LnkFile();

+ 49 - 0
Module/mod_ResourceWatcher/ResourceWatcher_client_g.h

@@ -646,6 +646,55 @@ public:
 		return Error;
 	}
 
+	ErrorCodeEnum CheckIsFileExists(ResourceWatcherService_CheckIsFileExists_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		if (m_context.checkEmpty())
+		{
+			m_context.AutoGenerate();
+			DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
+			m_context = m_context.upgradeLink();
+		}
+		auto ret = pFunc->AsyncRequest(ResourceWatcherService_Method_CheckIsFileExists, ResourceWatcherService_MethodSignature_CheckIsFileExists, Buf, spAsyncWait, m_context, dwTimeout);
+		m_context.clear();
+		return ret;
+	}
+	ErrorCodeEnum CheckIsFileExists(ResourceWatcherService_CheckIsFileExists_Req &Req, ResourceWatcherService_CheckIsFileExists_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CheckIsFileExists(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum CheckIsFileExists(ResourceWatcherService_CheckIsFileExists_Req &Req, ResourceWatcherService_CheckIsFileExists_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CheckIsFileExists(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum CheckIsFileExists(ResourceWatcherService_CheckIsFileExists_Req &Req, ResourceWatcherService_CheckIsFileExists_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = CheckIsFileExists(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			CSimpleString str;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
 
 	bool SafeDelete()
 	{

+ 26 - 0
Module/mod_ResourceWatcher/ResourceWatcher_def_g.h

@@ -24,6 +24,7 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_Method_ProcessDetectThirdPartyProgram 16
 #define ResourceWatcherService_Method_FilesClean 17
 #define ResourceWatcherService_Method_FetchSystemSnapshot 20
+#define ResourceWatcherService_Method_CheckIsFileExists 21
 
 #define ResourceWatcherService_MethodSignature_GetDevInfo 296205965
 #define ResourceWatcherService_MethodSignature_OperateFile 935567963
@@ -37,6 +38,7 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_MethodSignature_ProcessDetectThirdPartyProgram -1692430185
 #define ResourceWatcherService_MethodSignature_FilesClean 624348486
 #define ResourceWatcherService_MethodSignature_FetchSystemSnapshot -1005346345
+#define ResourceWatcherService_MethodSignature_CheckIsFileExists -339255831
 
 #define ResourceWatcherService_LogCode_GetDevInfo "QLR040250A99"
 #define ResourceWatcherService_LogCode_OperateFile "QLR040250A03"
@@ -50,6 +52,7 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_LogCode_ProcessDetectThirdPartyProgram "QLR040250A16"
 #define ResourceWatcherService_LogCode_FilesClean "QLR040250A17"
 #define ResourceWatcherService_LogCode_FetchSystemSnapshot "QLR040250A20"
+#define ResourceWatcherService_LogCode_CheckIsFileExists "QLR040250A21"
 
 struct ResourceWatcherService_GetDevInfo_Req
 {
@@ -411,6 +414,29 @@ struct ResourceWatcherService_FetchSystemSnapshot_Ans
 
 };
 
+struct ResourceWatcherService_CheckIsFileExists_Req
+{
+	int filetype;
+	CSimpleStringW filename;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & filetype & filename;
+	}
+
+};
+
+struct ResourceWatcherService_CheckIsFileExists_Ans
+{
+	int result;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result;
+	}
+
+};
+
 
 ///////////////////////////
 

+ 27 - 0
Module/mod_ResourceWatcher/ResourceWatcher_server_g.h

@@ -114,6 +114,13 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_CheckIsFileExists:
+			if (dwSignature == ResourceWatcherService_MethodSignature_CheckIsFileExists) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -185,6 +192,11 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_CheckIsFileExists:
+			if (dwSignature != ResourceWatcherService_MethodSignature_CheckIsFileExists) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -252,6 +264,11 @@ public:
 	/// override by user
 	}
 
+	virtual void Handle_CheckIsFileExists(SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req, ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
 	virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CAutoBuffer Buf;
@@ -388,6 +405,16 @@ public:
 						Handle_FetchSystemSnapshot(ctx);
 					}
 					break;
+				case ResourceWatcherService_Method_CheckIsFileExists:
+					{
+						SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req,ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req,ResourceWatcherService_CheckIsFileExists_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						pTransactionContext->GetLinkContext(ctx->link);
+						EntityResource::setLink(ctx->link);
+						Handle_CheckIsFileExists(ctx);
+					}
+					break;
 				default:
 					assert(0);
 					break;

+ 79 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -115,6 +115,12 @@ void ResourceWatcherServiceSession::Handle_FetchSystemSnapshot(SpReqAnsContext<R
     m_pEntity->FetchSystemSnapshot(ctx);
 }
 
+void ResourceWatcherServiceSession::Handle_CheckIsFileExists(SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req, ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx)
+{
+    DbgToBeidou(ctx->link, __FUNCTION__)();
+    m_pEntity->CheckIsFileExists(ctx);
+}
+
 void ResourceWatcherServiceSession::Handle_OperateFile
 (SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
     ResourceWatcherService_OperateFile_Ans>::Pointer ctx)
@@ -453,6 +459,30 @@ ErrorCodeEnum SetFileExecutePriviledge(LPCTSTR lpcszDirOrFilePath)
     return result;
 }
 
+static int IsFileExists(const char* pfilename)
+{
+    int iRet = -1;
+#ifdef RVC_OS_WIN
+    if (ExistsFileA(pfilename)) {
+        iRet = 0;
+    }
+    else {
+        iRet = GetLastError(); 
+        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("find file(%s) last error code is %d.", pfilename, iRet);
+    }
+#else
+    struct stat statbuf;
+    if (0 == stat(pfilename, &statbuf)) {
+        iRet = 0;
+    }
+    else {
+        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("find file(%s) errno info is %s.", pfilename, strerror(errno));
+        iRet = errno;
+    }
+#endif // RVC_OS_WIN
+    return iRet;
+}
+
 void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx)
 {
     ErrorCodeEnum result(Error_Succeed);
@@ -2636,6 +2666,55 @@ void ResourceWatcherEntity::FetchSystemSnapshot(
     }
 }
 
+int ResourceWatcherEntity::CheckMediaResource(int iFileType, const char* pFileName)
+{
+    int iRet = -1;
+    CSimpleStringA strRootPath("");
+    CSimpleStringA strFileFolder("");
+    CSimpleStringA strFilePath("");
+    ErrorCodeEnum Error = GetFunction()->GetPath("ADData", strRootPath);
+    if (AudioDefaultPath == iFileType) {
+        strFileFolder = strRootPath + SPLIT_SLASH_STR + "Audio" + SPLIT_SLASH_STR;
+    }
+    else {
+        strFileFolder = strRootPath + SPLIT_SLASH_STR + "Video" + SPLIT_SLASH_STR;
+    }
+    strFilePath = strFileFolder + pFileName;
+
+    iRet = IsFileExists(strFilePath.GetData());
+
+    return iRet;
+}
+
+void ResourceWatcherEntity::CheckIsFileExists(SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req, ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx)
+{
+    int iResult = -1;
+    ErrorCodeEnum Error = Error_Succeed;
+    if (ctx->Req.filename.GetLength() > 0) {
+        CSimpleStringA strFileName = CSimpleStringW2A(ctx->Req.filename);
+        switch (ctx->Req.filetype) {
+        case AbsolutePath:
+            iResult = IsFileExists(strFileName.GetData());
+            break;
+        case AudioDefaultPath:
+        case VideoDefaultPath:
+            iResult = CheckMediaResource(ctx->Req.filetype, strFileName.GetData());
+            break;
+        default:
+            Error = Error_NotSupport;
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A10").setAPI(__FUNCTION__)("目前不支持该类型文件检查");
+            break;
+        }
+    }
+    else {
+        Error = Error_Param;
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A11").setAPI(__FUNCTION__)("要检查的文件名为空");
+    }
+
+    ctx->Ans.result = iResult;
+    ctx->Answer(Error);
+}
+
 #if defined(RVC_OS_WIN)
 
 SP_BEGIN_ENTITY_MAP()

+ 12 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.h

@@ -19,6 +19,10 @@ class ResourceWatcherEntity;
 
 #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)  
 
+const int AbsolutePath = 0;
+const int AudioDefaultPath = 1; 
+const int VideoDefaultPath = 2; 
+
 class ResourceWatcherServiceSession : public ResourceWatcherService_ServerSessionBase
 {
 public:
@@ -51,6 +55,9 @@ public:
 	virtual void Handle_FilesClean(SpReqAnsContext<ResourceWatcherService_FilesClean_Req, ResourceWatcherService_FilesClean_Ans>::Pointer ctx);
 
 	virtual void Handle_FetchSystemSnapshot(SpReqAnsContext<ResourceWatcherService_FetchSystemSnapshot_Req, ResourceWatcherService_FetchSystemSnapshot_Ans>::Pointer ctx);
+
+	virtual void Handle_CheckIsFileExists(SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req, ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx);
+
 private:
 	ResourceWatcherEntity* m_pEntity;
 };
@@ -262,6 +269,11 @@ public:
 	void UninstallSogou(SpReqAnsContext<ResourceWatcherService_UninstallThirdPartyProgram_Req,
 		ResourceWatcherService_UninstallThirdPartyProgram_Ans>::Pointer ctx);
 
+	void CheckIsFileExists(SpReqAnsContext<ResourceWatcherService_CheckIsFileExists_Req, 
+		ResourceWatcherService_CheckIsFileExists_Ans>::Pointer ctx);
+
+	int CheckMediaResource(int iFileType, const char* pFileName);
+
 #if defined(_MSC_VER)
 	SP_BEGIN_MSG_DISPATCH_MAP(ResourceWatcherEntity)
 		SP_BEGIN_ENTITY_MSG("UpgradeManager")

+ 406 - 234
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -6,8 +6,8 @@
 #include  <stdio.h>
 #include  <stdlib.h>
 #include "fileutil.h"
+#include "iniutil.h"
 #include "CommEntityUtil.hpp"
-#include "CommEntityRestful.hpp"
 #include "SpUtility.h"
 #include "comm.h"
 #include "PinPad_client_g.h"
@@ -23,6 +23,10 @@ using namespace PinPad;
 #include <ws2tcpip.h>
 #include <Winsock2.h>
 #include <algorithm>
+#include "WMIDeviceQuery.h"
+#include <WinCrypt.h>
+#include <Strsafe.h>
+#include "DeviceBaseClass.h"
 #pragma comment(lib, "IPHLPAPI.lib")
 #define ALLOW_MULTI_NETWORKD_CARDS
 #endif // RVC_OS_WIN
@@ -128,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();
@@ -264,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是没加密的
@@ -309,6 +283,7 @@ struct UpdateWKTask : ITaskSp
 			else
 			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get keyChek && keyIndex failed.");
+				return;
 			}
 
 			pPinPad->GetFunction()->CloseSession();
@@ -316,6 +291,7 @@ struct UpdateWKTask : ITaskSp
 		else
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to pinpad failed.error code:%d", errRc);
+			return;
 		}
 
 		HttpClientResponseResult result;
@@ -392,46 +368,16 @@ 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)
-		};
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("encTerminalInfo: %s", getTokenReq.encTerminalInfo.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sessionTempPubKey:%s", getTokenReq.sessionTempPubKey.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("terminalNo: %s", getTokenReq.terminalNo.c_str());
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("terminalVersion: %s", getTokenReq.terminalVersion.c_str());
 
-		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);
-		config.SetChildUri("/api/v3/access");
+		config.SetChildUri("/api/v4/access");
 
 		if (m_fsm->containsChinese(m_fsm->GetmAccessAuthHost().GetData()))
 		{
@@ -445,23 +391,10 @@ 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);
-
-		std::string test;
-		test = config.GetRequestUri();
-
+		SP::Module::Restful::FulfillRequestJsonBody(&config, getTokenReq);
 		RestfulClient client = RestfulClient::getInstance();
 		config.PreDo();
+
 		client.Do(&config, &result);
 		if (result.ResponseOK()) {
 			SP::Module::Restful::CommResponseJson responseStatus;
@@ -476,10 +409,12 @@ struct GetTokenTask : ITaskSp
 			{
 				CSimpleStringA tmsg = CSimpleStringA::Format("{\"errcode\": \"%s\", \"message\": %s}",
 					responseStatus.errorCode.c_str(), getTokenAns.warnMessage.c_str());
+				m_entity->SetAuthErrMsg(tmsg.GetData());
 				m_fsm->GetEntityBase()->GetFunction()->SetSysVar("AuthErrMsg", tmsg.GetData(), true);
 			}
 			else
 			{
+				m_entity->SetAuthErrMsg("");
 				m_fsm->GetEntityBase()->GetFunction()->SetSysVar("AuthErrMsg", "", true);
 			}
 
@@ -519,25 +454,13 @@ struct GetTokenTask : ITaskSp
 			}
 
 			m_fsm->AuthLogWarn(result, config.GetRequestUri(), "获取准入token");
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTokenTask Connect Failed.");
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTokenTask Connect Failed. [%s]", result.WhatError().c_str());
 		}
 		FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_ReqTokenFail);
 		m_fsm->PostEventFIFO(pEvent);
 	}
 };
 
-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) {
@@ -594,6 +517,8 @@ void CAccessAuthFSM::doWarnMsg(int errReason, std::string errMsg, bool bNeedEven
 #endif // RVC_OS_WIN
 	if (bNeedEvent) 
 	{
+		auto pEntity = (CAccessAuthEntity*)m_pEntity;
+		pEntity->SetAuthErrMsg(fullErrMsg.c_str());
 		const ErrorCodeEnum ec = m_pEntity->GetFunction()->SetSysVar("AuthErrMsg", fullErrMsg.c_str(), true);
 		if (ec != Error_Succeed) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Update SysVar failed: 0x%X", ec);
@@ -601,6 +526,7 @@ void CAccessAuthFSM::doWarnMsg(int errReason, std::string errMsg, bool bNeedEven
 		
 		if (errReason == ERR_ACCESSAUTH_SERVICE_FAILED)
 		{
+			pEntity->SetAuthErrMsg(errMsg.c_str());
 			m_pEntity->GetFunction()->SetSysVar("AuthErrMsg", errMsg.c_str(), true);
 			LogEvent(Severity_Middle, ERR_ACCESSAUTH_SERVICE_FAILED, errMsg.c_str());
 		}
@@ -889,7 +815,6 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
 		{
 			pEntity->SetAuthErrMsg("保存令牌失败");
 			pEntity->GetFunction()->SetSysVar("AuthErrMsg", "保存令牌失败", true);
-			pEntity->SetAuthErrMsg("保存令牌失败");
 			doWarnMsg(ERR_ACCESSAUTH_SAVE_TOKEN, "保存令牌失败", true);
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5208")(GetOutPutStr("%s%08X", "SaveTokenAndSharedSK", rc).c_str());
 		}
@@ -897,112 +822,55 @@ 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);
+	bool bPinPadOnline = false;
+	pEntity->GetPinPadModel(pinpadModel, 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];
-
-	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];
+	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();
+	termInfo["pinpadModel"] = pinpadModel.GetData();
+
+	std::pair<bool, std::string> strResult;
+	strResult = generateJsonStr(termInfo);
+
+	char* pBuf = new char[2048];
+	int len = 0;
+#ifdef RVC_OS_WIN
+	string tmpStr = strResult.second;
+	SP::Module::Util::ConvertGBKToUtf8(tmpStr);
+	strcpy(pBuf, tmpStr.c_str()); //GBK转UTF8
+	len = tmpStr.size();
+#else
+	strcpy(pBuf, strResult.second.c_str());
+	len = strResult.second.size();
+#endif // RVC_OS_WIN
 
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HardWareInfo: %s", pBuf);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HardWareInfo size: %d", len);
 
 	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) 
 	{
@@ -1052,26 +920,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;
@@ -1079,23 +935,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;
 }
 
@@ -1103,9 +950,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());
@@ -1167,3 +1014,328 @@ void CAccessAuthFSM::GetNetMsg(SpReqAnsContext<AccessAuthService_GetNetMsg_Req,
 
 	ctx->Answer(Error_Succeed);
 }
+
+CSimpleStringA CAccessAuthFSM::GetOsVersion()
+{
+	std::map<std::string, std::string> errInfo;
+	CSimpleStringA errMsg;
+	errInfo["errcode"] = "RTA5219";
+	errInfo["msg"] = "调用系统api获取操作系统版本失败";
+
+#if defined(RVC_OS_WIN)
+	CSimpleStringA runInfoPath;
+	ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
+	if (eErr != Error_Succeed) {
+		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GetPath runinfo error=%s.", SpStrError(eErr));
+		errInfo["getLastErr"] = GetLastError();
+		errMsg = generateJsonStr(errInfo).second.c_str();
+		return errMsg;
+	}
+	runInfoPath += "\\runcfg\\osverion";
+	ifstream is;
+	is.open(runInfoPath.GetData(), ios::binary);
+	if (!is.is_open())
+	{
+		DWORD dwErr = GetLastError();
+		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open runcfg\\osverion file failed. [%d]", dwErr);
+		errInfo["getLastErr"] = dwErr;
+		errMsg = generateJsonStr(errInfo).second.c_str();
+		return errMsg;
+	}
+	string line;
+	while (!is.eof()) {
+		getline(is, line);
+		int start = line.find("版本");
+		if (start != string::npos)
+			//return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
+			return CSimpleStringA(line.c_str());
+		else
+			continue;
+	}
+
+	errInfo["getLastErr"] = GetLastError();
+	errMsg = generateJsonStr(errInfo).second.c_str();
+	return errMsg;
+#else
+	std::map<std::string, std::string> osInfo;
+	const char filePath[] = "/etc/os-version";
+	char tmp[33];
+	memset(tmp, 0, 33);
+	inifile_read_str_s("Version", "SystemName", "unknown", tmp, 32, filePath);
+	osInfo["SystemName"] = tmp;
+	memset(tmp, 0, 33);
+	inifile_read_str_s("Version", "ProductType", "unknown", tmp, 32, filePath);
+	osInfo["ProductType"] = tmp;
+	memset(tmp, 0, 33);
+	inifile_read_str_s("Version", "MajorVersion", "unknown", tmp, 32, filePath);
+	osInfo["MajorVersion"] = tmp;
+	memset(tmp, 0, 33);
+	inifile_read_str_s("Version", "MinorVersion", "unknown", tmp, 32, filePath);
+	osInfo["MinorVersion"] = tmp;
+	memset(tmp, 0, 33);
+	inifile_read_str_s("Version", "OsBuild", "unknown", tmp, 32, filePath);
+	osInfo["OsBuild"] = tmp;
+	return generateJsonStr(osInfo).second.c_str();
+#endif
+}
+
+void CAccessAuthFSM::GetIPandMac(CSimpleStringA& ip, CSimpleStringA& mac)
+{
+	CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
+	ErrorCodeEnum rc = SP::Module::Net::GetINETMacAddresses(netList);
+	std::map<std::string, std::string> errInfo;
+	if (rc != Error_Succeed)
+	{
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Get sys netinfo failed!. rc=%d.", rc);
+		errInfo["errcode"] = "RTA5216";
+		errInfo["msg"] = "调用系统api获取ip失败";
+		errInfo["getLastErr"] = GetLastError();
+		ip = generateJsonStr(errInfo).second.c_str();
+
+		errInfo["errcode"] = "RTA5217";
+		errInfo["msg"] = "调用系统api获取mac地址失败";
+		errInfo["getLastErr"] = GetLastError();
+		mac = generateJsonStr(errInfo).second.c_str();
+
+		auto pEntity = (CAccessAuthEntity*)m_pEntity;
+		pEntity->SetAuthErrMsg("获取本地ip和mac失败");
+		return;
+	}
+
+	CSimpleStringA csMac(""), csIP(""), csDNS("");
+	for (int i = 0; i < netList.GetCount(); i++) {
+		if (!csMac.IsNullOrEmpty()) {
+			csMac += ";";
+		}
+		csMac += netList[i].mac.c_str();
+	}
+	mac = csMac;
+	
+	for (int i = 0; i < netList.GetCount(); i++) {
+		if (!csIP.IsNullOrEmpty()) {
+			csIP += ";";
+		}
+		csIP += netList[i].ip.c_str();
+	}
+	ip = csIP;
+
+	return;
+}
+
+void CAccessAuthFSM::GetHardWareInfo(CSimpleStringA & cpu, CSimpleStringA & mainBoard, CSimpleStringA & disk)
+{
+	auto pEntity = (CAccessAuthEntity*)m_pEntity;
+	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 bGetFromRunCfg = false;
+	CSimpleString csInfo, strErrMsg, strRet;
+	CSmartPointer<IConfigInfo> pConfigRun;
+	ErrorCodeEnum eErr = GetEntityBase()->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());
+		CAutoArray<CSimpleStringA> sysInfo = csInfo.Split('|');
+		if (sysInfo.GetCount() == 3)
+		{
+			cpu = sysInfo[0];
+			mainBoard = sysInfo[1];
+			disk = sysInfo[2];
+			bGetFromRunCfg = true;
+		}
+	}
+	else
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTermSysInfo, OpenConfig Config_Run error=%d.", eErr);
+
+#ifdef RVC_OS_LINUX
+	char szTmp[1024] = {};
+	string strTmp;
+	int nTmpBufLen = 1024;
+	CSmartPointer<IEntityFunction> spFunction = GetEntityBase()->GetFunction();
+
+	CSimpleStringA runInfoPath;
+	auto rc = GetEntityBase()->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();
+			cpu = generateJsonStr(errInfo).second.c_str();
+		}
+
+		strErrMsg = CSimpleStringA::Format("查询CPU ID失败,请重启机器并重新初始化");
+		pEntity->SetAuthErrMsg((const char*)strErrMsg);
+
+		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;
+	}
+	cpu = 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();
+			mainBoard = generateJsonStr(errInfo).second.c_str();
+		}
+		strErrMsg = CSimpleStringA::Format("查询主板序列号失败,  请重启机器并重新初始化");
+		pEntity->SetAuthErrMsg((const char*)strErrMsg);
+
+		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;
+	}
+	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()))
+	{
+		if (!bGetFromRunCfg)
+		{
+			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);
+
+		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;
+	}
+	strRet += "|";
+	strTmp = "";
+	vector<string>::iterator it = diskArr.begin();
+	while (it != diskArr.end()) {
+		strTmp += *it;
+		it++;
+	}
+	strRet += strTmp.c_str();
+	disk = strTmp.c_str();
+#else
+	ULONGLONG ullStart = GetTickCount64();
+	char szTmp[1024] = {};
+	int nTmpBufLen = 1024;
+	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);
+
+		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")
+			(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "Processor", GetLastError()).c_str());
+		return;
+	}
+	strRet = szTmp;
+	cpu = 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();
+			mainBoard = generateJsonStr(errInfo).second.c_str();
+		}
+		strErrMsg = CSimpleStringA::Format("查询 baseboard sn 失败: %d, 请尝试重启应用", GetLastError());
+		pEntity->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")
+			(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
+		
+		return;
+	}
+
+	strRet += "|";
+	strRet += szTmp;
+	mainBoard = 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();
+			disk = generateJsonStr(errInfo).second.c_str();
+		}
+		strErrMsg = CSimpleStringA::Format("查询 harddisk sn 失败: %d, 请尝试重启应用", GetLastError());
+		pEntity->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());
+		
+		return;
+	}
+
+	strRet += "|";
+	strRet += szTmp;
+	disk = 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 (!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"
+			, csInfo.GetData(), strRet.GetData(), eErr);
+	}
+	else
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device info: [%s]", strRet.GetData());
+
+	return;
+	
+}

+ 75 - 358
Module/mod_accessauth/AccessAuthFSM.h

@@ -7,6 +7,7 @@
 #include "AccessAuthConn.h"
 #include "IHttpFunc.h"
 #include "json/json.h"
+#include "CommEntityRestful.hpp"
 
 #ifdef RVC_OS_WIN
 ///*TODO:  (80374374@11/27/2023)*/
@@ -26,394 +27,106 @@ static void GetLocalTimeRVC(SYSTEMTIME& stTime)
 #define REFLECTION(var) #var
 #define JUAGEHTTPS(ret) (ret.m_sysCode == 200 || ret.m_sysCode == 201)
 
-#ifdef RVC_OS_WIN
-typedef struct CSessionkeySynReq : CHTTPReq {
-	string terminalNo;
-	long curTime;
-
-	string ToJson() {
-		Json::Value value;
-		value[REFLECTION(terminalNo)] = terminalNo;
-		value[REFLECTION(curTime)] = curTime;
-		Json::FastWriter writer;
-		string strData = writer.write(value);
-
-		/*DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CSessionkeySynReq")
-			("req=%s at CSessionkeySynReq", strData.c_str());*/
-
-		return strData;
-	}
+typedef struct CSessionkeySynReq
+{
+	std::string terminalNo;
+	int curTime;
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, curTime)
 } CSessionkeySynReq;
 
-typedef struct CSessionkeySynRet : CHTTPRet {
-	struct data {
-		long timeDiff;
-		string sessionKey;
-	} data;
-	bool Parse(string strData) {
-		/*DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CSessionkeySynRet")
-			("ret=%s at CSessionkeySynRet", strData.c_str());*/
-
-		Json::Value root;
-		Json::Reader reader;
-		reader.parse(strData, root, false);
-
-		data.timeDiff = root["data"][REFLECTION(timeDiff)].asInt();
-		data.sessionKey = root["data"][REFLECTION(sessionKey)].asString();
-		return true;
-	}
-} CSessionkeySynRet;
-
-typedef struct CAccessAuthUpdateWKReq : CHTTPReq {
-	string terminalNo;
-	string encRandom;
+typedef struct CSessionkeySynAns
+{
+	int timeDiff;
+	int authVersion;
+	std::string sessionKey;
+	std::string reserved;
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(timeDiff, authVersion, sessionKey, reserved)
+}CSessionkeySynAns;
+
+typedef struct CAccessAuthUpdateWKReq
+{
+	std::string terminalNo;
+	std::string encRandom;
 	string tpkKeyCheck; //tpk密钥校验值
 	string edkKeyCheck; //edk密钥校验值
 	string keyIndex; //密钥序号
-	string ToJson() {
-		Json::Value value;
-		value[REFLECTION(terminalNo)] = terminalNo;
-		value[REFLECTION(encRandom)] = encRandom;
-		value[REFLECTION(tpkKeyCheck)] = tpkKeyCheck;
-		value[REFLECTION(edkKeyCheck)] = edkKeyCheck;
-		value[REFLECTION(keyIndex)] = keyIndex;
-		Json::FastWriter writer;
-		string strData = writer.write(value);
-		/*DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CAccessAuthUpdateWKReq")
-			("req=%s at CAccessAuthUpdateWKReq", strData.c_str());*/
-
-		return strData;
-	}
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, encRandom, tpkKeyCheck, edkKeyCheck, keyIndex)
 } CAccessAuthUpdateWKReq;
 
-typedef struct CAccessAuthUpdateWKRet : CHTTPRet {
+typedef struct CAccessAuthUpdateWKAns
+{
+	string tmk;
 	string tpk;
 	string edk;
 	string tpkKeyCheck; //密钥校验值
 	string edkKeyCheck; //edk密钥校验值
 	string keyIndex; //密钥序号
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(tmk, tpk, edk, tpkKeyCheck, edkKeyCheck, keyIndex)
+} CAccessAuthUpdateWKAns;
 
-	bool Parse(string strData) {
-		Json::Value root;
-		Json::Reader reader;
-		reader.parse(strData, root, false);
-
-		tpk = root["data"][REFLECTION(tpk)].asString();
-		edk = root["data"][REFLECTION(edk)].asString();
-		tpkKeyCheck = root["data"][REFLECTION(tpkKeyCheck)].asString();
-		edkKeyCheck = root["data"][REFLECTION(edkKeyCheck)].asString();
-		keyIndex = root["data"][REFLECTION(keyIndex)].asString();
-
-		return true;
-	}
-} CAccessAuthUpdateWKRet;
-#endif // RVC_OS_WIN
-
-typedef struct CAccessAuthGetTokenReq :public CHTTPReq {
-public:
-	string installVersion;//终端版本(新加字段)
-	string terminalCharacter;
+typedef struct CAccessAuthGetTokenReq
+{
+	string terminalVersion;//终端版本(新加字段)
 	string terminalNo;
 	string sessionTempPubKey;
 	string encTerminalInfo;
-	string publicKeySM;
-	string pinPadID;
-	string existPinPad;
-
-	string ToJson() {
-#ifdef RVC_OS_WIN
-		Json::Value value;
-		value[REFLECTION(installVersion)] = installVersion;
-		value[REFLECTION(terminalCharacter)] = terminalCharacter;
-		value[REFLECTION(terminalNo)] = terminalNo;
-		value[REFLECTION(sessionTempPubKey)] = sessionTempPubKey;
-		value[REFLECTION(encTerminalInfo)] = encTerminalInfo;
-		value[REFLECTION(publicKeySM)] = publicKeySM;
-		value[REFLECTION(pinPadID)] = pinPadID;
-		value[REFLECTION(existPinPad)] = existPinPad;
-
-		Json::FastWriter writer;
-		string strData = writer.write(value);
-		/*DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CAccessAuthGetTokenReq")
-			("req=%s at CAccessAuthGetTokenReq", strData.c_str());*/
-
-		return strData;
-#else
-		RVCJson rvcJson(true);
-		rvcJson.AddStringToObject(REFLECTION(installVersion), (char*)installVersion.c_str());
-		rvcJson.AddStringToObject(REFLECTION(terminalCharacter), (char*)terminalCharacter.c_str());
-		rvcJson.AddStringToObject(REFLECTION(terminalNo), (char*)terminalNo.c_str());
-		rvcJson.AddStringToObject(REFLECTION(sessionTempPubKey), (char*)sessionTempPubKey.c_str());
-		rvcJson.AddStringToObject(REFLECTION(encTerminalInfo), (char*)encTerminalInfo.c_str());
-		rvcJson.AddStringToObject(REFLECTION(publicKeySM), (char*)publicKeySM.c_str());
-		rvcJson.AddStringToObject(REFLECTION(pinPadID), (char*)pinPadID.c_str());
-		rvcJson.AddStringToObject(REFLECTION(existPinPad), (char*)existPinPad.c_str());
-		string ret;
-		char* tmp = rvcJson.GetJsonStr();
-		ret.assign(tmp);
-		delete tmp;
-		/*DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CAccessAuthGetTokenReq")
-			("req=%s at CAccessAuthGetTokenReq", ret.c_str());*/
-		return ret;
-#endif // RVC_OS_WIN
-	}
-}CAccessAuthGetTokenReq;
-
-typedef struct CAccessAuthGetTokenRet : CHTTPRet {
-	typedef struct AccessToken {
-		string enToken;
-		string retHash;
-	} AccessToken;
-	typedef struct SharedKey {
-		string enToken;
-		string sharedSK;
-		string retHash;
-	} ShareKey;
-	struct data {
-		AccessToken accessToken;
-		SharedKey sharedKey;
-#ifdef RVC_OS_WIN
-		int flag; //0:非高故障设备,1:高故障设备
-		string warnMessage; //告警提示信息
-#endif // RVC_OS_WIN
-	} data;
-	bool Parse(string strData) {
-#ifdef RVC_OS_WIN
-		Json::Value root;
-		Json::Reader reader;
-		reader.parse(strData, root, false);
-
-		data.accessToken.enToken = root["data"][REFLECTION(accessToken)][REFLECTION(enToken)].asString();
-		data.accessToken.retHash = root["data"][REFLECTION(accessToken)][REFLECTION(retHash)].asString();
-		data.sharedKey.enToken = root["data"][REFLECTION(sharedKey)][REFLECTION(enToken)].asString();
-		data.sharedKey.sharedSK = root["data"][REFLECTION(sharedKey)][REFLECTION(sharedSK)].asString();
-		data.sharedKey.retHash = root["data"][REFLECTION(sharedKey)][REFLECTION(retHash)].asString();
-		data.flag = root["data"][REFLECTION(flag)].asInt();
-		data.warnMessage = root["data"][REFLECTION(warnMessage)].asString();
-
-		return true;
-#else
-		//Dbg("ret=%s at CAccessAuthGetTokenRet", strData.c_str());
-		if (m_userCode.compare(ACS_SUCCESS)) return true;
-		RVCJson rvcJson;
-		rvcJson.SetJson(strData.c_str());
-
-		auto dataJson = rvcJson.GetJsonValue(REFLECTION(data));
-		auto tokenJson = dataJson->GetJsonValue(REFLECTION(accessToken));
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalVersion, terminalNo, sessionTempPubKey, encTerminalInfo)
+} CAccessAuthGetTokenReq;
 
-		data.accessToken.enToken = tokenJson->GetStringValue(REFLECTION(enToken));
-		data.accessToken.retHash = tokenJson->GetStringValue(REFLECTION(retHash));
-		tokenJson->Destory();
-		delete tokenJson;
-
-		auto sharedJson = dataJson->GetJsonValue(REFLECTION(sharedKey));
-
-		data.sharedKey.enToken = sharedJson->GetStringValue(REFLECTION(enToken));
-		data.sharedKey.sharedSK = sharedJson->GetStringValue(REFLECTION(sharedSK));
-		char* tmp = sharedJson->GetStringValue(REFLECTION(retHash));
-		data.sharedKey.retHash = tmp == NULL ? "" : tmp;
-
-		sharedJson->Destory();
-		delete sharedJson;
-		dataJson->Destory();
-		delete dataJson;
-
-		rvcJson.Destory();
-		return true;
-#endif // RVC_OS_WIN
-	}
-} CAccessAuthGetTokenRet;
+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)
+};
 
-typedef struct CInitlizerMKReq : CHTTPReq {
-	string enrolAddr;
-	string enrolGPS;
-	string installVersion;
-	string ip;
-	string machineModel;
-	string machineType;
-	string padDeviceID;
-	string site;
+typedef struct CAccessAuthGetTokenAns
+{
+	AccessTokenJson accessToken;
+	SharedKeyJson sharedKey;
+	bool flag;
+	string warnMessage;
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(accessToken, sharedKey, flag, warnMessage)
+} CAccessAuthGetTokenAns;
+
+typedef struct CInitlizerMKReq
+{
+	string iniTerminalInfo;
+	string terminalVersion;
 	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; //密钥序号
+	string curTpkKeyCheck; //密钥校验值
+	string curEdkKeyCheck; //密钥校验值
+	string curKeyIndex; //密钥序号
 
-	string ToJson() {
-#ifdef RVC_OS_WIN
-		Json::Value value;
-		value[REFLECTION(enrolAddr)] = enrolAddr;
-		value[REFLECTION(enrolGPS)] = enrolGPS;
-		value[REFLECTION(installVersion)] = installVersion;
-		value[REFLECTION(ip)] = ip;
-		value[REFLECTION(machineModel)] = machineModel;
-		value[REFLECTION(machineType)] = machineType;
-		value[REFLECTION(padDeviceID)] = padDeviceID;
-		value[REFLECTION(site)] = site;
-		value[REFLECTION(terminalNo)] = terminalNo;
-		value[REFLECTION(factory)] = factory;
-		value[REFLECTION(modal)] = modal;
-		value[REFLECTION(type)] = type;
-		value[REFLECTION(version)] = version;
-		value[REFLECTION(terminalCharacter)] = terminalCharacter;
-		value[REFLECTION(pinPadID)] = pinPadID;
-		value[REFLECTION(publicKey)] = publicKey;
-		value[REFLECTION(user)] = user;
-		value[REFLECTION(password)] = password;
-		value[REFLECTION(auth)] = auth;
-		value[REFLECTION(loginWay)] = loginWay;
-		value[REFLECTION(encRandom)] = encRandom;
-		value[REFLECTION(tpkKeyCheck)] = tpkKeyCheck;
-		value[REFLECTION(edkKeyCheck)] = edkKeyCheck;
-		value[REFLECTION(keyIndex)] = keyIndex;
-		Json::FastWriter writer;
-		string strData = writer.write(value);
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(iniTerminalInfo, terminalVersion, terminalNo, publicKey, user, auth,
+		loginWay, encRandom, curTpkKeyCheck, curEdkKeyCheck, curKeyIndex)
 
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CInitlizerMKReq")("CInitlizerMKReq:%s", strData.c_str());
-
-		return strData;
-#else
-		RVCJson rvcJson(true);
-		rvcJson.AddStringToObject(REFLECTION(enrolAddr), (char*)enrolAddr.c_str());
-		rvcJson.AddStringToObject(REFLECTION(enrolGPS), (char*)enrolGPS.c_str());
-		rvcJson.AddStringToObject(REFLECTION(installVersion), (char*)installVersion.c_str());
-		rvcJson.AddStringToObject(REFLECTION(ip), (char*)ip.c_str());
-		rvcJson.AddStringToObject(REFLECTION(machineModel), (char*)machineModel.c_str());
-		rvcJson.AddStringToObject(REFLECTION(machineType), (char*)machineType.c_str());
-		rvcJson.AddStringToObject(REFLECTION(padDeviceID), (char*)padDeviceID.c_str());
-		rvcJson.AddStringToObject(REFLECTION(site), (char*)site.c_str());
-		rvcJson.AddStringToObject(REFLECTION(terminalNo), (char*)terminalNo.c_str());
-		rvcJson.AddStringToObject(REFLECTION(factory), (char*)factory.c_str());
-		rvcJson.AddStringToObject(REFLECTION(modal), (char*)modal.c_str());
-		rvcJson.AddStringToObject(REFLECTION(type), (char*)type.c_str());
-		rvcJson.AddStringToObject(REFLECTION(version), (char*)version.c_str());
-		rvcJson.AddStringToObject(REFLECTION(terminalCharacter), (char*)terminalCharacter.c_str());
-		rvcJson.AddStringToObject(REFLECTION(pinPadID), (char*)pinPadID.c_str());
-		rvcJson.AddStringToObject(REFLECTION(publicKey), (char*)publicKey.c_str());
-		rvcJson.AddStringToObject(REFLECTION(user), (char*)user.c_str());
-		rvcJson.AddStringToObject(REFLECTION(password), (char*)password.c_str());
-		rvcJson.AddStringToObject(REFLECTION(auth), (char*)auth.c_str());
-		rvcJson.AddNumberToObject(REFLECTION(loginWay), loginWay);
-		rvcJson.AddStringToObject(REFLECTION(encRandom), (char*)encRandom.c_str());
-		rvcJson.AddStringToObject(REFLECTION(tpkKeyCheck), (char*)tpkKeyCheck.c_str());
-		rvcJson.AddStringToObject(REFLECTION(edkKeyCheck), (char*)edkKeyCheck.c_str());
-		rvcJson.AddStringToObject(REFLECTION(keyIndex), (char*)keyIndex.c_str());
-		string ret;
-		char* tmp = rvcJson.GetJsonStr();
-		ret.assign(tmp);
-		delete tmp;
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CInitlizerMKReq")("req=%s at CInitlizerMKReq", ret.c_str());
-		rvcJson.Destory();
-		return ret;
-#endif // RVC_OS_WIN
-	}
 } CInitlizerMKReq;
 
-typedef struct CInitlizerMKRet : CHTTPRet {
-#ifdef RVC_OS_WIN
-	string tpk;
-	string edk;
+typedef struct CInitlizerMKAns
+{
+	string TMK;
+	string TPK;
+	string EDK;
 	string tpkKeyCheck;
 	string edkKeyCheck;
 	string keyIndex;
-
-	bool Parse(string strData) {
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CInitlizerMKRet")("ret=%s at CInitlizerMKRet", strData.c_str());
-
-		Json::Value root;
-		Json::Reader reader;
-		reader.parse(strData, root, false);
-		tpk = root["data"][REFLECTION(tpk)].asString();
-		edk = root["data"][REFLECTION(edk)].asString();
-		tpkKeyCheck = root["data"][REFLECTION(tpkKeyCheck)].asString();
-		edkKeyCheck = root["data"][REFLECTION(edkKeyCheck)].asString();
-		keyIndex = root["data"][REFLECTION(keyIndex)].asString();
-		return true;
-	}
-#else
-	struct data {
-		string TMK;
-		string TPK;
-		string EDK;
-		string tpkKeyCheck;
-		string edkKeyCheck;
-		string keyIndex;
-		string reserved;
-	} data;
-	bool Parse(string strData) {
-		//Dbg("ret=%s at CInitlizerMKRet", strData.c_str());
-		if (m_userCode.compare(ACS_SUCCESS)) return true;
-		RVCJson rvcJson;
-		rvcJson.SetJson((char*)strData.c_str());
-		auto retJson = rvcJson.GetJsonValue(REFLECTION(data));
-		data.TMK = retJson->GetStringValue(REFLECTION(tmk));
-		data.TPK = retJson->GetStringValue(REFLECTION(tpk));
-		data.EDK = retJson->GetStringValue(REFLECTION(edk));
-		data.tpkKeyCheck = retJson->GetStringValue(REFLECTION(tpkKeyCheck));
-		data.edkKeyCheck = retJson->GetStringValue(REFLECTION(edkKeyCheck));
-		data.keyIndex = retJson->GetStringValue(REFLECTION(keyIndex));
-		rvcJson.Destory();
-		retJson->Destory();
-		delete retJson;
-		return true;
-	}
-#endif // RVC_OS_WIN
-} CInitlizerMKRet;
-
-#ifdef RVC_OS_WIN
-typedef struct CAccessAuthInitDeviceReq : CHTTPReq {
-	string cr1;
-	string cr3;
-	string r2;
-	string cDevPubKey;
-	string vendor;
-	string terminalNo;
-	string ToJson() {
-		Json::Value value;
-		value[REFLECTION(cr1)] = cr1;
-		value[REFLECTION(cr3)] = cr3;
-		value[REFLECTION(r2)] = r2;
-		value[REFLECTION(cDevPubKey)] = cDevPubKey;
-		value[REFLECTION(vendor)] = vendor;
-		value[REFLECTION(terminalNo)] = terminalNo;
-
-		Json::FastWriter writer;
-		string strData = writer.write(value);
-		//Dbg("CAccessAuthInitDeviceReq:%s", strData.c_str());
-		return strData;
-}
-} CAccessAuthInitDeviceReq;
-
-typedef struct CAccessAuthInitDeviceRet : CHTTPRet {
-	string r3;
-	string cr2;
-	string r1;
-	string devPubKey;
-
-	bool Parse(string strData) {
-		Json::Value root;
-		Json::Reader reader;
-		reader.parse(strData, root, false);
-		r3 = root["data"][REFLECTION(r3)].asString();
-		cr2 = root["data"][REFLECTION(cr2)].asString();
-		r1 = root["data"][REFLECTION(r1)].asString();
-		devPubKey = root["data"][REFLECTION(devPubKey)].asString();
-
-		return true;
-	}
-} CAccessAuthInitDeviceRet;
-#endif // RVC_OS_WIN
+	string reserved;
+	JSONCONVERT2OBJECT_MEMEBER_REGISTER(TMK, TPK, EDK, tpkKeyCheck, edkKeyCheck, keyIndex)
+		JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("tmk", "tpk", "edk", "tpkKeyCheck", "edkKeyCheck", "keyIndex")
+} CInitlizerMKAns;
 
 class MyMutex;
 class CAccessAuthFSM : public FSMImpl<CAccessAuthFSM>, public IFSMStateHooker
@@ -476,7 +189,7 @@ public:
 	void doWarnMsg(int errReason, std::string errMsg, bool bNeedEvent = false, string varMsg = "");
 	DWORD HandleTimeSyn(long nTimeDiff, BYTE* nSessionKey);
 	DWORD HandleGetToken(BYTE* token, BYTE* sharedKey, BYTE* token2, BYTE* retHash);
-	DWORD GetEncTerminalInfo(CBlob& encInfo);
+	DWORD GetEncTerminalInfoWithKey(CBlob& encInfo, BYTE* key);
 	DWORD GetTmk(string& tmk);
 	DWORD GetTokenReq(CAccessAuthGetTokenReq* getTokenReq);
 	void UpdateWK();
@@ -491,6 +204,10 @@ public:
 
 	bool containsChinese(const std::string& str);
 
+	CSimpleStringA GetOsVersion();
+	void GetIPandMac(CSimpleStringA& ip, CSimpleStringA& mac);
+	void GetHardWareInfo(CSimpleStringA& cpu, CSimpleStringA& mainBoard, CSimpleStringA& disk);
+
 private:
 	void GetDiffSyncTimeFromCenterSettings();
 private:

+ 88 - 510
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -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,19 +118,6 @@ struct InitializerInitMKTask : ITaskSp
 	}
 };
 
-#ifdef RVC_OS_WIN
-struct GetTermSysInfoTask : ITaskSp
-{
-	CAccessAuthEntity* m_entity;
-	GetTermSysInfoTask(CAccessAuthEntity* entity) :m_entity(entity) {}
-
-	void Process()
-	{
-		m_entity->GetTermSysInfo();
-	}
-};
-#endif // RVC_OS_WIN
-
 typedef struct _REG_TZI_FORMAT
 {
 	LONG Bias;
@@ -264,11 +190,6 @@ 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 +200,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 +537,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 +548,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 +594,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 +695,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 +718,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 +734,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 +761,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 +792,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 +1011,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 +1042,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 +1071,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
 		{
@@ -1395,7 +1099,7 @@ void CAccessAuthEntity::EndInitMK(DWORD rc, const char *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,132 +1283,6 @@ pair<string, string> CAccessAuthEntity::EncryptedByPubKey(CSimpleStringA pubKey,
 	return make_pair(pBlock, strRam);
 }
 
-#ifdef RVC_OS_WIN
-void CAccessAuthEntity::GetTermSysInfo()
-{
-	//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;
-	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))
-		{
-			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;
-		}
-		else
-		{
-			m_iGetTermSysInfo = 1;
-			bCalcFromRunCfg = true;
-		}
-	}
-	else
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTermSysInfo, OpenConfig Config_Run error=%d.", eErr);
-
-	ULONGLONG ullStart = GetTickCount64();
-	char szTmp[1024] = {};
-	int nTmpBufLen = 1024;
-	CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
-
-	if (!QueryWMIDevice(Processor, "ProcessorId", szTmp, &nTmpBufLen))
-	{
-		strErrMsg = CSimpleStringA::Format("查询 cpu id 失败: %d, 请尝试重启应用", GetLastError());
-		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("RTA5203")
-			(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "Processor", GetLastError()).c_str());
-		if (!bCalcFromRunCfg)
-			m_iGetTermSysInfo = -1;
-		return;
-	}
-	strRet = szTmp;
-
-	nTmpBufLen = 1024;
-	memset(szTmp, 0, sizeof(szTmp));
-	if (!QueryWMIDevice(BaseBoard, "SerialNumber", szTmp, &nTmpBufLen))
-	{
-		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")
-			(GetOutPutStr("%s%s%s%d", "QueryWMIDevice", "False", "BaseBoard", GetLastError()).c_str());
-		if (!bCalcFromRunCfg)
-			m_iGetTermSysInfo = -1;
-		return;
-	}
-
-	strRet += "|";
-	strRet += szTmp;
-
-	nTmpBufLen = 1024;
-	memset(szTmp, 0, sizeof(szTmp));
-	if (!QueryWMIDevice(DiskDrive, "SerialNumber", szTmp, &nTmpBufLen))
-	{
-		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;
-		return;
-	}
-
-	strRet += "|";
-	strRet += szTmp;
-
-	if (!bCalcFromRunCfg || 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"
-			, csInfo.GetData(), strRet.GetData(), eErr);
-	}
-	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));
-	}
-	return;
-}
-#endif // RVC_OS_WIN
-
 SP_BEGIN_ENTITY_MAP()
 	SP_ENTITY(CAccessAuthEntity)
 SP_END_ENTITY_MAP()

+ 7 - 7
Module/mod_accessauth/mod_AccessAuth.h

@@ -8,6 +8,9 @@ using namespace AccessAuthorization;
 
 #include "AccessAuthFSM.h"
 
+#define KEY_SIZE 16
+#define BUF_SIZE 256
+
 int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len);
 int StrBuf2HexBuf(LPCTSTR strBuf, PBYTE* hexBuf);
 
@@ -89,8 +92,8 @@ public:
 	// 保存会话密钥
 	bool SaveAuthKey(BYTE* pKey);
 
-	// 调用准入会话密钥加密
-	ErrorCodeEnum EncryptDataWithSessionKey(const CBlob& raw, CBlob& enc);
+	// 调用指定密钥加密
+	ErrorCodeEnum EncryptDataWithKey(const CBlob& raw, CBlob& enc, BYTE* key);
 
 	bool GetTerminalFingerPrint(BYTE* pBuf, int& nBufLen);
 	bool GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& pubkey);
@@ -98,10 +101,8 @@ public:
 	void SetAuthErrMsg(const char* pszErrMsg) { m_strAuthErrMsg = pszErrMsg; }
 	const char* GetAuthErrMsg() { return m_strAuthErrMsg; }
 
-	// 获取密码键盘ID和外设ID
-	//oilyang@20210510 add:in order to avoid getting info out of async, check if has pinpad while getting info
-	// 返回1:只有PinPadID;2:只有DeviceID;3:两者都有;0:失败
-	int GetPinPadIDAndDeviceID(CSimpleStringA& strPinPadID, CSimpleStringA& strDeviceID, bool& isPinPadMac, bool& bPinPadOnline);
+	// 获取密码键盘szModel
+	ErrorCodeEnum GetPinPadModel(CSimpleStringA& pinpadModel, bool& bPinPadOnline);
 
 	// 设置时区
 	wstring ANSIToUnicode(const string& str);
@@ -130,7 +131,6 @@ public:
 	SpReqAnsContext<AccessAuthService_InitializeNew_Req, AccessAuthService_InitializeNew_Ans>::Pointer m_ctx;
 	pair<string, string> GenerateTmkToKMC();
 	pair<string, string> EncryptedByPubKey(CSimpleStringA pubKey, bool bNeed04Head = false);
-	void GetTermSysInfo();
 
 	CSimpleStringA m_publicKey;
 	CSimpleStringA m_privateKey;

+ 1 - 1
Module/mod_cardissuerstore/CardIssuerFSM.cpp

@@ -7285,7 +7285,7 @@ void CCardIssuerFSM::GetCardProcessLastErr(ErrorCodeEnum& eErrCode, CSimpleStrin
 	CSimpleStringA lastApiName = "";
 	m_pCardProcess->getCardAssistLastErr(lastErrCode, lastErrMsg, lastApiName);
 	
-	const CSimpleStringA alarmMsgStr = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":%s, \"Context\":%s}"
+	const CSimpleStringA alarmMsgStr = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":\"%s\", \"Context\":\"%s\"}"
 		, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
 
 	std::map<std::string, std::string> msgInfo;

+ 0 - 2
Module/mod_gpio/Gpio_UserErrorCode.h

@@ -15,6 +15,4 @@
 #define GPIO_UserErrorCode_ReadPort_Failed	0x20900208
 #define GPIO_UserErrorCode_DetectStatus_Failed	0x20900209
 
-#define GPIO_UserErrorCode_PortNumOldVersion	0x2090020A
-
 #endif //_CONTACTLESSCARD_USER_ERRORCODE_H

+ 5 - 42
Module/mod_gpio/mod_gpio.cpp

@@ -457,43 +457,6 @@ ErrorCodeEnum CGpioEntity::Initial()
 	m_adapterInfo.strPort = csPort;
 	m_adapterInfo.strBaudrate = csBaudrate;
 	m_adapterInfo.strPortNum = csPortNum; //Just load from Config
-	BOOL nSwitchFlag(FALSE);
-	BOOL useOld = TRUE;
-	CSmartPointer<IConfigInfo> spConfigCenter;
-	eErrDev = spEntityFunction->OpenConfig(Config_CenterSetting, spConfigCenter);
-	if (eErrDev == Error_Succeed) {
-		int nValue(0);
-		spConfigCenter->ReadConfigValueInt(GetEntityName(), "PortNumChoiceSwitch", nValue);
-		if (nValue != 0) {
-			nSwitchFlag = TRUE;
-		}
-	}
-#if defined(RVC_OS_WIN)
-	if (nSwitchFlag && !csPortNum.IsNullOrEmpty()) {
-		if (csPortNum.Compare("3") == 0) { m_bNewVersion = FALSE;  useOld = FALSE; }
-		else if (csPortNum.Compare("4") == 0) { m_bNewVersion = TRUE;  useOld = FALSE; }
-	}
-	if (useOld) {
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[%s],[%s],[%s]", m_adapterInfo.strVendor.GetData()
-			, m_adapterInfo.strVersion.GetData(), m_adapterInfo.strBatch.GetData());
-		//Gpio.keba.1.1 , Gpio.Hyosung.1.1, Gpio.kxd.1.1 均为 老设备,2024-9-11发现现有生产有2249台
-		if (!_stricmp(m_adapterInfo.strVendor, "Hyosung") || !_stricmp(m_adapterInfo.strVendor, "Keba") || !_stricmp(m_adapterInfo.strVendor, "Kxd")) {
-			if (m_adapterInfo.strVersion == "1" && m_adapterInfo.strBatch == "1") {
-				m_bNewVersion = FALSE;
-			}
-		}
-	}
-#endif //RVC_OS_WIN
-	bool theSameFlag = false;
-	if ((m_bNewVersion && csPortNum.Compare("4") == 0) || (!m_bNewVersion && csPortNum.Compare("3") == 0)) { theSameFlag = true; }
-	LogWarn(Severity_Low, Error_Debug, GPIO_UserErrorCode_PortNumOldVersion
-		, CSimpleStringA::Format(",%s,%s,%s,%s,%s"
-			, theSameFlag ? "True" : "False"
-			, m_bNewVersion ? "True" : "False"
-			, csPortNum.GetData()
-			, nSwitchFlag ? "True" : "False"
-			, useOld ? "True" : "False"));
-
 	m_hDevHelper.SetAdapterName(GetEntityName());
     eErrDev = m_hDevHelper.LoadUp(dllName);
     if (eErrDev != Error_Succeed) {
@@ -510,7 +473,8 @@ ErrorCodeEnum CGpioEntity::Initial()
 	initParam.dir[2] = false;
 	initParam.dir[3] = false;
 	initParam.dwPortNum = 3;
-	if (m_bNewVersion) {
+	if (m_adapterInfo.GetPortNumInt() == 4) {
+		m_bNewVersion = TRUE;
 		initParam.dwPortNum = 4;
 		initParam.dir[3] = true;
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("New available 4 port num");
@@ -723,10 +687,9 @@ void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
     int idx = -1;
     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Write Pin %s with %s", GetDriverPortString(dwPinSeq + 1), bHighLevel ? "[Active]" : "[InActive]");
     if (dwPinSeq > 16) {/** 目前只有一个高拍仪的提示灯会超过该值  [Gifur@202495]*/
-        if (!m_bNewVersion && dwPinSeq < 24) {
-            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("not support pin number:%d", dwPinSeq);
-            return;
-        }
+		if (!m_bNewVersion || dwPinSeq < 24) {
+			return;
+		}
         idx = 3;
     } else if (dwPinSeq < 8) {
         idx = 0;

+ 1 - 1
Module/mod_gpio/mod_gpio.h

@@ -150,7 +150,7 @@ public:
 		,m_bVibrationFlag(false),m_bOpenFlag(false),m_bMoveFlag(false),m_bCardGateFlag(false)
 		, m_pLogListener(NULL), m_bHeadLightFlag(false), m_headlightDevPort(4), m_moveHoldTimes(0)
 		, m_moveDisappearTimes(0),m_eMachineType(SP::Module::Comm::RVC_UNKNOWN)
-		, m_bNewVersion(TRUE), m_bFuncVer2(FALSE)
+		, m_bNewVersion(FALSE), m_bFuncVer2(FALSE)
 		, m_bOpened(false), m_bOpening(true), m_btLastRevcInput(-1), m_iInWhatPage(PageType_Init)
 	{
 		memset(m_btOutputStatus,0,MAX_PORT_NUM*sizeof(BYTE));

+ 16 - 26
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -3,7 +3,6 @@
 #include <string>
 #include <algorithm>
 #include <regex>
-#include "CommEntityUtil.hpp"
 #include "SpUtility.h"
 #include "iniutil.h"
 #if defined(RVC_OS_WIN)
@@ -50,6 +49,7 @@ enum EntityOP
 
 ErrorCodeEnum CHealthManagerFSM::Initial()
 {
+	m_netList.Init(0);
 #if defined(RVC_OS_WIN)
 	SaveOsVersion();
 #endif
@@ -64,17 +64,6 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 	CSmartPointer<IConfigInfo> spConfigCen;
 	GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spConfigCen);
 
-#if defined(RVC_OS_LINUX)
-    if (!m_sysInfo.strMachineType.IsNullOrEmpty() && m_sysInfo.strMachineType.Compare("RVC.Stand2S") != 0
-		&& m_sysInfo.strMachineType.Compare("RVC.Stand1SPlus") != 0) {
-        CSimpleStringA strErrMsg = CSimpleStringA::Format("当前版本不支持此机型:%s", (LPCTSTR)m_sysInfo.strMachineType);
-        SP::Module::Comm::LogErrorNotiyStruct notifyItem(Error_NotSupport, 0);
-        SP::Module::Comm::LogNotiyMessageStruct notifyMsg(strErrMsg);
-        notifyItem.Notify(notifyMsg);
-        return Error_Succeed;
-    }
-#endif //RVC_OS_LINUX
-
 	spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "WKUpdatePeriod", m_wkUpdatePeriod);
 	if (m_wkUpdatePeriod <= 0 || m_wkUpdatePeriod > 365)
 		m_wkUpdatePeriod = 30;//default
@@ -90,6 +79,8 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
 		GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "X");
 	WaitDeamonFinishTask* task = new WaitDeamonFinishTask(this);
 	GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
+	
+	SP::Module::Net::GetINETMacAddresses(m_netList);
 
 	return Error_Succeed;
 }
@@ -116,7 +107,6 @@ void CHealthManagerFSM::s0_on_exit(void)
 }
 unsigned int CHealthManagerFSM::s0_on_event(FSMEvent* pEvt)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s0_on_event: %d, %d", pEvt->iEvt, pEvt->param1);
 	int ret = 0;
 	switch(pEvt->iEvt)
 	{
@@ -829,21 +819,20 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
 	CSmartPointer<IConfigInfo> spConfigRun;
 	GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spConfigRun);
 
-	CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
-	SP::Module::Net::GetINETMacAddresses(netList);
+	//CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
+	if (m_netList.GetCount() == 0)
+		SP::Module::Net::GetINETMacAddresses(m_netList);
 	CSimpleStringA csMac(""), csIP(""), csDNS("");
-    for (int i = 0; i < netList.GetCount(); i++) {
+    for (int i = 0; i < m_netList.GetCount(); i++) {
 		if (!csMac.IsNullOrEmpty()) {
 			csMac += ";";
 		}
-		csMac += netList[i].mac.c_str();
-	}
-    for (int i = 0; i < netList.GetCount(); i++) {
+		csMac += m_netList[i].mac.c_str();
 		if (!csIP.IsNullOrEmpty()) {
 			csIP += ";";
 		}
-        csIP += netList[i].ip.c_str();
-    }
+		csIP += m_netList[i].ip.c_str();
+	}
 	for (int i = 0; i < m_dns.GetCount(); i++) {
 		if (!csDNS.IsNullOrEmpty()) {
 			csDNS += ";";
@@ -1042,13 +1031,14 @@ void CHealthManagerFSM::QueryHardwareInfo(SpReqAnsContext<HealthManagerService_Q
 	CSystemStaticInfo info;
 	GetEntityBase()->GetFunction()->GetSystemStaticInfo(info);
 
-	CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
-	SP::Module::Net::GetINETMacAddresses(netList);
+	//CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
+	if (m_netList.GetCount() == 0)
+		SP::Module::Net::GetINETMacAddresses(m_netList);
 
 	CAutoArray<CSimpleStringA> ipAddrs, macAddrs;
-	for (int i = 0; i < netList.GetCount(); i++) {
-		CSimpleStringA tmpip = netList[i].ip.c_str();
-		CSimpleStringA tmpmac = netList[i].mac.c_str();
+	for (int i = 0; i < m_netList.GetCount(); i++) {
+		CSimpleStringA tmpip = m_netList[i].ip.c_str();
+		CSimpleStringA tmpmac = m_netList[i].mac.c_str();
 		ipAddrs.Append(&tmpip, 0, 1);
 		macAddrs.Append(&tmpmac, 0, 1);
 	}

+ 2 - 0
Module/mod_healthmanager/HealthManagerFSM.h

@@ -9,6 +9,7 @@
 using namespace std;
 
 #include "CommEntitySettings.hpp"
+#include "CommEntityUtil.hpp"
 #include "HealthManager_msg_g.h"
 #include "HealthManager_def_g.h"
 #include "AccessAuthorization_client_g.h"
@@ -226,6 +227,7 @@ private:
 	CSystemStaticInfo m_sysInfo;
 	std::map<string, string> m_computerInfo;
 	CAutoArray<string> m_dns;
+	CAutoArray<SP::Module::Net::NetworkAdapterItem> m_netList;
 };
 
 struct WaitDeamonFinishTask : public ITaskSp

+ 61 - 35
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -298,9 +298,10 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
 		//1、AccessAuth ok
 		//2、have ever enter main page OR 
 		if (!m_bSayIdle)
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_fsm.GetAccessAuthFlag():%d,m_bEnterMainPageEver:%d,m_fsm.IfIEBeforeHealth():%d", m_fsm.GetAccessAuthFlag()
-				, m_bEnterMainPageEver, m_fsm.IfIEBeforeHealth());
-		if (m_fsm.GetAccessAuthFlag() && (m_bEnterMainPageEver || (!m_bEnterMainPageEver && m_fsm.IfIEBeforeHealth())))//oilyang 20161219 改成通过是否成功进入主页来判断IE情况
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_fsm.GetAccessAuthFlag():%d, m_bEnterMainPageEver:%d, m_bInMainPage:%d", m_fsm.GetAccessAuthFlag()
+				, m_bEnterMainPageEver, m_bInMainPage);
+		//oilyang@20241230 check accessauth flag AND if in Main page now or ever
+		if (m_fsm.GetAccessAuthFlag() && (m_bEnterMainPageEver || (!m_bEnterMainPageEver && m_bInMainPage)))
 		{
 			iCheckGuardian = CheckGuardianIsRun(true);
 			if (!m_bSayIdle)
@@ -418,16 +419,33 @@ void CHealthManagerEntity::OnCheckTimeTimeout()
 }
 
 #if defined(RVC_OS_LINUX)
-bool FindGuardianPid(pid_t &pid)
+bool FindGuardianPid(CAutoArray<int> &pIDArr)
 {
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to check guardian process");
     char* relate_processes[] = { "guardian" };
-    int count = 1;
-    alive_process_info processes[1];
+    int relate_processes_count = 1;
+    alive_process_info processes[64];
+	int alive_process_info_count = 64;
     memset(processes, 0, sizeof(processes));
 
-    osutil_detect_unique_app(relate_processes, array_size(relate_processes), &count, processes);
-    if (count > 0) {
-		pid = processes[0].pid;
+    int retOfDetect = osutil_detect_unique_app(relate_processes, relate_processes_count, &alive_process_info_count, processes);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("detect guardian return:%d, alive_process_info_count:%d", retOfDetect, alive_process_info_count);
+    if (alive_process_info_count > 0) {
+		if (alive_process_info_count > 64)
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("too many guardian:%d", alive_process_info_count);
+		else
+		{
+			if (alive_process_info_count == 1)
+				pIDArr.Append(&processes[0].pid, 0, 1);
+			else
+			{
+				for (int i = 0; i < alive_process_info_count; i++)
+				{
+					pIDArr.Append(&processes[i].pid, 0, 1);
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("The %d(th) guardian's pid is:%d", i + 1, processes[i].pid);
+				}
+			}
+		}
 		return true;
     }
 	return false;
@@ -483,22 +501,25 @@ int CHealthManagerEntity::CheckGuardianIsRun(bool bStart)
 		}
 	}
 #else
-	pid_t pID;
+	CAutoArray<int> pIDArr;
 	bool bFind = false;
 
-	bFind = FindGuardianPid(pID);
+	bFind = FindGuardianPid(pIDArr);
 	if (bFind)
 	{
-		int ret = kill(pID, 0);
-		if (0 == ret)
+		for (int i = 0; i < pIDArr.GetCount(); i++)
 		{
-			if (!m_bSayIdle)
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("guardian.exe is active, pid:%d", pID);
-			return 1;
-		}
-		else
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("process: guardian.exe inactive, pID:%d,ret:%d", pID, ret);
+			int ret = kill(pIDArr[i], 0);
+			if (0 == ret)
+			{
+				if (!m_bSayIdle)
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("guardian.exe is active, pid:%d", pIDArr[i]);
+				return 1;
+			}
+			else
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("process: guardian.exe inactive, pID:%d,ret:%d", pIDArr[i], ret);
+			}
 		}
 	}
 	else
@@ -588,22 +609,25 @@ bool CHealthManagerEntity::StopGuardian()
 	//int ret = m_pfUpgradeRestart(6, 0);
 	//Dbg("healthmanager tell the guardian to quit.%d", ret);
 	Sleep(5000);
-	pid_t pID;
+	CAutoArray<int> pIDArr;
 	bool bFind = false;
-	bFind = FindGuardianPid(pID);
+	bFind = FindGuardianPid(pIDArr);
 	if (bFind)
 	{
-		int ret = kill(pID, 9 /*SIGKILL*/);
-		if (ret < 0)
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("kill guardian failed:%d",errno);
-			return false;
-		}
-		else
+		for (int i = 0; i < pIDArr.GetCount(); i++)
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("killed guardian.");
-			return true;
+			if (pIDArr[i] == 0)
+				continue;
+			int ret = kill(pIDArr[i], 9 /*SIGKILL*/);
+			if (ret < 0)
+			{
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("kill guardian(pid:%d) failed:%d", pIDArr[i], errno);
+				return false;
+			}
+			else
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("kill guardian(pid:%d) successfully.", pIDArr[i]);
 		}
+		return true;
 	}
 	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("can't find guardian pid.");
 	return true;
@@ -666,7 +690,7 @@ bool CHealthManagerEntity::StartGuardian()
 	tk_process_t* process = NULL;
 	tk_process_option_t option;
 	csBinPath += "/guardian";
-	sprintf(app, "%s %s %s %d", (const char*)csBinPath, staticInfo.strTerminalID.GetData(), "oiltest", 1);
+	sprintf(app, "%s %s %s %d", (const char*)csBinPath, staticInfo.strTerminalID.GetData(), "shouhu", 1);
 	Dbg("path:%s, app:%s", (const char*)csBinPath, (const char*)app);
 	option.exit_cb = NULL;
 	option.file = NULL;
@@ -799,7 +823,7 @@ bool CHealthManagerEntity::DoRestart()
 #else
 	deamonBasePath += "/libGuardianBase.so";
 #endif
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to check if in upgrade process");
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to check if in upgrade process");
 	if (m_fsm.IfInUpgradeProcess() && !m_versionEx.IsNullOrEmpty())
 	{
 		string xTmp(deamonBasePath.GetData());
@@ -1211,7 +1235,10 @@ void CHealthManagerEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nL
 		m_bNeedGuardianRestart = false;
 		m_fsm.SetVtmLoadResult(VtmLoad_AccessAuth_servFail);
 	}
-	break;
+
+		//m_fsm.SetVtmLoadResult(VtmLoad_AccessAuth_Suc);//oiltest
+
+		break;
 	case EVENT_MOD_RELEASESIP_TIMEOUT:
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RELEASESIP_TIMEOUT.");
 		RestartModule("SIPPhone");
@@ -1695,7 +1722,6 @@ void CHealthManagerEntity::OnSelfCheckTimeout()
 	CSmartPointer<IAsynWaitSp> spWait;
 	ErrorCodeEnum errCode;
 	int activeEnCount = m_activeEntity.GetCount();
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("activeEnCount %d,%s", activeEnCount, m_activeEntity[0].GetData());
 	//oilyang@20230426 ,常规自检时,针对"TerminalStage"做对应处理(自检分常规自检和即时自检)
 	//"S":准入服务告知准入不过,不再进行实体自检
 	//非"A":其他启动失败导致进关门页,不再对硬件以及其他没必要自检的实体进行自检

+ 0 - 13
Module/mod_healthmanager/mod_healthmanager.h

@@ -97,19 +97,6 @@ public:
 
 	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext) 
 	{
-		CSystemRunInfo runInfo = { 0 };
-		ErrorCodeEnum ec = GetFunction()->GetSystemRunInfo(runInfo);
-		if (runInfo.autoTest) //测试模式,该模式下无需启动guardian
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Test mode, no need to start guardian.");
-			m_bNeedGuardian = false;
-			if (CheckGuardianIsRun() > 0)//or true?
-			{
-				bool bStop = StopGuardian();
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Test mode, guardian running, to stop guardian:%d", bStop);
-			}
-		}
-
 		ErrorCodeEnum eErrCode = m_fsm.Init(this);
 		if (eErrCode == Error_Succeed) {
             DoRestart();

+ 2 - 2
Module/mod_mediacontroller/capture.cpp

@@ -1974,8 +1974,8 @@ namespace MediaController {
 				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
 				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
 				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-				videocap_get_device_instanceid(i, tmp2, ARRAYSIZE(tmp2));
-				WideCharToMultiByte(CP_ACP, 0, tmp2, -1, t2, sizeof(t2), 0, NULL);
+				//videocap_get_device_instanceid(i, tmp2, ARRAYSIZE(tmp2));
+				//WideCharToMultiByte(CP_ACP, 0, tmp2, -1, t2, sizeof(t2), 0, NULL);
 
 				cJSON* pobject = cJSON_CreateObject();
 				cJSON_AddItemToObject(pobject, "DevicePath", cJSON_CreateString(t1));

+ 1 - 7
Module/mod_pinpad/mod_PinPad.h

@@ -181,13 +181,7 @@ public:
 			ErrorCodeEnum eGetDevInfo = m_fsm.GetDevInfo(devInfo);
 			if (eGetDevInfo == Error_Succeed)
 			{
-				//oiltmp@20240823 纪林的与业务组的初始化优化完成之后,是不是不要再拼接了?
-				CSimpleStringA tmpAddStr("");
-				tmpAddStr = tmpAddStr + "Vendor=" + devInfo.szVendor;
-				if (devInfo.szModel[strlen(devInfo.szModel) - 1] == '#')
-					ctx->Ans.model = CSimpleStringA(devInfo.szModel) + tmpAddStr;
-				else
-					ctx->Ans.model = CSimpleStringA(devInfo.szModel) + "#" + tmpAddStr;
+				ctx->Ans.model = devInfo.szModel;
 				ctx->Ans.type = devInfo.szType;
 			}
 			ctx->Ans.state = eGetDevInfo;