当前位置: 首页>>代码示例>>C++>>正文


C++ OTASCIIArmor::Exists方法代码示例

本文整理汇总了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);
}
开发者ID:kazcw,项目名称:Open-Transactions,代码行数:9,代码来源:OTString.cpp

示例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);
}
开发者ID:germc,项目名称:Open-Transactions,代码行数:9,代码来源:OTString.cpp

示例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);
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:11,代码来源:String.cpp

示例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);
}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:11,代码来源:OTCachedKey.cpp

示例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;
}
开发者ID:piotreksz,项目名称:Open-Transactions,代码行数:53,代码来源:OTPurse.cpp

示例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);
}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:23,代码来源:OTCachedKey.cpp

示例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;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:64,代码来源:OTKeyring.cpp

示例8:

OTData::OTData(const OTASCIIArmor &theSource) : m_pData(NULL), m_lPosition(0), m_lSize(0)
{	
	if (theSource.Exists())
		theSource.GetData(*this); // ***********
}
开发者ID:BugRogers101,项目名称:Open-Transactions,代码行数:5,代码来源:OTData.cpp

示例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(
//.........这里部分代码省略.........
开发者ID:bitcredit-currency,项目名称:opentxs,代码行数:101,代码来源:MainFile.cpp

示例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;
}
开发者ID:batouzo,项目名称:Open-Transactions,代码行数:101,代码来源:OTToken.cpp

示例11:

OTData::OTData(const OTASCIIArmor& source)
{
    if (source.Exists()) {
        source.GetData(*this);
    }
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:6,代码来源:OTData.cpp


注:本文中的OTASCIIArmor::Exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。