std::string HandleRequest(const std::string& request_json)
		{
			try
			{
				static const std::string OK = ""; // TODO maybe improve this use the same variable defined by "HardwareCmd".
				HWRequest hw_req = ParseRequest(request_json);

				LOG_TRACE(L"执行硬件调用请求:" + str_2_wstr("[" + hw_req.cmd + "," +hw_req.file_id + "," + hw_req.seq + "]"));
				HardwareCmd::Reply reply = m_hw_cmd_map.at(hw_req.cmd + hw_req.file_id).Execute(hw_req.data);
				std::string answer = "";
				if (boost::iequals(OK, reply.error_code)) // Succeed.
					answer = hw_req.cmd + "_ack";
				else
					answer = hw_req.cmd + "_failed";
				std::string reply_json = MakeResultJSON(answer, hw_req.file_id, reply.error_code, hw_req.seq, reply.data);
				LOG_TRACE(L"执行硬件调用结果:" + str_2_wstr("[" + hw_req.cmd + "," + hw_req.file_id + "," + hw_req.seq + "] [" + reply.error_code + "]") + +L"\n");
				return reply_json;
			}
			catch (std::exception& ex)
			{
				LOG_FATAL(L"执行硬件调用请求发生异常,异常信息: " + str_2_wstr(ex.what()) + L"\n");
				return "";
			}
		}
ApplicationConfig::ApplicationConfig()
{
	std::stringstream ss;
	try
	{
#ifdef _DEBUG
		// 在调试的时候,先生成加密文件
		AES_CBC::EncryptFileToFile(PLAIN_TEXT_FILE, CIPHER_TEXT_FILE);
#endif 
		ss << AES_CBC::DecryptFromFile(CIPHER_TEXT_FILE);
	}
	catch (std::exception& ex)
	{
		LOG_ERROR(gbk_2_wstr(ex.what()));
		return;
	}

	namespace PT = boost::property_tree;
	try //Parse the configuration file
	{
		PT::ptree ptree;
		PT::read_json(ss, ptree);

		m_msg_count_query_interval = ptree.get<uint32_t>("msg_count_query_interval");
		m_pwd_machine_ip = ptree.get<std::string>("pwd_machine_ip");
		m_pwd_machine_port = ptree.get<uint32_t>("pwd_machine_port");
		m_pwd_machine_timeout = ptree.get<uint32_t>("pwd_machine_timeout");
		m_pin_pad_pwd_len = ptree.get<uint8_t>("pin_pad_pwd_len");
		m_pin_pad_timeout = ptree.get<uint8_t>("pin_pad_timeout");
		m_client_cert_store = ptree.get<std::string>("client_cert_store");
		m_client_cert_subject = ptree.get<std::string>("client_cert_subject");
	}
	catch (...) // Catch the exception in order for logging.
	{
		LOG_ERROR(L"解析路径配置文件" + str_2_wstr(CIPHER_TEXT_FILE) + L"出错!请确认该配置文件存在,存放的json数据格式正确!");
		throw; // Don't swallow the exception!
	}
}
Beispiel #3
0
std::wstring PlutoUtil::GetFullPathW(const char* path){
	std::string pstr = SysEnv::GetVariable("PLU_ROOT") + path;
	std::wstring wst;
	str_2_wstr(pstr, wst);
	return wst;
}