本文整理汇总了C++中OTString::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ OTString::Get方法的具体用法?C++ OTString::Get怎么用?C++ OTString::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTString
的用法示例。
在下文中一共展示了OTString::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveAndReloadBothKeysFromTempFile
bool OTKeypair::SaveAndReloadBothKeysFromTempFile( OTString * pstrOutputCert/*=NULL*/,
const OTString * pstrReason/*=NULL*/,
OTPassword * pImportPassword/*=NULL*/)
{
OT_ASSERT(NULL != m_pkeyPrivate);
OT_ASSERT(NULL != m_pkeyPublic);
// ---------------------------------------------------------------
OTString strOutput;
const bool bSuccess = this->SaveCertAndPrivateKeyToString(strOutput, pstrReason, pImportPassword);
// ---------------------------------------
if (bSuccess)
{
// todo security. Revisit this part during security audit.
//
const OTString strFilename("temp.nym"); // todo stop hardcoding. Plus this maybe should select a random number too.
if (false == OTDB::StorePlainString(strOutput.Get(), OTFolders::Cert().Get(), strFilename.Get())) // temp.nym
{
OTLog::vError("%s: Failure storing new cert in temp file: %s\n", __FUNCTION__, strFilename.Get());
return false;
}
// ------------------------------------------
if (false == this->LoadBothKeysFromCertFile(OTFolders::Cert().Get(), strFilename, pstrReason, pImportPassword))
return false; // LoadBothKeysFromCertFile already has error logs, no need to log twice at this point.
// ------------------------------------------
if (NULL != pstrOutputCert)
pstrOutputCert->Set(strOutput); // Success!
}
return bSuccess;
}
示例2: Concatenate
// append a string at the end of the current buffer.
void OTString::Concatenate(const OTString & strBuf)
{
// _WIN32
static char * new_string = NULL;
if (NULL == new_string)
{
new_string = new char[MAX_STRING_LENGTH]; // This only happens once. Static var.
OT_ASSERT(NULL != new_string);
}
new_string[0] = '\0';
// _end _WIN32
if (Exists())
#ifdef _WIN32
{
const char * pBuf = strBuf.Get();
sprintf_s(new_string, MAX_STRING_LENGTH, "%s%s", m_strBuffer, pBuf);
}
#else
snprintf(new_string, MAX_STRING_LENGTH, "%s%s", m_strBuffer, strBuf.Get());
#endif
else
#ifdef _WIN32
{
示例3: GetOTAppDataFolderLocation
// ***********************************************************************
//
// INI FILE
//
bool GetOTAppDataFolderLocation(OTString strIniFileDefault, OTString & strOTServerDataLocation)
{
CSimpleIniA ini;
SI_Error rc = ini.LoadFile(strIniFileDefault.Get());
if (rc >=0)
{
{
const char * pVal = ini.GetValue("paths", "server_path", SERVER_PATH_DEFAULT); // todo stop hardcoding.
if (NULL != pVal)
{
strOTServerDataLocation.Set(pVal);
OTLog::vOutput(0, "Reading ini file (%s). \n Found Server data_folder path: %s \n",
strIniFileDefault.Get(), strOTServerDataLocation.Get());
return true;
}
OTLog::vOutput(0, "Reading ini file (%s) \n", strIniFileDefault.Get());
return false;
}
}
else
{
OTLog::vOutput(0, "Unable to load ini file (%s) to find data_folder path \n",
strIniFileDefault.Get());
return false;
}
}
示例4: Assert
int OTLog::Assert(const char * szFilename, int nLinenumber)
{
if ((NULL != szFilename))
{
#ifndef ANDROID // if NOT android
std::cerr << "OT_ASSERT in " << szFilename << " at line " << nLinenumber << "\n";
// -----------------------------
// Grab this if we can, too...
//
OTString strTemp;
strTemp.Format("OT_ASSERT in %s at line %d\n", szFilename, nLinenumber);
LogToFile(strTemp.Get());
// -----------------------------
#else // if Android
OTString strAndroidAssertMsg;
strAndroidAssertMsg.Format("\nOT_ASSERT in %s at line %d\n", szFilename, nLinenumber);
__android_log_write(ANDROID_LOG_FATAL,"OT Assert", (const char *)strAndroidAssertMsg.Get());
#endif
#ifndef _WIN32
print_stacktrace();
#endif
}
abort();
return -1;
}
示例5: LoadCron
// Make sure Server Nym is set on this cron object before loading or saving, since it's
// used for signing and verifying..
bool OTCron::LoadCron()
{
static const char * szCronFile = "OT-CRON.crn"; // todo stop hardcoding filenames.
OT_ASSERT(NULL != GetServerNym());
// ------------------------------------------------------------------------
bool bFolderExists = OTLog::ConfirmOrCreateFolder(OTLog::CronFolder()); // <path>/cron is where all cronlogs go.
if (!bFolderExists)
{
OTLog::vError("Unable to create or confirm folder \"%s\" in order to load Cron file.\n",
OTLog::CronFolder());
return false;
}
// ------------------------------------------------------------------------
OTString strCronfileLocalPath;
strCronfileLocalPath.Format("%s%s%s", OTLog::CronFolder(), OTLog::PathSeparator(), szCronFile);
// ------------------------------------------------------------------------
OTString strCronfilePath;
strCronfilePath.Format("%s%s%s", OTLog::Path(), OTLog::PathSeparator(), strCronfileLocalPath.Get());
std::ifstream in(strCronfilePath.Get(), std::ios::binary);
if (in.fail())
{
OTLog::vError("Error opening file in OTCron::LoadCron: %s\n",
strCronfilePath.Get());
return false;
}
std::stringstream buffer;
buffer << in.rdbuf();
std::string contents(buffer.str());
OTString strRawFile = contents.c_str();
bool bSuccess = false;
if (strRawFile.GetLength())
{
bSuccess = LoadContractFromString(strRawFile);
if (bSuccess)
{
bSuccess = VerifySignature(*GetServerNym());
}
}
return bSuccess;
// ------------------------------------------------------------------------
}
示例6: in
OTCronItem * OTCronItem::LoadCronReceipt(const long & lTransactionNum)
{
// ------------------------------------------------------------------------
bool bFolderExists = OTLog::ConfirmOrCreateFolder(OTLog::CronFolder()); // <path>/cron is where all cronlogs go.
if (!bFolderExists)
{
OTLog::vError("Unable to create or confirm folder \"%s\"\n in order to load Cron Receipt %ld.\n",
OTLog::CronFolder(), lTransactionNum);
return NULL;
}
// ------------------------------------------------------------------------
OTString strCronItemLocalPath;
strCronItemLocalPath.Format("%s%s%ld.crn", OTLog::CronFolder(),
OTLog::PathSeparator(), lTransactionNum);
bool bFileExists = OTLog::ConfirmFile(strCronItemLocalPath.Get());
if (!bFileExists)
{
OTLog::vError("Attempted to load non-existent Cron Record for transaction %ld in folder %s.\n",
lTransactionNum, strCronItemLocalPath.Get());
return NULL;
}
// ------------------------------------------------------------------------
OTString strCronItemPath;
strCronItemPath.Format("%s%s%s", OTLog::Path(), OTLog::PathSeparator(),
strCronItemLocalPath.Get());
std::ifstream in(strCronItemPath.Get(), std::ios::binary);
if (in.fail())
{
OTLog::vError("Error opening file in OTCronItem::LoadCronReceipt: %s\n",
strCronItemPath.Get());
return NULL;
}
std::stringstream buffer;
buffer << in.rdbuf();
std::string contents(buffer.str());
OTString strRawFile = contents.c_str();
if (strRawFile.GetLength())
return OTCronItem::NewCronItem(strRawFile);
return NULL;
// ------------------------------------------------------------------------
}
示例7: SaveMint
bool OTMint::SaveMint(const char * szAppend/*=NULL*/)
{
if (!m_strFoldername.Exists())
m_strFoldername.Set(OTLog::MintFolder());
const OTString strServerID(m_ServerID), strAssetTypeID(m_AssetID);
if (!m_strFilename.Exists())
{
if (NULL != szAppend)
m_strFilename.Format("%s%s%s%s", strServerID.Get(), OTLog::PathSeparator(),
strAssetTypeID.Get(), szAppend);
else
m_strFilename.Format("%s%s%s", strServerID.Get(), OTLog::PathSeparator(), strAssetTypeID.Get());
}
OTString strFilename;
if (NULL != szAppend)
strFilename.Format("%s%s", strAssetTypeID.Get(), szAppend);
else
strFilename = strAssetTypeID.Get();
const char * szFolder1name = OTLog::MintFolder();
const char * szFolder2name = strServerID.Get();
const char * szFilename = strFilename.Get();
// --------------------------------------------------------------------
OTString strRawFile;
if (!SaveContractRaw(strRawFile))
{
OTLog::vError("Error saving Mintfile (to string):\n%s%s%s%s%s\n", szFolder1name,
OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename);
return false;
}
// --------------------------------------------------------------------
//
bool bSaved = OTDB::StorePlainString(strRawFile.Get(), szFolder1name,
szFolder2name, szFilename); // <=== SAVING TO DATA STORE.
if (!bSaved)
{
if (NULL != szAppend)
OTLog::vError("OTMint::SaveMint: Error writing to file: %s%s%s%s%s%s\n", szFolder1name,
OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename, szAppend);
else
OTLog::vError("OTMint::SaveMint: Error writing to file: %s%s%s%s%s\n", szFolder1name,
OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename);
return false;
}
// --------------------------------------------------------------------
return true;
}
示例8: SetDumper
_OT_Lucre_Dumper::_OT_Lucre_Dumper()
{
#ifdef _WIN32
OTString OpenSSLDumpFilename; // todo security. We shouldn't necessarily be dumping this info to file AT ALL.
OpenSSLDumpFilename.Format("%s%s%s",OTLog::Path(),OTLog::PathSeparator,"openssl.dumpfile"); // todo hardcoding.
SetDumper(OpenSSLDumpFilename.Get()); // We are only dumping this way currently as a temporary solution to the applink.c openssl thing that can cause crashes in Lucre when withdrawing cash. (Caused by da2ce7 removing Lucre from OT and moving it into a dylib.)
m_str_dumpfile = OpenSSLDumpFilename.Get();
#else
SetDumper(stderr);
#endif
}
示例9: defined
// -----------------------------------
__ot_server_() : m_pServer(NULL) // INIT
{
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// OTLog class exists on both client and server sides.
// #define OT_NO_SIGNAL_HANDLING if you want to turn off OT's signal handling.
//
#if defined(OT_SIGNAL_HANDLING)
OTLog::SetupSignalHandler(); // This is optional! (I, of course, am using it in this test app...)
#endif
// -----------------------------------------------------------------------
// I instantiate this here (instead of globally) so that I am assured that any globals and other
// setup is already done before we instantiate the server object itself.
//
OT_ASSERT_MSG(NULL == m_pServer, "server main(): ASSERT: NULL == m_pServer.");
m_pServer = new OTServer;
//
// (This .cpp file you are currently reading is a wrapper for OTServer,
// which adds the transport layer.)
//
OT_ASSERT_MSG(NULL != m_pServer, "server main(): ASSERT: Unable to instantiate OT server.\n");
OTString pathUserAppDataPath, pathIniFileLocation;
pathUserAppDataPath = GetRoamingAppDataLocation();
pathIniFileLocation.Format("%s%s%s", pathUserAppDataPath.Get(), OTLog::PathSeparator(), SERVER_INI_FILE_DEFAULT);
OTString pathOTServerDataLocation;
OTLog::vOutput(0, "\nFound ot_init.cfg in: \n %s \nNow checking to see if it contains the OT Server path...", pathIniFileLocation.Get());
// Read the File, If successful use result
if (false == GetOTAppDataFolderLocation(pathIniFileLocation, pathOTServerDataLocation))
{
OTLog::vOutput(0, "Path not found... Will attempt default!... \n");
// Not successfull will will assume it is in default location:
pathOTServerDataLocation.Format("%s%s%s", pathUserAppDataPath.Get(), OTLog::PathSeparator(), SERVER_PATH_DEFAULT);
};
OTLog::vOutput(0, " %s \n", pathOTServerDataLocation.Get());
OTLog::SetMainPath(pathOTServerDataLocation.Get()); // <============ SET MAIN PATH
OTLog::vOutput(0, "Using server_data path: %s\n", OTLog::Path());
// -----------------------------------------------------------------------
OTCrypto::It()->Init(); // <========== (OpenSSL gets initialized here.)
}
示例10: LoadFromFile
// This code reads up the file, discards the bookends, and saves only the gibberish itself.
bool OTASCIIArmor::LoadFromFile(const OTString & filename)
{
std::ifstream fin(filename.Get(), std::ios::binary);
if (!fin.is_open())
{
OTLog::vError("Error opening file in OTASCIIArmor::LoadFromFile: %s\n", filename.Get());
return false;
}
return LoadFromifstream(fin);
}
示例11:
const bool OTSettings::LogChange_bool(const OTString & strSection,const OTString & strKey,const bool & bValue )
{
if (! strSection.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strSection" ); OT_ASSERT(false); }
if (! strKey.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strKey" ); OT_ASSERT(false); }
OTString strCategory, strOption;
if (!OTLog::StringFill(strCategory,strSection.Get(),12)) return false;
if (!OTLog::StringFill(strOption,strKey.Get(),30," to:")) return false;
OTLog::vOutput(1, "Setting %s %s %s \n",strCategory.Get(),strOption.Get(),bValue ? "true" : "false");
return true;
}
示例12: RecordTokenAsSpent
bool OTToken::RecordTokenAsSpent(OTString & theCleartextToken)
{
OTString strAssetID(GetAssetID());
// ----------------------------------------------------------------------------
// Calculate the filename (a hash of the Lucre cleartext token ID)
OTIdentifier theTokenHash;
theTokenHash.CalculateDigest(theCleartextToken);
// Grab the new hash into a string (for use as a filename)
OTString strTokenHash(theTokenHash);
OTString strAssetFolder;
strAssetFolder.Format("%s.%d", strAssetID.Get(), GetSeries());
// --------------------------------------------------------------------
// See if the spent token file ALREADY EXISTS...
bool bTokenIsPresent = OTDB::Exists(OTLog::SpentFolder(), strAssetFolder.Get(), strTokenHash.Get());
// If so, we're trying to record a token that was already recorded...
if (bTokenIsPresent)
{
OTLog::vError("OTToken::RecordTokenAsSpent: Trying to record token as spent,"
" but it was already recorded: %s%s%s%s%s\n",
OTLog::SpentFolder(), OTLog::PathSeparator(), strAssetFolder.Get(),
OTLog::PathSeparator(), strTokenHash.Get());
return false;
}
// ----------------------------------------------------------------------
// FINISHED:
// We actually save the token itself into the file, which is named based
// on a hash of the Lucre data.
// The success of that operation is also now the success of this one.
OTString strToken;
SaveContract(strToken);
bool bSaved = OTDB::StorePlainString(strToken.Get(), OTLog::SpentFolder(),
strAssetFolder.Get(), strTokenHash.Get());
if (!bSaved)
{
OTLog::vError("OTToken::RecordTokenAsSpent: Error saving file: %s%s%s%s%s\n",
OTLog::SpentFolder(), OTLog::PathSeparator(), strAssetFolder.Get(),
OTLog::PathSeparator(), strTokenHash.Get());
}
return bSaved;
}
示例13: VerifyToken
// Lucre step 5: mint verifies token when it is redeemed by merchant.
// This function is called by OTToken::VerifyToken.
// That's the one you should be calling, most likely, not this one.
bool OTMint_Lucre::VerifyToken(OTPseudonym & theNotary, OTString & theCleartextToken, int64_t lDenomination)
{
bool bReturnValue = false;
// OTLog::Error("%s <bank info> <coin>\n", argv[0]);
_OT_Lucre_Dumper setDumper;
OpenSSL_BIO bioBank = BIO_new(BIO_s_mem()); // input
OpenSSL_BIO bioCoin = BIO_new(BIO_s_mem()); // input
// --- copy theCleartextToken to bioCoin so lucre can load it
BIO_puts(bioCoin, theCleartextToken.Get());
// --- The Mint private info is encrypted in m_mapPrivate[lDenomination].
// So I need to extract that first before I can use it.
OTASCIIArmor theArmor;
GetPrivate(theArmor, lDenomination);
OTEnvelope theEnvelope(theArmor);
OTString strContents; // will contain output from opening the envelope.
// Decrypt the Envelope into strContents
if (theEnvelope.Open(theNotary, strContents))
{
// copy strContents to a BIO
BIO_puts(bioBank, strContents.Get());
// ---- Now the bank and coin bios are both ready to go...
Bank bank(bioBank);
Coin coin(bioCoin);
if (bank.Verify(coin)) // Here's the boolean output: coin is verified!
{
bReturnValue = true;
// (Done): When a token is redeemed, need to store it in the spent token database.
// Right now I can verify the token, but unless I check it against a database, then
// even though the signature verifies, it doesn't stop people from redeeming the same
// token again and again and again.
//
// (done): also need to make sure issuer has double-entries for total amount outstanding.
//
// UPDATE: These are both done now. The Spent Token database is implemented in the transaction server,
// (not OTLib proper) and the same server also now keeps a cash account to match all cash withdrawals.
// (Meaning, if 10,000 clams total have been withdrawn by various users, then the server actually has
// a clam account containing 10,000 clams. As the cash comes in for redemption, the server debits it from
// this account again before sending it to its final destination. This way the server tracks total outstanding
// amount, as an additional level of security after the blind signature itself.)
}
}
return bReturnValue;
}
示例14: SetLongValue
const bool OTSettings::Set_long(const OTString & strSection, const OTString & strKey, const long & lValue, bool & out_bNewOrUpdate, const OTString & strComment)
{
if (! strSection.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strSection" ); OT_ASSERT(false); }
if (strSection.Compare("")) { OTLog::vError("%s: Error: %s is Blank!\n", __FUNCTION__, "strSection" ); OT_ASSERT(false); }
if (! strKey.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strKey" ); OT_ASSERT(false); }
if (strKey.Compare("")) { OTLog::vError("%s: Error: %s is Blank!\n", __FUNCTION__, "strKey" ); OT_ASSERT(false); }
OTString strValue; strValue.Format("%ld",lValue);
const char * const szComment = (strComment.Exists() && !strComment.Compare("")) ? strComment.Get() : NULL;
OTString strOldValue, strNewValue;
bool bOldKeyExist, bNewKeyExist;
// Check if Old Key exists.
if(! Check_str(strSection,strKey,strOldValue,bOldKeyExist)) return false;
if (bOldKeyExist)
{
if (strValue.Compare(strOldValue))
{
out_bNewOrUpdate = false;
return true;
}
}
// Log to Output Setting Change
if (! LogChange_str(strSection,strKey,strValue)) return false;
// Set New Value
SI_Error rc = p_iniSimple -> SetLongValue(strSection.Get(),strKey.Get(),lValue,szComment,false,true);
if (0 > rc) return false;
// Check if the new value is the same as intended.
if (! Check_str(strSection,strKey,strNewValue,bNewKeyExist)) return false;
if (bNewKeyExist)
{
if (strValue.Compare(strNewValue))
{
// Success
out_bNewOrUpdate = true;
return true;
}
}
// If we get here, error!
OT_ASSERT(false);
return false;
}
示例15: Gnome_StoreSecret
// static
bool OTKeyring::Gnome_StoreSecret(const OTString& strUser,
const OTPassword& thePassword,
const std::string& str_display)
{
OT_ASSERT(strUser.Exists());
OT_ASSERT(thePassword.getMemorySize() > 0);
OTData theData(thePassword.getMemory(), thePassword.getMemorySize());
OTASCIIArmor ascData(theData);
theData.zeroMemory(); // security reasons.
OTString strOutput;
const bool bSuccess =
ascData.Exists() &&
ascData.WriteArmoredString(strOutput, "DERIVED KEY"); // There's no
// default, to
// force you to
// enter the right
// string.
ascData.zeroMemory();
GnomeKeyringResult theResult = GNOME_KEYRING_RESULT_IO_ERROR;
if (bSuccess && strOutput.Exists()) {
theResult = gnome_keyring_store_password_sync(
GNOME_KEYRING_NETWORK_PASSWORD,
GNOME_KEYRING_DEFAULT, // GNOME_KEYRING_SESSION,
str_display.c_str(), strOutput.Get(), "user", strUser.Get(),
"protocol", "opentxs", // todo: hardcoding.
nullptr);
strOutput.zeroMemory();
bool bResult = false;
if (theResult == GNOME_KEYRING_RESULT_OK)
bResult = true;
else
otErr << "OTKeyring::Gnome_StoreSecret: "
<< "Failure in gnome_keyring_store_password_sync: "
<< gnome_keyring_result_to_message(theResult) << '\n';
return bResult;
}
otOut << "OTKeyring::Gnome_StoreSecret: No secret to store.\n";
return false;
}