Forráskód Böngészése

#IQRV #comment [Module] 准入实体修改部分提示

gifur 4 éve
szülő
commit
761fd8e481

+ 22 - 26
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -125,9 +125,10 @@ void CAccessAuthFSM::s2_on_entry()
 	LOG_FUNCTION();
 
 	m_finishAccess = 0;
-	TimeOutTask* timeOutTask = new TimeOutTask(this,120 * 1000);// 设定30秒准入超时
+	TimeOutTask* timeOutTask = new TimeOutTask(this, 120 * 1000);
 	GetEntityBase()->GetFunction()->PostThreadPoolTask(timeOutTask);
 	Dbg("启动了准入超时定时器2分钟[%d]",m_finishAccess);
+	GetEntityBase()->GetFunction()->ShowStartupInfo("正在进行准入...");
 
 	auto pEntity = (CAccessAuthEntity*)m_pEntity;
 	
@@ -136,8 +137,7 @@ void CAccessAuthFSM::s2_on_entry()
 	{
 		FSMEvent *pEvent = new FSMEvent(Event_UpdateWKFail);
 		PostEventFIFO(pEvent);
-		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_INIT_KMC,
-			GetOutPutStr("%s%08X", "InitKMC", rc).c_str());
+		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_INIT_KMC, GetOutPutStr("%s%08X", "InitKMC", rc).c_str());
 		return;
 	}
 	
@@ -160,9 +160,9 @@ void CAccessAuthFSM::s2_on_exit()
 	// 关闭连接
 	auto pEntity = (CAccessAuthEntity*)m_pEntity;
 	pEntity->ReleaseKMC();
-
 	SecureClientRelease();
 	CancelTimer(1);
+	GetEntityBase()->GetFunction()->ShowStartupInfo("");
 }
 
 // 会收到Event_UpdateWKResult和Event_ReqTokenResult和EVT_TIMER
@@ -200,20 +200,17 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		auto pEntity = ((CAccessAuthEntity*)m_pEntity);
 		int isFirstAccessAfterSM = pEntity->GetOrSetIsFirstSM(0);
 		if (isFirstAccessAfterSM != 1) {
-			Dbg("否则继续!");
-			FSMEvent* pEvent = new FSMEvent(Event_CheckMD5Succ);
-			PostEventFIFO(pEvent);
+			Dbg("非首次准入");
+			PostEventFIFO(new FSMEvent(Event_CheckMD5Succ));
 			return 0;
 		}
-		Dbg("等待自动初始化完成!");
+		Dbg("第一次准入 !!!");
 		CSimpleStringA strInitState;
 		pEntity->GetFunction()->GetSysVar("InitState", strInitState);
 		if (strInitState == "1") {
-			//2020/5/29 删除了各个文件MD5检验的代码		
-			FSMEvent* pEvent = new FSMEvent(Event_CheckMD5Succ);
-			PostEventFIFO(pEvent);
-		}
-		else {
+			//2020/5/29 删除了各个文件MD5检验的代码	
+			PostEventFIFO(new FSMEvent(Event_CheckMD5Succ));
+		} else {
 			ScheduleTimer(3, 1500);
 		}
 	}
@@ -229,8 +226,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		DWORD rc = m_pConnection->SendSyncTimePackage();
 		if (rc != Error_Succeed)
 		{
-			FSMEvent *pEvent = new FSMEvent(Event_EndSyncTime);
-			PostEventFIFO(pEvent);
+			PostEventFIFO(new FSMEvent(Event_EndSyncTime));
 			LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_SYNC_TIME,
 				GetOutPutStr("%s%08X", "SendSyncTimePackage", rc).c_str());
 		}
@@ -260,6 +256,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		
 		CSimpleStringA strWKSyncSuccTime = "";
 		CSimpleStringA strWKSyncFailCount = "";
+
 #ifdef RVC_OS_WIN
 		auto rc = pEntity->GetFunction()->GetSysVar("WKSyncSuccTime", strWKSyncSuccTime);
 		assert(rc == Error_Succeed);
@@ -278,13 +275,16 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		if (nWKLastSyncTime > 0 && stSyncTime.wYear == stNow.wYear
 			&& stSyncTime.wMonth == stNow.wMonth && stSyncTime.wDay == stNow.wDay
 			&& nWKSyncFailCount == 0 )		// 最近一次同步成功,才能跳过
+
 #else
-		Dbg("获取WKSyncSuccTime。。。");
-		auto rc = pEntity->GetFunction()->GetSysVar("WKSyncSuccTime", strWKSyncSuccTime);
-		if (rc != Error_Succeed) Dbg("获取WKSyncSuccTime失败");
 
+		Dbg("获取 WKSyncSuccTime");
+		auto rc = pEntity->GetFunction()->GetSysVar("WKSyncSuccTime", strWKSyncSuccTime);
+		if (rc != Error_Succeed) 
+			Dbg("获取WKSyncSuccTime失败");
 		rc = pEntity->GetFunction()->GetSysVar("WKSyncFailCount", strWKSyncFailCount);
