|
@@ -7,6 +7,9 @@
|
|
|
#include <stdlib.h>
|
|
|
#include "fileutil.h"
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
+#include "comm.h"
|
|
|
+#include "PinPad_client_g.h"
|
|
|
+using namespace PinPad;
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
#include <io.h>
|
|
@@ -18,13 +21,12 @@
|
|
|
#include <Winsock2.h>
|
|
|
#include <algorithm>
|
|
|
#pragma comment(lib, "IPHLPAPI.lib")
|
|
|
-#endif // RVC_OS_WIN
|
|
|
+#define ALLOW_MULTI_NETWORKD_CARDS
|
|
|
|
|
|
+#else
|
|
|
#include "CommEntityRestful.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
-#include "comm.h"
|
|
|
-#include "PinPad_client_g.h"
|
|
|
-using namespace PinPad;
|
|
|
+#endif // RVC_OS_WIN
|
|
|
|
|
|
int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len)
|
|
|
{
|
|
@@ -71,8 +73,7 @@ CAccessAuthFSM::~CAccessAuthFSM()
|
|
|
|
|
|
void CAccessAuthFSM::OnStateTrans(int iSrcState, int iDstState)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("OnStateTrans")
|
|
|
- ("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum CAccessAuthFSM::OnInit()
|
|
@@ -115,7 +116,6 @@ struct TimeSynTask : ITaskSp
|
|
|
|
|
|
void Process()
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("TimeSynTask")("TimeSynTask Process");
|
|
|
if (m_fsm->GetmAccessAuthHost().IsNullOrEmpty())
|
|
|
{
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, AccessAuthorization_UserErrorCode_AccessAuth_NULL, "准入Url为空");
|
|
@@ -158,14 +158,11 @@ struct TimeSynTask : ITaskSp
|
|
|
DWORD rc = m_fsm->HandleTimeSyn(timeSynRet.data.timeDiff, (BYTE*)decodedSessionKey);
|
|
|
delete decodedSessionKey;
|
|
|
if (rc == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleTimeSyn")
|
|
|
- ("TimeSynTask HandleTimeSyn Success");
|
|
|
auto pEvent = new FSMEvent(CAccessAuthFSM::Event_EndSyncTime);
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("HandleTimeSyn")
|
|
|
- ("TimeSynTask HandleTimeSyn error = %08X", rc);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("TimeSynTask HandleTimeSyn error = %08X", rc);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -203,8 +200,6 @@ struct TimeSynTask : ITaskSp
|
|
|
|
|
|
std::string test;
|
|
|
test = config.GetRequestUri();
|
|
|
- Dbg("请求地址:%s.", test.c_str());
|
|
|
-
|
|
|
|
|
|
config.PreDo();
|
|
|
client.Do(&config, &result);
|
|
@@ -235,7 +230,6 @@ struct TimeSynTask : ITaskSp
|
|
|
rc = m_fsm->HandleTimeSyn(timeSyncAns.timeDiff, (BYTE*)decodedSessionKey);
|
|
|
delete decodedSessionKey;
|
|
|
if (rc == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("TimeSynTask HandleTimeSyn Success");
|
|
|
auto pEvent = new FSMEvent(CAccessAuthFSM::Event_EndSyncTime);
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
}
|
|
@@ -316,18 +310,17 @@ struct UpdateWKTask : ITaskSp
|
|
|
{
|
|
|
updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get keyChek && keyIndex failed.");
|
|
|
}
|
|
|
|
|
|
pPinPad->GetFunction()->CloseSession();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to pinpad failed.error code:%d", errRc);
|
|
|
}
|
|
|
|
|
|
CAccessAuthUpdateWKRet updateWKRet;
|
|
@@ -338,13 +331,10 @@ struct UpdateWKTask : ITaskSp
|
|
|
long end = GetTickCount();
|
|
|
|
|
|
if (ret) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask").setBeginTime(beg).setEndTime(end).
|
|
|
- setResultCode(std::to_string(LONGLONG(updateWKRet.m_sysCode)).c_str()).
|
|
|
- setResultMsg(updateWKRet.m_errMsg.c_str())("UpdateWKTask Connect Success.");
|
|
|
if (updateWKRet.m_userCode.compare(ACS_SUCCESS)) {
|
|
|
m_fsm->doWarnMsg(ERR_ACCESSAUTH_UPDATE_WK,
|
|
|
GetOutPutStr("%s%s%s%s", "UpdateWKTask", updateWKRet.m_userCode.c_str(), "message", updateWKRet.m_errMsg.c_str()).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)
|
|
|
(GetOutPutStr("%s%s%s%s", "UpdateWKTask", updateWKRet.m_userCode.c_str(), "message", updateWKRet.m_errMsg.c_str()).c_str());
|
|
|
if (client) client->Destory();
|
|
|
return;
|
|
@@ -355,26 +345,30 @@ struct UpdateWKTask : ITaskSp
|
|
|
ErrorCodeEnum eLoadErr = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKRet.tpk,
|
|
|
updateWKRet.edk, updateWKRet.keyIndex);
|
|
|
if (eLoadErr == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("LoadKeysToPinPadNew")
|
|
|
- ("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
|
if (client) client->Destory();
|
|
|
return;
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("LoadKeysToPinPadNew")
|
|
|
- ("UpdateWKTask 密钥加载失败,请检查密码键盘连接. error = %08X", eLoadErr);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("UpdateWKTask 密钥加载失败,请检查密码键盘连接. error = %08X", eLoadErr);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ CSimpleStringA acsResoultCode = "RTA520F";
|
|
|
int acsErrCode = ERROR_ACCESSAUTH_CONNECT_ACS_x;
|
|
|
if (updateWKRet.m_sysCode == 6)
|
|
|
+ {
|
|
|
+ acsResoultCode = "RTA520D";
|
|
|
acsErrCode = ERROR_ACCESSAUTH_CONNECT_ACS_6;
|
|
|
+ }
|
|
|
else if (updateWKRet.m_sysCode == 28)
|
|
|
+ {
|
|
|
+ acsResoultCode = "RTA520E";
|
|
|
acsErrCode = ERROR_ACCESSAUTH_CONNECT_ACS_28;
|
|
|
+ }
|
|
|
m_fsm->doWarnMsg(acsErrCode,
|
|
|
GetOutPutStr("%s%d", "连接总行ACS准入服务失败(StageReport).", updateWKRet.m_sysCode).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask").setBeginTime(beg).setEndTime(end).
|
|
|
- setResultCode(std::to_string(LONGLONG(updateWKRet.m_sysCode)).c_str()).
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setBeginTime(beg).setEndTime(end).
|
|
|
+ setResultCode(acsResoultCode.GetData()).
|
|
|
setResultMsg(updateWKRet.m_errMsg.c_str())
|
|
|
(GetOutPutStr("%s%d", "连接总行ACS准入服务失败(StageReport).", updateWKRet.m_sysCode).c_str());
|
|
|
}
|
|
@@ -421,18 +415,17 @@ struct UpdateWKTask : ITaskSp
|
|
|
{
|
|
|
updateWKReq.tpkKeyCheck = ans.checkcode[0].GetData();
|
|
|
updateWKReq.keyIndex = ans.index[0].GetData();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex suc.");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("Get keyChek && keyIndex failed.");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get keyChek && keyIndex failed.");
|
|
|
}
|
|
|
|
|
|
pPinPad->GetFunction()->CloseSession();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("UpdateWKTask")("connect to pinpad failed.error code:%d", errRc);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to pinpad failed.error code:%d", errRc);
|
|
|
}
|
|
|
|
|
|
HttpClientResponseResult result;
|
|
@@ -459,16 +452,9 @@ struct UpdateWKTask : ITaskSp
|
|
|
return;
|
|
|
}
|
|
|
SP::Module::Restful::ExtractDataFromDebranchResponse(result.content, updateWKAns);
|
|
|
- /*DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tmk=%s %d", updateWKAns.tmk.c_str(), updateWKAns.tmk.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpk=%s %d", updateWKAns.tpk.c_str(), updateWKAns.tpk.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edk=%s %d", updateWKAns.edk.c_str(), updateWKAns.edk.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("tpkKeyCheck=%s %d", updateWKAns.tpkKeyCheck.c_str(), updateWKAns.tpkKeyCheck.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("edkKeyCheck=%s %d", updateWKAns.edkKeyCheck.c_str(), updateWKAns.edkKeyCheck.size());
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("index=%s %d", updateWKAns.keyIndex.c_str(), updateWKAns.keyIndex.size());*/
|
|
|
|
|
|
DWORD rc = m_entity->LoadKeysToPinPadACS(tmkpair.second, updateWKAns.tpk, updateWKAns.edk, updateWKAns.keyIndex);
|
|
|
if (rc == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
|
return;
|
|
|
}
|
|
|
else {
|
|
@@ -478,7 +464,7 @@ struct UpdateWKTask : ITaskSp
|
|
|
else {
|
|
|
m_fsm->doWarnMsg(ERROR_ACCESSAUTH_CONNECT_ACS,
|
|
|
GetOutPutStr("%s%s", "连接总行ACS准入服务失败(UpdateWKTask).", result.WhatError().c_str()).c_str(), true);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("UpdateWKTask Connect Failed.");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520G")("UpdateWKTask Connect Failed.");
|
|
|
}
|
|
|
|
|
|
UpdateWKRetError:
|
|
@@ -497,7 +483,6 @@ struct GetTokenTask : ITaskSp
|
|
|
|
|
|
void Process()
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTokenTask")("GetTokenTask Process");
|
|
|
if (m_fsm->GetmAccessAuthHost().IsNullOrEmpty()) {
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, AccessAuthorization_UserErrorCode_AccessAuth_NULL, "准入Url为空");
|
|
|
FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_ReqTokenCancel);
|
|
@@ -530,10 +515,6 @@ struct GetTokenTask : ITaskSp
|
|
|
long end = GetTickCount();
|
|
|
|
|
|
if (ret) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTokenTask").setBeginTime(beg).setEndTime(end).
|
|
|
- setResultCode(std::to_string(LONGLONG(getTokenRet.m_sysCode)).c_str()).
|
|
|
- setResultMsg(getTokenRet.m_errMsg.c_str())
|
|
|
- ("GetTokenTask userCode:%s,errMsg:%s", getTokenRet.m_userCode.c_str(), getTokenRet.m_errMsg.c_str());
|
|
|
if (getTokenRet.m_userCode.compare(ACS_SUCCESS)) {
|
|
|
m_fsm->AuthLogWarn(getTokenRet, getTokenReq.m_url, "获取准入token");
|
|
|
if (client) client->Destory();
|
|
@@ -555,14 +536,13 @@ struct GetTokenTask : ITaskSp
|
|
|
DWORD rc = m_fsm->HandleGetToken((BYTE*)getTokenRet.data.sharedKey.enToken.c_str(), (BYTE*)getTokenRet.data.sharedKey.sharedSK.c_str(),
|
|
|
(BYTE*)getTokenRet.data.accessToken.enToken.c_str(), (BYTE*)getTokenRet.data.accessToken.retHash.c_str());
|
|
|
if (rc == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("GetTokenTask HandleGetToken Success");
|
|
|
FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_ReqTokenSucc);
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
if (client) client->Destory();
|
|
|
return;
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("GetTokenTask HandleGetToken error = %08X", rc);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetTokenTask HandleGetToken error = %08X", rc);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -639,7 +619,6 @@ struct GetTokenTask : ITaskSp
|
|
|
|
|
|
std::string test;
|
|
|
test = config.GetRequestUri();
|
|
|
- Dbg("请求地址:%s.", test.c_str());
|
|
|
|
|
|
RestfulClient client = RestfulClient::getInstance();
|
|
|
config.PreDo();
|
|
@@ -668,7 +647,6 @@ struct GetTokenTask : ITaskSp
|
|
|
(BYTE*)getTokenAns.accessToken.enToken.c_str(), (BYTE*)getTokenAns.accessToken.retHash.c_str());
|
|
|
|
|
|
if (rc == Error_Succeed) {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetTokenTask HandleGetToken Success");
|
|
|
FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_ReqTokenSucc);
|
|
|
m_fsm->PostEventFIFO(pEvent);
|
|
|
return;
|
|
@@ -753,7 +731,6 @@ struct InitDeviceTask :public ITaskSp
|
|
|
m_fsm->SetDevPubKey(initDeviceRet.devPubKey.c_str());
|
|
|
m_fsm->m_ctxInitDev->Answer(Error_Succeed);
|
|
|
m_fsm->m_ctxInitDev.Clear();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InitDeviceTask")("InitDeviceTask success.");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -826,7 +803,7 @@ void CAccessAuthFSM::s1_on_exit()
|
|
|
|
|
|
unsigned int CAccessAuthFSM::s1_on_event(FSMEvent* pEvent)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("s1_on_event")("s1_on_event: %d", pEvent->iEvt);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s1_on_event: %d", pEvent->iEvt);
|
|
|
return 0;
|
|
|
}
|
|
|
void CAccessAuthFSM::s2_on_entry()
|
|
@@ -835,7 +812,7 @@ void CAccessAuthFSM::s2_on_entry()
|
|
|
|
|
|
m_finishAccess = 0;
|
|
|
SetEntryPermitSysVar("C");
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("开始第%d次准入", m_nAccessFailedCount);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("开始第%d次准入", m_nAccessFailedCount);
|
|
|
|
|
|
CSmartPointer<TimeSynTask> timeSynTask = new TimeSynTask(this);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(timeSynTask.GetRawPointer());
|
|
@@ -847,11 +824,10 @@ void CAccessAuthFSM::s2_on_exit()
|
|
|
|
|
|
unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("s2 receives event id: %d", pEvent->iEvt);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s2 receives event id: %d", pEvent->iEvt);
|
|
|
|
|
|
if (pEvent->iEvt == Event_EndSyncTime)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("get token now");
|
|
|
pEvent->SetHandled();
|
|
|
|
|
|
CSmartPointer<GetTokenTask> getTokenTask = new GetTokenTask(this, (CAccessAuthEntity*)m_pEntity);
|
|
@@ -893,6 +869,7 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
|
|
|
CSimpleStringA strErrMsg = CSimpleStringA::Format("%s", (const char*)pEntity->GetAuthErrMsg());
|
|
|
// 发送准入失败事件,暂时不发送事件进去关门界面,原因关门界面显示中文乱码
|
|
|
doWarnMsg(EVENT_ACCESSAUTH_FAILED, strErrMsg.GetData(), true);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520B")("准入失败");
|
|
|
pEntity->GetFunction()->ShowFatalError(strErrMsg);
|
|
|
|
|
|
m_nAccessFailedCount = 0;
|
|
@@ -921,7 +898,7 @@ void CAccessAuthFSM::s3_on_entry()
|
|
|
|
|
|
unsigned int CAccessAuthFSM::s3_on_event(FSMEvent* event)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s3_on_event")("s3 receives event id: %d", event->iEvt);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s3 receives event id: %d", event->iEvt);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -963,15 +940,9 @@ ErrorCodeEnum CAccessAuthFSM::GetIntFromCS(const char* pcSection, const char* pc
|
|
|
{
|
|
|
|
|
|
Error = spConfig->ReadConfigValueInt(pcSection, pcKey, retInt);
|
|
|
- if (Error_Succeed == Error)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetIntFromCS")
|
|
|
- ("get retInt=%d from CenterSetting.ini", retInt);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (Error_Succeed != Error)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetIntFromCS")
|
|
|
- ("get retInt from CenterSetting.ini failed");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get retInt from CenterSetting.ini failed");
|
|
|
}
|
|
|
}
|
|
|
return Error;
|
|
@@ -986,12 +957,7 @@ ErrorCodeEnum CAccessAuthFSM::GetStrFromCS(const char* pcSection, const char* pc
|
|
|
if (Error_Succeed == Error)
|
|
|
{
|
|
|
Error = spConfig->ReadConfigValue(pcSection, pcKey, retStr);
|
|
|
- if (Error_Succeed == Error)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("GetStrFromCS")
|
|
|
- ("get retStr=%s from CenterSetting.ini", retStr);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (Error_Succeed != Error)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("GetStrFromCS")
|
|
|
("get retStr from CenterSetting.ini failed");
|
|
@@ -1012,7 +978,7 @@ bool CAccessAuthFSM::DecryptWithSessionKey(BYTE* encText, int encTextLen, BYTE*
|
|
|
delete keyTmp;
|
|
|
|
|
|
if (!DecWithSM4_ECB(key, encText, encTextLen, decTest, &decTestLen)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DecryptWithSessionKey")("DecryptWithSessionKey ECB error.");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("DecryptWithSessionKey ECB error.");
|
|
|
return false;
|
|
|
}
|
|
|
#ifdef RVC_OS_WIN
|
|
@@ -1084,8 +1050,7 @@ DWORD CAccessAuthFSM::HandleTimeSyn(long nTimeDiff, BYTE* nSessionKey)
|
|
|
#else
|
|
|
if (set_system_time_by_sec(nTimeDiff)) {
|
|
|
#endif // RVC_OS_WIN
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleTimeSyn")
|
|
|
- ("sync time with server succeed, server time: [%s]", (const char*)dtServerTime.ToTimeString());
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sync time with server succeed, server time: [%s]", (const char*)dtServerTime.ToTimeString());
|
|
|
LogWarn(Severity_Low, Error_Debug, AccessAuthorization_UserErrorCode_Sync_Time_Succ,
|
|
|
CSimpleStringA::Format("sync time succ: server time: [%s],diff[%ld],threshold:[%d]",
|
|
|
(const char*)dtServerTime.ToTimeString(), nTimeDiff, m_torelateDiffSyncTimeSecs));
|
|
@@ -1113,7 +1078,7 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
DWORD rc = Error_Succeed;
|
|
|
auto pEntity = (CAccessAuthEntity*)m_pEntity;
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("retHash=%s", (char*)retHash);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("retHash=%s", (char*)retHash);
|
|
|
|
|
|
char* enToken1_acs, * sharedKey_acs, * enToken2_acs, * hash_acs;
|
|
|
int enToken1_acs_len = 0, sharedKey_acs_len = 0, enToken2_acs_len = 0, hash_acs_len = 0;
|
|
@@ -1130,10 +1095,10 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
hash_acs = Hex2Str((char*)retHash, hash_acs_len);
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("enToken1_acs_len=%d", enToken1_acs_len);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("sharedKey_acs_len=%d", sharedKey_acs_len);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("enToken2_acs_len=%d", enToken2_acs_len);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("hash_acs_len=%d", hash_acs_len);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("enToken1_acs_len=%d", enToken1_acs_len);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("sharedKey_acs_len=%d", sharedKey_acs_len);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("enToken2_acs_len=%d", enToken2_acs_len);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("hash_acs_len=%d", hash_acs_len);
|
|
|
|
|
|
memset(enToken1, 0, strlen((char*)enToken1));
|
|
|
memset(sharedKey, 0, strlen((char*)sharedKey));
|
|
@@ -1157,7 +1122,7 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
|
|
|
BYTE sm3[32] = { 0 };
|
|
|
if (!SM3Hash(enToken, 512 + 16, sm3)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("SM3 Hash error at Token Ret.");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("SM3 Hash error at Token Ret.");
|
|
|
}
|
|
|
if (memcmp(sm3, retHash, 32) != 0)
|
|
|
{
|
|
@@ -1169,11 +1134,9 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
#else
|
|
|
char* sm3Ret = Str2Hex((char*)sm3, 32);
|
|
|
#endif // RVC_OS_WIN
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")("sm3Ret=%s", (char*)sm3Ret);
|
|
|
delete sm3Ret;
|
|
|
doWarnMsg(ERR_ACCESSAUTH_TOKEN_HASH, "返回令牌校验不通过", true);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")
|
|
|
- (GetOutPutStr("%s%s", "Hash", "返回令牌校验不通过").c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%s", "Hash", "返回令牌校验不通过").c_str());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1191,8 +1154,7 @@ DWORD CAccessAuthFSM::HandleGetToken(BYTE* enToken1, BYTE* sharedKey, BYTE* enTo
|
|
|
pEntity->GetFunction()->SetSysVar("AuthErrMsg", "保存令牌失败", true);
|
|
|
pEntity->SetAuthErrMsg("保存令牌失败");
|
|
|
doWarnMsg(ERR_ACCESSAUTH_SAVE_TOKEN, "保存令牌失败", true);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("HandleGetToken")
|
|
|
- (GetOutPutStr("%s%08X", "SaveTokenAndSharedSK", rc).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5208")(GetOutPutStr("%s%08X", "SaveTokenAndSharedSK", rc).c_str());
|
|
|
}
|
|
|
}
|
|
|
return rc;
|
|
@@ -1217,8 +1179,7 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
bool bHasPinPad = false;
|
|
|
int nRet = ((CAccessAuthEntity*)m_pEntity)->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, bHasPinPad);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")
|
|
|
- ("GetPinPadIDAndDeviceID ret: %d, PinPadID: %s, DeviceID: %s", nRet, (const char*)strPinPadID, (const char*)strDeviceID);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPinPadIDAndDeviceID ret: %d, PinPadID: %s, DeviceID: %s", nRet, (const char*)strPinPadID, (const char*)strDeviceID);
|
|
|
if (nRet == 2 || nRet == 3) {
|
|
|
strncpy(pInfo->szPadDeviceID, (const char*)strDeviceID, sizeof(pInfo->szPadDeviceID) - 1);
|
|
|
}
|
|
@@ -1255,16 +1216,16 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
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).setAPI("GetEncTerminalInfo")("ip:%d.%d.%d.%d", pInfo->ip[0], pInfo->ip[1], pInfo->ip[2], pInfo->ip[3]);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ip:%d.%d.%d.%d", pInfo->ip[0], pInfo->ip[1], pInfo->ip[2], pInfo->ip[3]);
|
|
|
}
|
|
|
#else
|
|
|
char ip[32] = { 0 };
|
|
|
- if (getIPFromLinux(ip)) Dbg("Get IP From Linux Error ex.");
|
|
|
+ if (getIPFromLinux(ip)) DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Get IP From Linux Error ex.");
|
|
|
else {
|
|
|
- if (ip2byte(ip, pInfo->ip)) Dbg("Ip 2 Byte Error");
|
|
|
+ if (ip2byte(ip, pInfo->ip)) DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Ip 2 Byte Error");
|
|
|
else {
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
- Dbg("ip[%d]=%d", i, (int)pInfo->ip[i]);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ip[%d]=%d", i, (int)pInfo->ip[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1280,8 +1241,7 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
{
|
|
|
doWarnMsg(ERR_ACCESSAUTH_GET_SYS_VAR,
|
|
|
GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "TerminalStage", ts).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")
|
|
|
- (GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "TerminalStage", ts).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "TerminalStage", ts).c_str());
|
|
|
return ERR_ACCESSAUTH_GET_SYS_VAR;
|
|
|
}
|
|
|
assert(ts.GetLength() >= 1);
|
|
@@ -1293,8 +1253,7 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
{
|
|
|
doWarnMsg(ERR_ACCESSAUTH_GET_SYS_VAR,
|
|
|
GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "RunState", rs).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")
|
|
|
- (GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "RunState", ts).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%08X%s%s", "GetSysVar", rc, "RunState", ts).c_str());
|
|
|
return ERR_ACCESSAUTH_GET_SYS_VAR;
|
|
|
}
|
|
|
assert(rs.GetLength() >= 1);
|
|
@@ -1304,7 +1263,6 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
CBlob raw;
|
|
|
auto pEntity = ((CAccessAuthEntity*)m_pEntity);
|
|
|
// 使用会话密钥加密
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")("使用会话密钥加密。。。");
|
|
|
raw.Refer(pBuf, sizeof(RequestTokenInfo) + 4);
|
|
|
rc = pEntity->EncryptDataWithSessionKey(raw, encInfo);
|
|
|
|
|
@@ -1312,8 +1270,7 @@ DWORD CAccessAuthFSM::GetEncTerminalInfo(CBlob& encInfo)
|
|
|
{
|
|
|
doWarnMsg(ERR_ACCESSAUTH_ENCRYPT_KEY,
|
|
|
GetOutPutStr("%s%08X", "CryptEncrypt", rc).c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")
|
|
|
- (GetOutPutStr("%s%08X", "CryptEncrypt", rc).c_str());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(GetOutPutStr("%s%08X", "CryptEncrypt", rc).c_str());
|
|
|
return ERR_ACCESSAUTH_ENCRYPT_KEY;
|
|
|
}
|
|
|
return Error_Succeed;
|
|
@@ -1331,18 +1288,18 @@ DWORD CAccessAuthFSM::GetTmk(string& tmk)
|
|
|
if (rc != Error_Succeed) return rc;
|
|
|
memset(tmp, 0, sizeof(tmp));
|
|
|
if (pubKey.m_iLength > 70) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTmk")("临时公钥长度(%d)大于70。。。", pubKey.m_iLength);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("临时公钥长度(%d)大于70。。。", pubKey.m_iLength);
|
|
|
return Error_TooSmallBuffer;
|
|
|
}
|
|
|
memcpy_s(tmp, sizeof(tmp) - 70, pubKey.m_pData, pubKey.m_iLength);
|
|
|
if (priKey.m_iLength > 70) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTmk")("临时私钥长度(%d)大于70。。。", priKey.m_iLength);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("临时私钥长度(%d)大于70。。。", priKey.m_iLength);
|
|
|
return Error_TooSmallBuffer;
|
|
|
}
|
|
|
memcpy_s(&tmp[70], sizeof(tmp) - 70, priKey.m_pData, priKey.m_iLength);
|
|
|
char* pRet = new char[512];
|
|
|
HexBuf2StrBuf(tmp, &pRet, 140);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTmk")("data=%s,%d", pRet, strlen(pRet));
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("data=%s,%d", pRet, strlen(pRet));
|
|
|
tmk.assign(pRet);
|
|
|
delete[] pRet;
|
|
|
|
|
@@ -1365,7 +1322,7 @@ DWORD CAccessAuthFSM::GetTokenReq(CAccessAuthGetTokenReq* getTokenReq)
|
|
|
{
|
|
|
doWarnMsg(ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT,
|
|
|
GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTokenReq")
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5203")
|
|
|
(GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
return ERR_ACCESSAUTH_GET_TERMINAL_FINGERPRINT;
|
|
|
}
|
|
@@ -1382,7 +1339,7 @@ DWORD CAccessAuthFSM::GetTokenReq(CAccessAuthGetTokenReq* getTokenReq)
|
|
|
CBlob encInfo;
|
|
|
if ((rc = GetEncTerminalInfo(encInfo)) != Error_Succeed)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetEncTerminalInfo")("GetEncTerminalInfo failed:%d", rc);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetEncTerminalInfo failed:%d", rc);
|
|
|
return rc;
|
|
|
}
|
|
|
#ifdef RVC_OS_WIN
|
|
@@ -1397,25 +1354,6 @@ DWORD CAccessAuthFSM::GetTokenReq(CAccessAuthGetTokenReq* getTokenReq)
|
|
|
if ((rc = GetTmk(tmpStr)) != Error_Succeed) return rc;
|
|
|
getTokenReq->sessionTempPubKey = tmpStr;
|
|
|
|
|
|
- memset(tmp, 0, sizeof(tmp));
|
|
|
- int publicKeyLen = sizeof(tmp);
|
|
|
- if (!pEntity->GetTerminalPublicKey((BYTE*)tmp, publicKeyLen))
|
|
|
- {
|
|
|
- doWarnMsg(ERR_ACCESSAUTH_GET_TERMINAL_PUBKEY,
|
|
|
- GetOutPutStr("%s%s", "GetTerminalPublicKey", "False").c_str());
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")
|
|
|
- (GetOutPutStr("%s%s", "GetTerminalPublicKey", "False").c_str());
|
|
|
- return ERR_ACCESSAUTH_GET_TERMINAL_PUBKEY;
|
|
|
- }
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTokenReq")("publicKeyLen=%d", publicKeyLen);
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- char* retKey = MyBase64::Str2Hex(tmp, publicKeyLen);
|
|
|
-#else
|
|
|
- char* retKey = Str2Hex(tmp, publicKeyLen);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
- getTokenReq->publicKeySM.assign(retKey);
|
|
|
- delete retKey;
|
|
|
-
|
|
|
CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
bool bHasPinPad = false;
|
|
|
int nRet = ((CAccessAuthEntity*)m_pEntity)->GetPinPadIDAndDeviceID(strPinPadID, strDeviceID, bHasPinPad);
|
|
@@ -1439,7 +1377,7 @@ DWORD CAccessAuthFSM::GetAllDevices(CEntityBase* pEntity, CAutoArray<CSimpleStri
|
|
|
{
|
|
|
int nCount(0);
|
|
|
rc = pConfig->ReadConfigValueInt("Device", "Number", nCount);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetAllDevices")("nCount=%d", nCount);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("nCount=%d", nCount);
|
|
|
if (rc == Error_Succeed && nCount > 0)
|
|
|
{
|
|
|
devs.Init(nCount);
|
|
@@ -1453,7 +1391,7 @@ DWORD CAccessAuthFSM::GetAllDevices(CEntityBase* pEntity, CAutoArray<CSimpleStri
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetAllDevices")("GetAllDevices OpenConfig error");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetAllDevices OpenConfig error");
|
|
|
}
|
|
|
return rc;
|
|
|
}
|
|
@@ -1548,6 +1486,7 @@ void CAccessAuthFSM::AuthLogWarn(const T& ret, const string& url, const string&
|
|
|
responseStatus.errorCode.c_str(), responseStatus.errorMsg.c_str());
|
|
|
#endif // RVC_OS_WIN
|
|
|
doWarnMsg(ERR_ACCESSAUTH_SERVICE_FAILED, msg.GetData(), bNeedEvent);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520A")("准入服务端报错");
|
|
|
}
|
|
|
}
|
|
|
|