|
|
@@ -28,8 +28,12 @@ using namespace MaintainWatcher;
|
|
|
#define BUF_SIZE 256
|
|
|
#define KEY_SIZE 16
|
|
|
|
|
|
+#ifdef WITH_CPPRESTSDK
|
|
|
+#include "CommEntityRestful.hpp"
|
|
|
+#else
|
|
|
#define SAFE_DELETE_HTTPCLIENT(obj) \
|
|
|
do{if(obj != NULL) { obj->Destory(); obj = NULL; }}while(false)
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
void CInitializerSession::Handle_Initialize(SpOnewayCallContext<InitializerService_Initialize_Info>::Pointer ctx)
|
|
|
@@ -69,55 +73,7 @@ void CInitializerSession::Handle_InitializeForBlueTooth(SpReqAnsContext<Initiali
|
|
|
ctx->Ans.Errcode = m_pEntity->m_eErrNum;
|
|
|
ctx->Ans.ErrMsg = m_pEntity->m_strLastErrMsg;
|
|
|
}
|
|
|
-struct GateReqTask :public ITaskSp {
|
|
|
- CInitializerFSM* m_fsm;
|
|
|
- CInitializerEntity* m_entity;
|
|
|
- GateReqTask(CInitializerFSM* fsm, CInitializerEntity* entity) :m_fsm(fsm), m_entity(entity) {}
|
|
|
- void Process() {
|
|
|
- CSmartPointer<IEntityFunction> spFunction = m_entity->GetFunction();
|
|
|
- CSmartPointer<IConfigInfo> spConfig;
|
|
|
- ErrorCodeEnum eErr = spFunction->OpenConfig(Config_CenterSetting, spConfig);
|
|
|
- CSimpleStringA branchNo = "",grayUrl = "";
|
|
|
- if (Error_Succeed == eErr)
|
|
|
- {
|
|
|
- spConfig->ReadConfigValue("Common", "GrayLaunchUrl", grayUrl);
|
|
|
- spConfig->ReadConfigValue("Initializer", "SubBankNo", branchNo);
|
|
|
- }
|
|
|
- if (grayUrl.IsNullOrEmpty())
|
|
|
- {
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, Initializer_UserErrorCode_GateUrl_NULL, "灰度Url为空");
|
|
|
- return;
|
|
|
- }
|
|
|
- CSystemStaticInfo si;
|
|
|
- m_entity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
|
|
|
- IHttpFunc* client;
|
|
|
- client = create_http(m_fsm->HttpsLogCallBack);
|
|
|
-
|
|
|
- CInitlizerGateReq gateReq(si.strTerminalID.GetData(), branchNo.GetData(), m_entity->GetEntityName());
|
|
|
- CInitlizerGateRet gateRet;
|
|
|
- gateReq.m_url = grayUrl;
|
|
|
- //oiltest
|
|
|
- gateReq.m_printDbg = true;
|
|
|
-
|
|
|
- bool ret = client->Post(gateReq, gateRet);
|
|
|
- if (!ret)
|
|
|
- {
|
|
|
- //doWarnMsg(ERROR_ACCESSAUTH_CONNECT_ACS, GetOutPutStr("%s%d%s", "访问灰度控制失败"
|
|
|
- // , gateRet.m_sysCode, gateRet.m_userCode.c_str()), true);
|
|
|
- gateRet.bACS = false;
|
|
|
- }
|
|
|
-
|
|
|
- SAFE_DELETE_HTTPCLIENT(client);
|
|
|
-
|
|
|
- Dbg("m_bACS=%d", gateRet.bACS);
|
|
|
- m_entity->m_bACS = gateRet.bACS;
|
|
|
- if (m_entity->m_bACS)
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, Initializer_UserErrorCode_Init_ACS, "灰度提示走总行");
|
|
|
- else
|
|
|
- LogWarn(Severity_Middle, Error_Unexpect, Initializer_UserErrorCode_Init_Branch, "灰度提示走分行");
|
|
|
- }
|
|
|
-};
|
|
|
void CInitializerEntity::OnStarted()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
@@ -135,8 +91,9 @@ void CInitializerEntity::OnStarted()
|
|
|
m_bHasCkCode = false;
|
|
|
|
|
|
m_FSM.Init(this);
|
|
|
- CSmartPointer<GateReqTask> gateReqTask = new GateReqTask(&this->m_FSM,this);
|
|
|
- GetFunction()->PostThreadPoolTask(gateReqTask.GetRawPointer());
|
|
|
+ m_bACS = true;
|
|
|
+ ///**TODO(Gifur@3/24/2022): 需要同步改初始化页面,安装时重启初始化实体的事后操作也可以裁剪掉 */
|
|
|
+ LogWarn(Severity_Middle, Error_Unexpect, Initializer_UserErrorCode_Init_ACS, "强制走总行");
|
|
|
}
|
|
|
|
|
|
void CInitializerEntity::OnPaused()
|
|
|
@@ -1980,32 +1937,83 @@ struct InitializerLoginTask : ITaskSp {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- IHttpFunc* client;
|
|
|
- Dbg("create_http");
|
|
|
- client = create_http(m_fsm->HttpsLogCallBack);
|
|
|
- CInitlizerLoginReq initLoginReq;
|
|
|
- CInitlizerLoginRet initLoginRet;
|
|
|
- CSystemStaticInfo si;
|
|
|
- m_entity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
- initLoginReq.terminalNo = si.strTerminalID;
|
|
|
-
|
|
|
- initLoginReq.user = m_entity->m_strUserID;
|
|
|
- initLoginReq.password = m_entity->m_strPassword;
|
|
|
- initLoginReq.m_url = m_entity->GetInitUrl();
|
|
|
- initLoginReq.m_url += "/api/user/login";
|
|
|
- bool ret = client->Post(initLoginReq, initLoginRet);
|
|
|
-
|
|
|
- Dbg("code=%d", initLoginRet.m_sysCode);
|
|
|
- if (ret)
|
|
|
- {
|
|
|
- Dbg("login Connect Success.");
|
|
|
- m_entity->EndLoginACS(Error_Succeed, "");
|
|
|
- }
|
|
|
- else {
|
|
|
- Dbg("GetTokenTask Connect Failed:%s", initLoginRet.m_errMsg.c_str());
|
|
|
- m_entity->EndLoginACS(Error_Unexpect, initLoginRet.m_errMsg.c_str());
|
|
|
- }
|
|
|
- SAFE_DELETE_HTTPCLIENT(client);
|
|
|
+
|
|
|
+#ifdef WITH_CPPRESTSDK
|
|
|
+ struct InstanceReqJson
|
|
|
+ {
|
|
|
+ string terminalNo;
|
|
|
+ string branchNo;
|
|
|
+ string user;
|
|
|
+ string password;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, branchNo, user, password)
|
|
|
+ } instanceReq;
|
|
|
+
|
|
|
+ struct InstanceAnsJson
|
|
|
+ {
|
|
|
+ int lockState;
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(lockState)
|
|
|
+ } instanceAns;
|
|
|
+
|
|
|
+ CSystemStaticInfo si;
|
|
|
+ m_entity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
+ instanceReq.terminalNo = si.strTerminalID;
|
|
|
+ instanceReq.user = m_entity->m_strUserID;
|
|
|
+ instanceReq.password = m_entity->m_strPassword;
|
|
|
+ instanceReq.branchNo = "";
|
|
|
+
|
|
|
+ HttpClientResponseResult result;
|
|
|
+ HttpClientRequestConfig config(HttpRequestMethod::POST, m_entity->GetInitUrl().GetData());
|
|
|
+ config.SetChildUri("/api/user/login");
|
|
|
+ SP::Module::Restful::FulfillRequestJsonBody(&config, instanceReq);
|
|
|
+
|
|
|
+ RestfulClient client = RestfulClient::getInstance();
|
|
|
+ config.PreDo();
|
|
|
+ client.Do(&config, &result);
|
|
|
+ if (result.ResponseOK()) {
|
|
|
+ SP::Module::Restful::CommResponseJson responseStatus;
|
|
|
+ SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);
|
|
|
+ if (!responseStatus.IsOperatedOK()) {
|
|
|
+ Dbg(responseStatus.errorMsg.c_str());
|
|
|
+ m_entity->EndLoginACS(Error_Unexpect, responseStatus.errorMsg.c_str());
|
|
|
+ } else {
|
|
|
+ Dbg("login Connect Success.");
|
|
|
+ m_entity->EndLoginACS(Error_Succeed, "");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ m_entity->EndLoginACS(Error_Unexpect, result.WhatError().c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+ IHttpFunc* client;
|
|
|
+ Dbg("create_http");
|
|
|
+ client = create_http(m_fsm->HttpsLogCallBack);
|
|
|
+ CInitlizerLoginReq initLoginReq;
|
|
|
+ CInitlizerLoginRet initLoginRet;
|
|
|
+ CSystemStaticInfo si;
|
|
|
+ m_entity->GetFunction()->GetSystemStaticInfo(si);
|
|
|
+ initLoginReq.terminalNo = si.strTerminalID;
|
|
|
+
|
|
|
+ initLoginReq.user = m_entity->m_strUserID;
|
|
|
+ initLoginReq.password = m_entity->m_strPassword;
|
|
|
+ initLoginReq.m_url = m_entity->GetInitUrl();
|
|
|
+ initLoginReq.m_url += "/api/user/login";
|
|
|
+ bool ret = client->Post(initLoginReq, initLoginRet);
|
|
|
+
|
|
|
+ Dbg("code=%d", initLoginRet.m_sysCode);
|
|
|
+ if (ret) {
|
|
|
+ Dbg("login Connect Success.");
|
|
|
+ m_entity->EndLoginACS(Error_Succeed, "");
|
|
|
+ } else {
|
|
|
+ Dbg("GetTokenTask Connect Failed:%s", initLoginRet.m_errMsg.c_str());
|
|
|
+ m_entity->EndLoginACS(Error_Unexpect, initLoginRet.m_errMsg.c_str());
|
|
|
+ }
|
|
|
+ SAFE_DELETE_HTTPCLIENT(client);
|
|
|
+
|
|
|
+#endif //WITH_CPPRESTSDK
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
struct InitializerInitMKTask : ITaskSp {
|
|
|
@@ -2015,87 +2023,215 @@ struct InitializerInitMKTask : ITaskSp {
|
|
|
|
|
|
void Process()
|
|
|
{
|
|
|
- //if (m_fsm->GetmAccessAuthHost().IsNullOrEmpty())
|
|
|
- //{
|
|
|
- // LogWarn(Severity_Middle, Error_Unexpect, AccessAuthorization_UserErrorCode_AccessAuth_NULL, "准入Url为空");
|
|
|
- // return;
|
|
|
- //}
|
|
|
CSystemStaticInfo si;
|
|
|
m_fsm->GetEntityBase()->GetFunction()->GetSystemStaticInfo(si);
|
|
|
- IHttpFunc* client;
|
|
|
- client = create_http(m_fsm->HttpsLogCallBack);
|
|
|
CInitlizerMKReq initMKReq(1);//oiltest dev module count
|
|
|
- initMKReq.m_bTransCode = false;
|
|
|
- CInitlizerMKRet initMKRet;
|
|
|
m_entity->SendInitMKReqACS(initMKReq);
|
|
|
- initMKReq.m_url = m_entity->GetInitUrl();
|
|
|
- initMKReq.m_url += "/api/initmk";
|
|
|
- bool ret = client->Post(initMKReq, initMKRet);
|
|
|
|
|
|
- Dbg("code=%d", initMKRet.m_sysCode);
|
|
|
- if (ret)
|
|
|
- {
|
|
|
+#ifdef WITH_CPPRESTSDK
|
|
|
+
|
|
|
+ struct MKD_NEW1JSON
|
|
|
+ {
|
|
|
+ string enrolAddr;
|
|
|
+ string enrolGPS;
|
|
|
+ string installVersion;
|
|
|
+ string ip;
|
|
|
+ string machineModel;
|
|
|
+ string machineType;
|
|
|
+ string padDeviceID;
|
|
|
+ string site;
|
|
|
+ string terminalNo;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(enrolAddr, enrolGPS, installVersion, ip, machineModel, machineType, padDeviceID, site, terminalNo)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MKD_REQ2JSON
|
|
|
+ {
|
|
|
+ string branchNo;
|
|
|
+ string kmcData;
|
|
|
+ string subBankNo;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(branchNo, kmcData, subBankNo)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MKD_REQ3JSON
|
|
|
+ {
|
|
|
+ string factory;
|
|
|
+ string modal;
|
|
|
+ string type;
|
|
|
+ string version;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(factory, modal, type, version)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MKD_REQ4JSON
|
|
|
+ {
|
|
|
+ string fingerPrint;
|
|
|
+ string fingerPrintSM;
|
|
|
+ string pinPadID;
|
|
|
+ string publicKey;
|
|
|
+ string reserverd;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(fingerPrint, fingerPrintSM, pinPadID, publicKey, reserverd)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MKD_REQ5JSON
|
|
|
+ {
|
|
|
+ int isFirstSM;
|
|
|
+ int isSM;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(isFirstSM, isSM)
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MKD_SMR2JSON
|
|
|
+ {
|
|
|
+ string branchNo;
|
|
|
+ string kmcData;
|
|
|
+ string subBankNo;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(branchNo, kmcData, subBankNo)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ struct InstanceReqJson
|
|
|
+ {
|
|
|
+ MKD_NEW1JSON MKD_NEW1;
|
|
|
+ MKD_REQ2JSON MKD_REQ2;
|
|
|
+ std::vector<MKD_REQ3JSON> MKD_REQ3;
|
|
|
+ MKD_REQ4JSON MKD_REQ4;
|
|
|
+ MKD_REQ5JSON MKD_REQ5;
|
|
|
+ MKD_SMR2JSON MKD_SMR2;
|
|
|
+
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(MKD_NEW1, MKD_REQ2, MKD_REQ3, MKD_REQ4, MKD_REQ5, MKD_SMR2)
|
|
|
+
|
|
|
+ } instanceReq;
|
|
|
+
|
|
|
+ instanceReq.MKD_NEW1.enrolAddr = initMKReq.MKD_NEW1.enrolAddr;
|
|
|
+ instanceReq.MKD_NEW1.enrolGPS = initMKReq.MKD_NEW1.enrolGPS;
|
|
|
+ instanceReq.MKD_NEW1.installVersion = initMKReq.MKD_NEW1.installVersion;
|
|
|
+ instanceReq.MKD_NEW1.ip = initMKReq.MKD_NEW1.ip;
|
|
|
+ instanceReq.MKD_NEW1.machineModel = initMKReq.MKD_NEW1.machineModel;
|
|
|
+ instanceReq.MKD_NEW1.machineType = initMKReq.MKD_NEW1.machineType;
|
|
|
+ instanceReq.MKD_NEW1.padDeviceID = initMKReq.MKD_NEW1.padDeviceID;
|
|
|
+ instanceReq.MKD_NEW1.site = initMKReq.MKD_NEW1.site;
|
|
|
+ instanceReq.MKD_NEW1.terminalNo = initMKReq.MKD_NEW1.terminalNo;
|
|
|
+
|
|
|
+ instanceReq.MKD_REQ2.branchNo = initMKReq.MKD_REQ2.branchNo;
|
|
|
+ instanceReq.MKD_REQ2.kmcData = initMKReq.MKD_REQ2.kmcData;
|
|
|
+ instanceReq.MKD_REQ2.subBankNo = initMKReq.MKD_REQ2.subBankNo;
|
|
|
+
|
|
|
+ for (int i = 0; i < initMKReq.iReq3Count; ++i) {
|
|
|
+ MKD_REQ3JSON item;
|
|
|
+ item.type = initMKReq.MKD_REQ3[i]->type;
|
|
|
+ item.modal = initMKReq.MKD_REQ3[i]->modal;
|
|
|
+ item.factory = initMKReq.MKD_REQ3[i]->factory;
|
|
|
+ item.version = initMKReq.MKD_REQ3[i]->version;
|
|
|
+
|
|
|
+ instanceReq.MKD_REQ3.push_back(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ instanceReq.MKD_REQ4.fingerPrint = initMKReq.MKD_REQ4.fingerPrint;
|
|
|
+ instanceReq.MKD_REQ4.fingerPrintSM = initMKReq.MKD_REQ4.fingerPrintSM;
|
|
|
+ instanceReq.MKD_REQ4.pinPadID = initMKReq.MKD_REQ4.pinPadID;
|
|
|
+ instanceReq.MKD_REQ4.publicKey = initMKReq.MKD_REQ4.publicKey;
|
|
|
+ instanceReq.MKD_REQ4.reserverd = initMKReq.MKD_REQ4.reserverd;
|
|
|
+
|
|
|
+ instanceReq.MKD_REQ5.isFirstSM = initMKReq.MKD_REQ5.isFirstSM;
|
|
|
+ instanceReq.MKD_REQ5.isSM = initMKReq.MKD_REQ5.isSM;
|
|
|
+
|
|
|
+ instanceReq.MKD_SMR2.branchNo = initMKReq.MKD_SMR2.branchNo;
|
|
|
+ instanceReq.MKD_SMR2.subBankNo = initMKReq.MKD_SMR2.subBankNo;
|
|
|
+ instanceReq.MKD_SMR2.kmcData = initMKReq.MKD_SMR2.kmcData;
|
|
|
+
|
|
|
+ struct InstanceAnsJson
|
|
|
+ {
|
|
|
+ string TMK;
|
|
|
+ string TPK;
|
|
|
+ string EDK;
|
|
|
+ string index;
|
|
|
+ string reserved;
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(TMK, TPK, EDK, index)
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("tmk", "tpk", "edk", "index")
|
|
|
+
|
|
|
+
|
|
|
+ } instanceAns;
|
|
|
+
|
|
|
+ HttpClientResponseResult result;
|
|
|
+ HttpClientRequestConfig config(HttpRequestMethod::POST, m_entity->GetInitUrl().GetData());
|
|
|
+ config.SetChildUri("/api/initmk");
|
|
|
+ SP::Module::Restful::FulfillRequestJsonBody(&config, instanceReq);
|
|
|
+
|
|
|
+ RestfulClient client = RestfulClient::getInstance();
|
|
|
+ config.PreDo();
|
|
|
+ client.Do(&config, &result);
|
|
|
+ if (result.ResponseOK()) {
|
|
|
+
|
|
|
Dbg("InitializerInitMKTask Connect Success.");
|
|
|
- if (initMKRet.m_userCode.compare(ACS_SUCCESS)) {
|
|
|
- Dbg("update wk failed: %s", initMKRet.m_errMsg.c_str());
|
|
|
- std::string errStr("#ACS#");
|
|
|
- errStr += initMKRet.m_errMsg;
|
|
|
- m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, errStr.c_str());
|
|
|
- SAFE_DELETE_HTTPCLIENT(client);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (m_entity->HasPinPad())
|
|
|
- {
|
|
|
- if (m_entity->LoadKeysToPinPadACS(initMKRet.data.TMK, initMKRet.data.TPK, initMKRet.data.EDK, initMKRet.data.index) == Error_Succeed)
|
|
|
+ SP::Module::Restful::CommResponseJson responseStatus;
|
|
|
+ SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);
|
|
|
+ if (!responseStatus.IsOperatedOK()) {
|
|
|
+ Dbg("update wk failed: %s", responseStatus.errorMsg.c_str());
|
|
|
+ m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, responseStatus.errorMsg.c_str());
|
|
|
+ } else {
|
|
|
+ if (m_entity->HasPinPad()) {
|
|
|
+ const bool testResult = SP::Module::Restful::ExtractDataFromDebranchResponse(result.content, instanceAns);
|
|
|
+ Dbg("ExtractDataFromDebranchResponse returned: %d", testResult);
|
|
|
+ if (m_entity->LoadKeysToPinPadACS(instanceAns.TMK, instanceAns.TPK, instanceAns.EDK, instanceAns.index) == Error_Succeed) {
|
|
|
+ m_entity->EndInitMK(Error_Succeed, "");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, "加载秘钥到密码键盘失败");//,待完善细化错误码oiltest
|
|
|
+ }
|
|
|
+ } else {
|
|
|
m_entity->EndInitMK(Error_Succeed, "");
|
|
|
- else
|
|
|
- m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, "加载秘钥到密码键盘失败");//,待完善细化错误码oiltest
|
|
|
- }else
|
|
|
- m_entity->EndInitMK(Error_Succeed, "");
|
|
|
- //int len = 0;
|
|
|
- //char* tmp = MyBase64::Hex2Str(updateWKRet.data.TMK.c_str(), len);
|
|
|
- //int textLen = 2 * len;
|
|
|
- //BYTE* text = new BYTE[textLen];
|
|
|
- //memset(text, 0, textLen);
|
|
|
- //if (!m_fsm->DecryptWithSessionKey((BYTE*)tmp, len, text, textLen)) {
|
|
|
- // delete[] tmp;
|
|
|
- // delete[] text;
|
|
|
- // goto UpdateWKRetError;
|
|
|
- //}
|
|
|
- //updateWKRet.data.TMK.assign((char*)text);
|
|
|
- //delete[] text;
|
|
|
- //delete tmp;
|
|
|
-
|
|
|
- //Dbg("tmk=%s %d", updateWKRet.data.TMK.c_str(), updateWKRet.data.TMK.size());
|
|
|
- //Dbg("tpk=%s %d", updateWKRet.data.TPK.c_str(), updateWKRet.data.TPK.size());
|
|
|
- //Dbg("edk=%s %d", updateWKRet.data.EDK.c_str(), updateWKRet.data.EDK.size());
|
|
|
- //Dbg("index=%s %d", updateWKRet.data.index.c_str(), updateWKRet.data.index.size());
|
|
|
-
|
|
|
- //DWORD rc = m_entity->LoadKeysToPinPadNew(updateWKRet.data.TMK, updateWKRet.data.TPK,
|
|
|
- // updateWKRet.data.EDK, updateWKRet.data.index);
|
|
|
- //if (rc == Error_Succeed) {
|
|
|
- // Dbg("UpdateWKTask LoadKeysToPinPadNew Success");
|
|
|
- // FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_UpdateWKSucc);
|
|
|
- // m_fsm->PostEventFIFO(pEvent);
|
|
|
- // if (client) client->Destory();
|
|
|
- // return;
|
|
|
- //}
|
|
|
- //else {
|
|
|
- // Dbg("UpdateWKTask LoadKeysToPinPadNew error = %08X", rc);
|
|
|
-
|
|
|
- //}
|
|
|
- }
|
|
|
- else {
|
|
|
- //m_fsm->doWarnMsg(ERROR_ACCESSAUTH_CONNECT_ACS,
|
|
|
- // GetOutPutStr("%s%d", "连接总行ACS准入服务失败(StageReport).", updateWKRet.m_sysCode).c_str(), true);
|
|
|
- Dbg("UpdateWKTask Connect Failed.");
|
|
|
- }
|
|
|
- //UpdateWKRetError:
|
|
|
- // FSMEvent* pEvent = new FSMEvent(CAccessAuthFSM::Event_UpdateWKFail);
|
|
|
- // m_fsm->PostEventFIFO(pEvent);
|
|
|
- SAFE_DELETE_HTTPCLIENT(client);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Dbg("post wk failed: %s", result.WhatError().c_str());
|
|
|
+ m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, result.WhatError().c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+ IHttpFunc* client;
|
|
|
+ client = create_http(m_fsm->HttpsLogCallBack);
|
|
|
+ initMKReq.m_bTransCode = false;
|
|
|
+ CInitlizerMKRet initMKRet;
|
|
|
+ initMKReq.m_url = m_entity->GetInitUrl();
|
|
|
+ initMKReq.m_url += "/api/initmk";
|
|
|
+ bool ret = client->Post(initMKReq, initMKRet);
|
|
|
+ Dbg("code=%d", initMKRet.m_sysCode);
|
|
|
+ if (ret) {
|
|
|
+ Dbg("InitializerInitMKTask Connect Success.");
|
|
|
+ if (initMKRet.m_userCode.compare(ACS_SUCCESS)) {
|
|
|
+ Dbg("update wk failed: %s", initMKRet.m_errMsg.c_str());
|
|
|
+ std::string errStr("#ACS#");
|
|
|
+ errStr += initMKRet.m_errMsg;
|
|
|
+ m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, errStr.c_str());
|
|
|
+ SAFE_DELETE_HTTPCLIENT(client);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (m_entity->HasPinPad()) {
|
|
|
+ if (m_entity->LoadKeysToPinPadACS(initMKRet.data.TMK, initMKRet.data.TPK, initMKRet.data.EDK, initMKRet.data.index) == Error_Succeed)
|
|
|
+ m_entity->EndInitMK(Error_Succeed, "");
|
|
|
+ else
|
|
|
+ m_entity->EndInitMK(ERR_INITIALIZER_INIT_EXCEPTION, "加载秘钥到密码键盘失败");//,待完善细化错误码oiltest
|
|
|
+ } else
|
|
|
+ m_entity->EndInitMK(Error_Succeed, "");
|
|
|
+ } else {
|
|
|
+ Dbg("UpdateWKTask Connect Failed.");
|
|
|
+ }
|
|
|
+ SAFE_DELETE_HTTPCLIENT(client);
|
|
|
+
|
|
|
+#endif //WITH_CPPRESTSDK
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
void CInitializerEntity::BeginLoginACS(const char* pszAuthServer)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
@@ -2223,7 +2359,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
LogWarn(Severity_Middle, (ErrorCodeEnum)rc, ERR_INITIALIZER_READ_WRITE_FILE,
|
|
|
GetOutPutStr("%s%08X%s%s", "OpenConfig", rc, "File", "Config_CenterSetting").c_str());
|
|
|
rc = ERR_INITIALIZER_READ_WRITE_FILE;
|
|
|
- //pEntity->m_strLastErrMsg = CSimpleStringA::Format("打开集中配置失败,请先下载集中配置!");
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
@@ -2236,8 +2371,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
{
|
|
|
LogWarn(Severity_Low, (ErrorCodeEnum)rc, ERR_INITIALIZER_READ_WRITE_FILE,
|
|
|
GetOutPutStr("%s%08X%s%s", "ReadConfigValue", rc, "File", "SubBankNo & BranchNo").c_str());
|
|
|
-
|
|
|
- //pEntity->m_strLastErrMsg = CSimpleStringA::Format("集中配置Initializer节点下没有找到SubBankNo和BranchNo配置项,请联系分行技术部!");
|
|
|
rc = ERR_INITIALIZER_READ_WRITE_FILE;
|
|
|
return rc;
|
|
|
}
|
|
|
@@ -2256,22 +2389,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
// support des key
|
|
|
initMKReq.MKD_REQ2.branchNo = strSubBankNo;
|
|
|
initMKReq.MKD_REQ2.subBankNo = strBranchNo;
|
|
|
- //CBlob blob;
|
|
|
- //blob.Refer(pReq2->kmcData, 600);
|
|
|
-
|
|
|
- //rc = CreateInitMKData(blob, false);
|
|
|
- //if (rc != Error_Succeed)
|
|
|
- //{
|
|
|
- // LogWarn(Severity_Middle, (ErrorCodeEnum)rc, ERR_INITIALIZER_CREATE_INIT_MK,
|
|
|
- // GetOutPutStr("%s%d", "CreateInitTMK", rc).c_str());
|
|
|
- // rc = ERR_INITIALIZER_CREATE_INIT_MK;
|
|
|
- // m_strLastErrMsg = CSimpleStringA::Format("调用KMC接口CreateInitTMKReq(0)失败,错误信息[%s],返回值[%d],请联系维护人员!",
|
|
|
- // (const char*)pEntity->GetKMCLastErrMsg(), rc);
|
|
|
- // return rc;
|
|
|
- //}
|
|
|
-
|
|
|
- //// 添加KMC信息
|
|
|
- //package->AddStruct("MKD_REQ2", false, false, (BYTE*)buf, sizeof(MKDownloadReq2) + blob.m_iLength);
|
|
|
}
|
|
|
|
|
|
if (nCapability == 2 || nCapability == 3)
|
|
|
@@ -2279,29 +2396,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
// support sm key
|
|
|
initMKReq.MKD_SMR2.branchNo = strSubBankNo;
|
|
|
initMKReq.MKD_SMR2.subBankNo = strBranchNo;
|
|
|
-
|
|
|
- //char buf[632];
|
|
|
- //memset(buf, 0, 632);
|
|
|
- //SMMKDownloadReq2* pReq2 = (SMMKDownloadReq2*)buf;
|
|
|
- //strncpy(pReq2->szSubBankNo, (const char*)strSubBankNo, sizeof(pReq2->szSubBankNo) - 1);
|
|
|
- //strncpy(pReq2->szBranchNo, (const char*)strBranchNo, sizeof(pReq2->szBranchNo) - 1);
|
|
|
-
|
|
|
- //CBlob blob;
|
|
|
- //blob.Refer(pReq2->kmcData, 600);
|
|
|
-
|
|
|
- //rc = CreateInitMKData(blob, true);
|
|
|
- //if (rc != Error_Succeed)
|
|
|
- //{
|
|
|
- // LogWarn(Severity_Middle, Error_Unexpect, ERR_INITIALIZER_CREATE_INIT_MK,
|
|
|
- // GetOutPutStr("%s%d", "CreateInitTMK", rc).c_str());
|
|
|
- // rc = ERR_INITIALIZER_CREATE_INIT_MK;
|
|
|
- // m_strLastErrMsg = CSimpleStringA::Format("调用KMC接口CreateInitTMKReq(0)失败,错误信息[%s],返回值[%d],请联系维护人员",
|
|
|
- // (const char*)GetKMCLastErrMsg(), rc);
|
|
|
- // return rc;
|
|
|
- //}
|
|
|
-
|
|
|
- //// 添加KMC信息
|
|
|
- //package->AddStruct("MKD_SMR2", false, false, (BYTE*)buf, sizeof(SMMKDownloadReq2) + blob.m_iLength);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2313,32 +2407,19 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
CSimpleStringA strPinPadID = "", strDeviceID = "";
|
|
|
int nRet = GetPinPadIDAndDeviceID(strPinPadID, strDeviceID);
|
|
|
Dbg("GetPinPadIDAndDeviceID ret: %d, PinPadID: %s, DeviceID: %s", nRet, (const char*)strPinPadID, (const char*)strDeviceID);
|
|
|
- /*
|
|
|
- std::regex pattern(".+-[Ff][Ww][Bb]-.+");
|
|
|
- if (std::regex_match(strDeviceID.GetData(), pattern))
|
|
|
- {
|
|
|
- strDeviceID = "";
|
|
|
- strPinPadID = "";
|
|
|
- }
|
|
|
- Dbg("GetPinPadIDAndDeviceID ret: %d, PinPadID: %s, DeviceID: %s", nRet, (const char*)strPinPadID, (const char*)strDeviceID);
|
|
|
- */
|
|
|
// 从系统获取设备信息和硬件信息
|
|
|
// 变长结构初始化
|
|
|
char buf2[512];
|
|
|
memset(buf2, 0, 512);
|
|
|
|
|
|
- //MKDownloadNew1* pReq1 = (MKDownloadNew1*)buf2;
|
|
|
CSystemStaticInfo si;
|
|
|
pFunc->GetSystemStaticInfo(si);
|
|
|
- //strncpy(pReq1->szTerminalNo, (const char*)si.strTerminalID, sizeof(pReq1->szTerminalNo) - 1);
|
|
|
initMKReq.MKD_NEW1.terminalNo = si.strTerminalID;
|
|
|
initMKReq.MKD_NEW1.installVersion = si.InstallVersion.ToString();
|
|
|
- if (nRet == 2 || nRet == 3)
|
|
|
- //strncpy(pReq1->szPadDeviceID, (const char*)strDeviceID, sizeof(pReq1->szPadDeviceID) - 1);
|
|
|
+ if (nRet == 2 || nRet == 3) {
|
|
|
initMKReq.MKD_NEW1.padDeviceID = strDeviceID;
|
|
|
+ }
|
|
|
|
|
|
- //strncpy(pReq1->szMachineType, (const char*)si.strMachineType, sizeof(pReq1->szMachineType) - 1);
|
|
|
- //strncpy(pReq1->szSite, (const char*)si.strSite, sizeof(pReq1->szSite) - 1);
|
|
|
initMKReq.MKD_NEW1.machineType = si.strMachineType;
|
|
|
initMKReq.MKD_NEW1.site = si.strSite;
|
|
|
BYTE xIP[64] = {};
|
|
|
@@ -2362,10 +2443,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
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.MKD_NEW1.ip = xIP;
|
|
|
Dbg("ip:%s",xIP);
|
|
|
- //pReq1->ip[0] = in->S_un.S_un_b.s_b1;
|
|
|
- //pReq1->ip[1] = in->S_un.S_un_b.s_b2;
|
|
|
- //pReq1->ip[2] = in->S_un.S_un_b.s_b3;
|
|
|
- //pReq1->ip[3] = in->S_un.S_un_b.s_b4;
|
|
|
}
|
|
|
#else
|
|
|
char ip[32] = { 0 };
|
|
|
@@ -2383,40 +2460,10 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
}
|
|
|
}
|
|
|
#endif //RVC_OS_WIN
|
|
|
- //BYTE xGps[4];
|
|
|
- //si.EnrolGPS.GetBinaryLongitude(&pReq1->enrolGPS[0]);
|
|
|
- //si.EnrolGPS.GetBinaryLatitude(&pReq1->enrolGPS[4]);
|
|
|
- //Dbg("GPS=%s", (char*)&pReq1->enrolGPS);
|
|
|
+
|
|
|
initMKReq.MKD_NEW1.enrolGPS = "00000A4500000A4E";//oiltmp
|
|
|
initMKReq.MKD_NEW1.enrolAddr = si.strEnrolAddr;
|
|
|
- //strcpy(pReq1->szEnrolAddr, (const char*)si.strEnrolAddr);
|
|
|
-
|
|
|
- //int nStructLen = sizeof(MKDownloadNew1) + strlen(pReq1->szEnrolAddr); // 变长结构长度计算
|
|
|
- //package->AddStruct("MKD_NEW1", false, false, (BYTE*)buf2, nStructLen);
|
|
|
-
|
|
|
- // 获取硬件信息
|
|
|
- //int nDevEntityCount = 0;
|
|
|
- //BYTE* pDevInfo = NULL;
|
|
|
- //if ((rc = GetModalInfo(&pDevInfo, nDevEntityCount)) != Error_Succeed) return rc;
|
|
|
- //else if (pDevInfo == NULL) {
|
|
|
- // Dbg("pDexInfo is NULL.");
|
|
|
- //}
|
|
|
- //else {
|
|
|
- // Dbg("GetModalInfo succ.");
|
|
|
- //}
|
|
|
- //if (nDevEntityCount > 0 && pDevInfo != NULL) {
|
|
|
- // RequestTokenReq2* R2Array = (RequestTokenReq2*)pDevInfo;
|
|
|
- // for (int i = 0; i < nDevEntityCount; i++) {
|
|
|
- // Dbg("szFactory=%s", R2Array->szFactory);
|
|
|
- // getTokenReq->TOKEN_R2[i]->factory = R2Array->szFactory;
|
|
|
- // getTokenReq->TOKEN_R2[i]->modal = R2Array->szModal;
|
|
|
- // getTokenReq->TOKEN_R2[i]->type = R2Array->szType;
|
|
|
- // getTokenReq->TOKEN_R2[i]->versoin = (char*)R2Array->version;
|
|
|
- // R2Array++;
|
|
|
- // }
|
|
|
- // delete pDevInfo;
|
|
|
- //}
|
|
|
- //oiltest
|
|
|
+
|
|
|
initMKReq.MKD_REQ3[0]->modal = "";
|
|
|
initMKReq.MKD_REQ3[0]->factory = "";
|
|
|
initMKReq.MKD_REQ3[0]->type = "";
|
|
|
@@ -2429,8 +2476,6 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
GetOutPutStr("%s%s", "GetTerminalFingerPrint", "False").c_str());
|
|
|
return ERR_INITIALIZER_GET_TERMINAL_FINGERPRINT;
|
|
|
}
|
|
|
- //memcpy(req4.FingerPrint, fingerPrint, 16);
|
|
|
- //memcpy(req4.FingerPrintSM, fingerPrint + 16, 16);
|
|
|
string xFingerPrint = ConvertBytesToHexStr(fingerPrint, nBufLen);
|
|
|
initMKReq.MKD_REQ4.fingerPrint = xFingerPrint.substr(0,32);
|
|
|
initMKReq.MKD_REQ4.fingerPrintSM = xFingerPrint.substr(32, 64);
|
|
|
@@ -2451,17 +2496,11 @@ bool CInitializerEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
|
|
|
//strncpy(req4.PinPadID, (const char*)strPinPadID, sizeof(req4.PinPadID) - 1);
|
|
|
initMKReq.MKD_REQ4.pinPadID = strPinPadID;
|
|
|
|
|
|
- //package->AddStruct("MKD_REQ4", false, false, (BYTE*)&req4, sizeof(req4));
|
|
|
-
|
|
|
//国密改造
|
|
|
- //MKDownloadReq5 req5 = {};
|
|
|
initMKReq.MKD_REQ5.isFirstSM = GetOrSetIsFirstSM(0);
|
|
|
initMKReq.MKD_REQ5.isSM = 1;
|
|
|
- //package->AddStruct("MKD_REQ5", false, false, (BYTE*)&req5, sizeof(req5));
|
|
|
Dbg("rinitMKReq.MKD_REQ5.isFirstSM=%d", initMKReq.MKD_REQ5.isFirstSM);
|
|
|
- Dbg("send MK init request now");
|
|
|
return true;
|
|
|
- //return SendPackage(package) != "" ? Error_Succeed : ERR_INITIALIZER_INIT_MK_SEND_PKG;
|
|
|
}
|
|
|
int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len)
|
|
|
{
|
|
|
@@ -2534,16 +2573,10 @@ ErrorCodeEnum CInitializerEntity::LoadKeysToPinPadACS(string TMK, string TPK, st
|
|
|
char* pxx = new char[1024];
|
|
|
memset(pxx, 0, 1024);
|
|
|
HexBuf2StrBuf((BYTE*)pDecryptPrivateKey, &pxx, decryprtLen);
|
|
|
- //char* pEncodeTMK = MyBase64::Str2Hex(TMK.c_str(), TMK.size());
|
|
|
PBYTE pBt = new BYTE[512];
|
|
|
memset(pBt, 0, 512);
|
|
|
StrBuf2HexBuf(TMK.c_str(), &pBt);
|
|
|
|
|
|
- //if (DecWithSM2PriKey(pBt, 258 / 2, (BYTE*)pPlainTMK, &plainKeyLen, (BYTE*)pDecryptPrivateKey, decryprtLen))
|
|
|
- // Dbg("ok");
|
|
|
- //else
|
|
|
- // Dbg("not ok");
|
|
|
- //return Error_Unexpect;
|
|
|
if (!DecWithSM2PriKey(pBt, TMK.size()/2, (BYTE*)pPlainTMK, &plainKeyLen, (BYTE*)pDecryptPrivateKey, decryprtLen)) {
|
|
|
Dbg("使用私钥解密TMK失败!");
|
|
|
return Error_Unexpect;
|