本文整理汇总了C++中Lobby::otpKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Lobby::otpKey方法的具体用法?C++ Lobby::otpKey怎么用?C++ Lobby::otpKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lobby
的用法示例。
在下文中一共展示了Lobby::otpKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ABC_LoginServerOtpRequest
tABC_CC ABC_LoginServerOtpRequest(const char *szUrl,
const Lobby &lobby,
tABC_U08Buf LP1,
JsonPtr *results,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
HttpReply reply;
ServerReplyJson replyJson;
char *szPost = NULL;
json_t *pJSON_Root = NULL;
// create the post data
pJSON_Root = json_pack("{ss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str());
// If there is a LP1 provided
if (LP1.data())
{
json_object_set_new(pJSON_Root, ABC_SERVER_JSON_LP1_FIELD,
json_string(base64Encode(LP1).c_str()));
}
{
auto key = lobby.otpKey();
if (key)
json_object_set_new(pJSON_Root, ABC_SERVER_JSON_OTP_FIELD, json_string(key->totp().c_str()));
}
json_object_set_new(pJSON_Root, ABC_SERVER_JSON_OTP_RESET_AUTH, json_string(gOtpResetAuth.c_str()));
szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT);
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, szUrl, szPost));
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
if (results)
*results = replyJson.results();
exit:
ABC_FREE_STR(szPost);
if (pJSON_Root) json_decref(pJSON_Root);
return cc;
}
示例2: ABC_LoginServerOtpEnable
/**
* Enables 2 Factor authentication
*
* @param LP1 Password hash for the account
* @param timeout Amount of time needed for a reset to complete
*/
tABC_CC ABC_LoginServerOtpEnable(const Lobby &lobby,
tABC_U08Buf LP1,
const char *szOtpSecret,
const long timeout,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
HttpReply reply;
std::string url = ABC_SERVER_ROOT "/otp/on";
ServerReplyJson replyJson;
char *szPost = NULL;
json_t *pJSON_Root = NULL;
ABC_CHECK_NULL_BUF(LP1);
// create the post data
pJSON_Root = json_pack("{sssssssi}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
ABC_SERVER_JSON_LP1_FIELD, base64Encode(LP1).c_str(),
ABC_SERVER_JSON_OTP_SECRET_FIELD, szOtpSecret,
ABC_SERVER_JSON_OTP_TIMEOUT, timeout);
{
auto key = lobby.otpKey();
if (key)
json_object_set_new(pJSON_Root, ABC_SERVER_JSON_OTP_FIELD, json_string(key->totp().c_str()));
}
szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT);
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, url, szPost));
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
exit:
ABC_FREE_STR(szPost);
if (pJSON_Root) json_decref(pJSON_Root);
return cc;
}
示例3: ABC_LoginServerGetString
/**
* Helper function for getting CarePackage or LoginPackage.
*/
static
tABC_CC ABC_LoginServerGetString(const Lobby &lobby, tABC_U08Buf LP1, tABC_U08Buf LRA1,
const char *szURL, const char *szField, char **szResponse, tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
HttpReply reply;
ServerReplyJson replyJson;
json_t *pJSON_Value = NULL;
json_t *pJSON_Root = NULL;
char *szPost = NULL;
// create the post data with or without LP1
if (LP1.data() == NULL && LRA1.data() == NULL)
{
pJSON_Root = json_pack("{ss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str());
}
else
{
if (LP1.data() == NULL)
{
pJSON_Root = json_pack("{ssss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
ABC_SERVER_JSON_LRA1_FIELD, base64Encode(LRA1).c_str());
}
else
{
pJSON_Root = json_pack("{ssss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
ABC_SERVER_JSON_LP1_FIELD, base64Encode(LP1).c_str());
}
}
{
auto key = lobby.otpKey();
if (key)
json_object_set_new(pJSON_Root, ABC_SERVER_JSON_OTP_FIELD, json_string(key->totp().c_str()));
}
szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT);
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, szURL, szPost));
// Check the results, and store json if successful
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
// get the care package
pJSON_Value = replyJson.results().get();
ABC_CHECK_ASSERT((pJSON_Value && json_is_object(pJSON_Value)), ABC_CC_JSONError, "Error parsing server JSON care package results");
pJSON_Value = json_object_get(pJSON_Value, szField);
ABC_CHECK_ASSERT((pJSON_Value && json_is_string(pJSON_Value)), ABC_CC_JSONError, "Error care package JSON results");
ABC_STRDUP(*szResponse, json_string_value(pJSON_Value));
exit:
if (pJSON_Root) json_decref(pJSON_Root);
ABC_FREE_STR(szPost);
return cc;
}