-		if (rc != Error_Succeed) Dbg("获取WKSyncFailCount失败");
+		if (rc != Error_Succeed)
+			Dbg("获取WKSyncFailCount失败");
 
 		Dbg("strWKSyncSuccTime=%s", strWKSyncSuccTime.GetData());
 		Dbg("strWKSyncFailCount=%s", strWKSyncFailCount.GetData());
@@ -308,7 +308,6 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 			&& nWKSyncFailCount == 0)		// 最近一次同步成功,才能跳过
 #endif
 		
-		
 		{
 			Dbg("WK has been updated today");
 			FSMEvent *pEvent = new FSMEvent(Event_IgnoreUpdateWK);
@@ -317,9 +316,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 		else
 		{	
 			Dbg("begin update WK now");
-		
-			// 请求WK
-			DWORD rc = m_pConnection->SendWKUpdatePackage();
+			DWORD rc = m_pConnection->SendWKUpdatePackage(); // 请求WK
 			if (rc != Error_Succeed)
 			{
 				LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_UPDATE_WK,
@@ -328,8 +325,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 				PostEventFIFO(pEvent);	
 			}
 		}
-#ifdef RVC_OS_WIN
-#else
+#if defined(RVC_OS_LINUX)
 		if(lastTime != NULL) delete lastTime;
 		if(currentTime != NULL) delete currentTime;
 #endif
@@ -611,7 +607,7 @@ DWORD CAccessAuthFSM::InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req,
 
 	if (rc != Error_Succeed)
 	{
-		ctx->Answer(rc? Error_Unexpect: Error_Succeed);
+		ctx->Answer(rc? Error_Unexpect: Error_Succeed); //???
 		return rc;
 	}	
 

+ 4 - 4
Module/mod_accessauth/AccessAuthFSM.h

@@ -56,10 +56,10 @@ public:
 
 	BEGIN_FSM_STATE(CAccessAuthFSM)
 		FSM_STATE_ENTRY(s1, "Isolate",s1_on_entry,s1_on_exit,s1_on_event)
-		FSM_STATE_ENTRY(s2, "Checking",s2_on_entry,s2_on_exit,s2_on_event)
-		FSM_STATE_ENTRY(s3, "Failure",s3_on_entry,s3_on_exit,s3_on_event)
-		FSM_STATE_ENTRY(s4, "Cancel", s4_on_entry, s4_on_exit, s4_on_event)
-		FSM_STATE_ENTRY(s5, "Login", s5_on_entry, s5_on_exit, s5_on_event)
+		FSM_STATE_ENTRY(s2, "Checking",s2_on_entry,s2_on_exit,s2_on_event) //开始准入
+		FSM_STATE_ENTRY(s3, "Failure",s3_on_entry,s3_on_exit,s3_on_event) //准入失败
+		FSM_STATE_ENTRY(s4, "Cancel", s4_on_entry, s4_on_exit, s4_on_event) //准入超时
+		FSM_STATE_ENTRY(s5, "Login", s5_on_entry, s5_on_exit, s5_on_event) //准入成功
 		FSM_STATE_ENTRY(s6, "Leaving", s6_on_entry, s6_on_exit, s6_on_event)
 		FSM_STATE_ENTRY(s7, "LostTrust", s7_on_entry, s7_on_exit, s7_on_event)
 	END_FSM_STATE()

+ 6 - 4
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -686,7 +686,7 @@ bool CAccessAuthEntity::SaveAuthVerAndKey(int nAuthVer, BYTE *pKey)
 			printPasswdError();
 			return false;
 		}
-		Dbg("使用私钥解密成功。。。");
+		Dbg("使用私钥解密成功");
 		if (plainKeyLen != KEY_SIZE) {
 			Dbg("私钥解密后的会话密钥长度不等于16!");
 		}
@@ -1378,7 +1378,9 @@ int CAccessAuthEntity::GetOrSetIsFirstSM(int type) {
 		else if (sIsFirst == "Yes") {
 			isFirst = 1;
 		}
-		else isFirst = 0;
+		else 
+			isFirst = 0;
+
 		return isFirst;
 	}
 	else {
@@ -1386,13 +1388,13 @@ int CAccessAuthEntity::GetOrSetIsFirstSM(int type) {
 		if (rc != Error_Succeed) {
 			Dbg("WriteConfigValue Config_Run SM IsFirst error.");
 			return isFirst;
-		}
-		else {
+		} else {
 			isFirst = 1;
 		}
 		return isFirst;
 	}
 }
+
 SP_BEGIN_ENTITY_MAP()
 	SP_ENTITY(CAccessAuthEntity)
 SP_END_ENTITY_MAP()

+ 2 - 0
Module/mod_accessauth/mod_AccessAuth.h

@@ -132,6 +132,8 @@ public:
 
 	int ConvertStr2Byte(string input, BYTE* output, int outputLen);
 	void printPasswdError();
+	/*type=0 means read first or not while type=1 for writing not first*/
+	/*return 1 means first access auth as 0 means not first access auth*/
 	int GetOrSetIsFirstSM(int type);
 
 	string m_TMK;