本文整理汇总了C++中OTASCIIArmor::Exists方法的典型用法代码示例。如果您正苦于以下问题:C++ OTASCIIArmor::Exists方法的具体用法?C++ OTASCIIArmor::Exists怎么用?C++ OTASCIIArmor::Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTASCIIArmor
的用法示例。
在下文中一共展示了OTASCIIArmor::Exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// This version base64-DECODES the ascii-armored string passed in,
// and then sets the decoded plaintext string onto this object.
OTString::OTString(const OTASCIIArmor & strValue) : m_lLength(0), m_lPosition(0), m_strBuffer(NULL)
{
// Initialize();
if (strValue.Exists())
strValue.GetString(*this);
}
示例2:
// This version base64-DECODES the ascii-armored string passed in,
// and then sets the decoded plaintext string onto this object.
OTString::OTString(const OTASCIIArmor & strValue)
{
Initialize();
if (strValue.Exists())
strValue.GetString(*this);
}
示例3:
// This version base64-DECODES the ascii-armored string passed in,
// and then sets the decoded plaintext string onto this object.
String::String(const OTASCIIArmor& strValue)
: length_(0)
, position_(0)
, data_(nullptr)
{
// Initialize();
if (strValue.Exists()) strValue.GetString(*this);
}
示例4:
OTCachedKey::OTCachedKey(const OTASCIIArmor & ascCachedKey) :
m_pThread(NULL),
m_nTimeoutSeconds(OTCachedKey::It()->GetTimeoutSeconds()),
m_pMasterPassword(NULL), // This is created in GetMasterPassword, and destroyed by a timer thread sometime soon after.
m_bUse_System_Keyring(OTCachedKey::It()->IsUsingSystemKeyring()), // this master key instance will decide to use the system keyring based on what the global master key instance is set to do. (So we get the same settings from config file, etc.)
m_pSymmetricKey(NULL), // OTServer OR OTWallet owns this key, and sets this pointer. It's the encrypted form of s_pMasterPassword.
m_bPaused(false)
{
OT_ASSERT(ascCachedKey.Exists());
this->SetCachedKey(ascCachedKey);
}
示例5: ProcessXMLNode
int OTPurse::ProcessXMLNode(irr::io::IrrXMLReader*& xml)
{
if (!strcmp("purse", xml->getNodeName()))
{
OTString strServerID, strUserID, strAssetID, strTotalValue;
m_strVersion = xml->getAttributeValue("version");
strUserID = xml->getAttributeValue("userID");
strServerID = xml->getAttributeValue("serverID");
strAssetID = xml->getAttributeValue("assetTypeID");
strTotalValue = xml->getAttributeValue("totalValue");
m_AssetID.SetString(strAssetID);
m_UserID.SetString(strUserID);
m_ServerID.SetString(strServerID);
m_lTotalValue = 0;
if (strTotalValue.Exists() && (atol(strTotalValue.Get()) > 0))
m_lTotalValue = atol(strTotalValue.Get());
OTLog::vOutput(4, "Loaded purse...\n ServerID: %s\n UserID: %s\n Asset ID: %s\n----------\n", strServerID.Get(),
strUserID.Get(), strAssetID.Get());
return 1;
}
else if (!strcmp("token", xml->getNodeName()))
{
OTASCIIArmor * pArmor = new OTASCIIArmor;
OT_ASSERT(NULL != pArmor);
if (!LoadEncodedTextField(xml, *pArmor) || !pArmor->Exists())
{
OTLog::Error("Error in OTPurse::ProcessXMLNode: token field without value.\n");
delete pArmor;
pArmor = NULL;
return (-1); // error condition
}
else
{
m_dequeTokens.push_front(pArmor);
}
return 1;
}
return 0;
}
示例6: SetCachedKey
// Called by OTServer or OTWallet, or whatever instantiates those.
//
void OTCachedKey::SetCachedKey(const OTASCIIArmor & ascCachedKey)
{
tthread::lock_guard<tthread::mutex> lock(m_Mutex); // Multiple threads can't get inside here at the same time.
OT_ASSERT(ascCachedKey.Exists());
// ----------------------------------------
if (NULL != m_pSymmetricKey)
{
OTLog::Error("OTCachedKey::SetCachedKey: Warning: This was already set. (Re-setting.)\n");
delete m_pSymmetricKey;
m_pSymmetricKey = NULL;
}
// -----------------------------------------
m_pSymmetricKey = new OTSymmetricKey;
OT_ASSERT(NULL != m_pSymmetricKey);
// ----------------------------------
//const bool bSerialized =
m_pSymmetricKey->SerializeFrom(ascCachedKey);
}
示例7: Windows_RetrieveSecret
// static
bool OTKeyring::Windows_RetrieveSecret(const OTString& strUser,
OTPassword& thePassword,
const std::string& str_display)
{
OT_ASSERT(strUser.Exists());
OTString strFoldername("win32_data"); // todo hardcoding.
OTASCIIArmor ascFileContents;
bool bLoaded = (strFoldername.Exists() &&
ascFileContents.LoadFromFile(strFoldername, strUser) &&
ascFileContents.Exists());
if (!bLoaded) {
otWarn << "%s: No cached ciphertext of master key loaded during "
"attempted retrieval. "
"(However, once one is available, it WILL be cached using "
"DPAPI.) \n";
return false;
}
// Below this point, we know for sure the ciphertext of the master
// key loaded, and exists.
//
const OTData theCipherblob(ascFileContents);
//
if (theCipherblob.IsEmpty()) {
otErr << __FUNCTION__ << ": Error: OTData is empty after decoding "
"OTASCIIArmor (that wasn't empty.)\n";
}
else {
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(theCipherblob.GetPayloadPointer()));
input.cbData = static_cast<DWORD>(theCipherblob.GetSize());
// CRYPTPROTECT_PROMPTSTRUCT PromptStruct;
// ZeroMemory(&PromptStruct, sizeof(PromptStruct));
// PromptStruct.cbSize = sizeof(PromptStruct);
// PromptStruct.dwPromptFlags = CRYPTPROTECT_PROMPT_ON_PROTECT;
// PromptStruct.szPrompt = L"This is a user prompt.";
// LPWSTR pDescrOut = nullptr;
DATA_BLOB output;
BOOL result = CryptUnprotectData(&input, nullptr, // &pDescrOut
nullptr, // optional entropy
nullptr, // reserved
nullptr, //&PromptStruct
0, &output);
if (!result) {
otErr << __FUNCTION__
<< ": Error: Output of Win32 CryptUnprotectData was empty.\n";
}
else {
thePassword.setMemory(reinterpret_cast<void*>(output.pbData),
static_cast<uint32_t>(output.cbData));
SecureZeroMemory(output.pbData, output.cbData);
LocalFree(output.pbData);
// LocalFree(pDescrOut);
return true;
}
}
return false;
}
示例8:
OTData::OTData(const OTASCIIArmor &theSource) : m_pData(NULL), m_lPosition(0), m_lSize(0)
{
if (theSource.Exists())
theSource.GetData(*this); // ***********
}
示例9: LoadMainFile
bool MainFile::LoadMainFile(bool bReadOnly)
{
if (!OTDB::Exists(".", server_->m_strWalletFilename.Get())) {
Log::vError("%s: Error finding file: %s\n", __FUNCTION__,
server_->m_strWalletFilename.Get());
return false;
}
String strFileContents(OTDB::QueryPlainString(
".",
server_->m_strWalletFilename.Get())); // <=== LOADING FROM DATA STORE.
if (!strFileContents.Exists()) {
Log::vError("%s: Unable to read main file: %s\n", __FUNCTION__,
server_->m_strWalletFilename.Get());
return false;
}
bool bNeedToSaveAgain = false;
bool bFailure = false;
{
OTStringXML xmlFileContents(strFileContents);
if (false ==
xmlFileContents.DecodeIfArmored()) // bEscapedIsAllowed=true by
// default.
{
Log::vError("%s: Notary server file apparently was encoded and "
"then failed decoding. Filename: %s \n"
"Contents: \n%s\n",
__FUNCTION__, server_->m_strWalletFilename.Get(),
strFileContents.Get());
return false;
}
irr::io::IrrXMLReader* xml =
irr::io::createIrrXMLReader(xmlFileContents);
std::unique_ptr<irr::io::IrrXMLReader> theXMLGuardian(xml);
while (xml && xml->read()) {
// strings for storing the data that we want to read out of the file
String AssetName;
String InstrumentDefinitionID;
const String strNodeName(xml->getNodeName());
switch (xml->getNodeType()) {
case irr::io::EXN_TEXT:
// in this xml file, the only text which occurs is the
// messageText
// messageText = xml->getNodeData();
break;
case irr::io::EXN_ELEMENT: {
if (strNodeName.Compare("notaryServer")) {
version_ = xml->getAttributeValue("version");
server_->m_strNotaryID = xml->getAttributeValue("notaryID");
server_->m_strServerNymID =
xml->getAttributeValue("serverNymID");
String strTransactionNumber; // The server issues
// transaction numbers and
// stores the counter here
// for the latest one.
strTransactionNumber =
xml->getAttributeValue("transactionNum");
server_->transactor_.transactionNumber(
strTransactionNumber.ToLong());
Log::vOutput(
0,
"\nLoading Open Transactions server. File version: %s\n"
" Last Issued Transaction Number: %" PRId64
"\n Notary ID: "
" %s\n Server Nym ID: %s\n",
version_.c_str(),
server_->transactor_.transactionNumber(),
server_->m_strNotaryID.Get(),
server_->m_strServerNymID.Get());
}
// todo in the future just remove masterkey. I'm leaving it for
// now so people's
// data files can get converted over. After a while just remove
// it.
//
else if (strNodeName.Compare("masterKey") ||
strNodeName.Compare("cachedKey")) {
OTASCIIArmor ascCachedKey;
if (Contract::LoadEncodedTextField(xml, ascCachedKey)) {
// We successfully loaded the masterKey from file, so
// let's SET it
// as the master key globally...
//
OTCachedKey::It()->SetCachedKey(ascCachedKey);
if (!OTCachedKey::It()->HasHashCheck()) {
OTPassword tempPassword;
tempPassword.zeroMemory();
std::shared_ptr<OTCachedKey> sharedPtr(
//.........这里部分代码省略.........
示例10: ProcessXMLNode
//.........这里部分代码省略.........
// "\n===> Loading XML for token into memory structures..."
"\n\nToken State: %s\n Denomination: %ld\n"
" AssetTypeID: %s\nServerID: %s\n",
strState.Get(), GetDenomination(), strAssetTypeID.Get(), strServerID.Get());
nReturnVal = 1;
}
else if (!strcmp("tokenID", xml->getNodeName()))
{
if (false == LoadEncodedTextField(xml, m_ascSpendable))
{
OTLog::Error("Error in OTToken::ProcessXMLNode: token ID without value.\n");
return (-1); // error condition
}
return 1;
}
else if (!strcmp("tokenSignature", xml->getNodeName()))
{
if (false == LoadEncodedTextField(xml, m_Signature))
{
OTLog::Error("Error in OTToken::ProcessXMLNode: token Signature without value.\n");
return (-1); // error condition
}
return 1;
}
else if (!strcmp("protopurse", xml->getNodeName()))
{ // TODO for security, if the count here doesn't match what's loaded up, that should be part of
// what is verified in each token when it's verified..
m_nTokenCount = atoi(xml->getAttributeValue("count"));
m_nChosenIndex = atoi(xml->getAttributeValue("chosenIndex"));
nPublicTokenCount = 0;
return 1;
}
else if (!strcmp("prototoken", xml->getNodeName()))
{
OTASCIIArmor * pArmoredPrototoken = new OTASCIIArmor;
OT_ASSERT(NULL != pArmoredPrototoken);
if (!LoadEncodedTextField(xml, *pArmoredPrototoken) || !pArmoredPrototoken->Exists())
{
OTLog::Error("Error in OTToken::ProcessXMLNode: prototoken field without value.\n");
delete pArmoredPrototoken;
pArmoredPrototoken = NULL;
return (-1); // error condition
}
else
{
m_mapPublic[nPublicTokenCount] = pArmoredPrototoken;
nPublicTokenCount++;
}
return 1;
}
else if (!strcmp("privateProtopurse", xml->getNodeName()))
{
nPrivateTokenCount = 0;
return 1;
}
else if (!strcmp("privatePrototoken", xml->getNodeName()))
{
OTASCIIArmor * pArmoredPrototoken = new OTASCIIArmor;
OT_ASSERT(NULL != pArmoredPrototoken);
if (!LoadEncodedTextField(xml, *pArmoredPrototoken) || !pArmoredPrototoken->Exists())
{
OTLog::Error("Error in OTToken::ProcessXMLNode: privatePrototoken field without value.\n");
delete pArmoredPrototoken;
pArmoredPrototoken = NULL;
return (-1); // error condition
}
else
{
m_mapPrivate[nPrivateTokenCount] = pArmoredPrototoken;
nPrivateTokenCount++;
OTLog::vOutput(4, "Loaded prototoken and adding to m_mapPrivate at index: %d\n", nPrivateTokenCount-1);
}
return 1;
}
return nReturnVal;
}
示例11:
OTData::OTData(const OTASCIIArmor& source)
{
if (source.Exists()) {
source.GetData(*this);
}
}