本文整理汇总了C++中Name::toUri方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::toUri方法的具体用法?C++ Name::toUri怎么用?C++ Name::toUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::toUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConstBufferPtr
Block
SecTpmMemory::signInTpm(const uint8_t *data, size_t dataLength,
const Name& keyName,
DigestAlgorithm digestAlgorithm)
{
if (digestAlgorithm != DIGEST_ALGORITHM_SHA256)
return ConstBufferPtr();
// Find the private key and sign.
PrivateKeyStore::iterator privateKey = privateKeyStore_.find(keyName.toUri());
if (privateKey == privateKeyStore_.end())
throw Error(string("MemoryPrivateKeyStorage: Cannot find private key ") + keyName.toUri());
uint8_t digest[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, data, dataLength);
SHA256_Final(digest, &sha256);
BufferPtr signatureBuffer = ptr_lib::make_shared<Buffer>();
signatureBuffer->resize(RSA_size(privateKey->second->getPrivateKey()));
unsigned int signatureBitsLength;
if (!RSA_sign(NID_sha256, digest, sizeof(digest),
signatureBuffer->buf(),
&signatureBitsLength,
privateKey->second->getPrivateKey()))
{
throw Error("Error in RSA_sign");
}
return Block(Tlv::SignatureValue, signatureBuffer);
}
示例2: QString
void
ChatDialog::updateLabels(Name newChatPrefix)
{
// Reset DigestTree
m_scene->clearAll();
m_scene->plot("Empty");
// Display chatroom name
QString chatroomName = QString("Chatroom: %1").arg(QString::fromStdString(m_chatroomName));
ui->infoLabel->setStyleSheet("QLabel {color: #630; font-size: 16px; font: bold \"Verdana\";}");
ui->infoLabel->setText(chatroomName);
// Display chat message prefix
QString chatPrefix;
if (PRIVATE_PREFIX.isPrefixOf(newChatPrefix)) {
chatPrefix =
QString("<Warning: no connection to hub or hub does not support prefix autoconfig.>\n"
"<Prefix = %1>")
.arg(QString::fromStdString(newChatPrefix.toUri()));
ui->prefixLabel->setStyleSheet(
"QLabel {color: red; font-size: 12px; font: bold \"Verdana\";}");
}
else {
chatPrefix = QString("<Prefix = %1>")
.arg(QString::fromStdString(newChatPrefix.toUri()));
ui->prefixLabel->setStyleSheet(
"QLabel {color: Green; font-size: 12px; font: bold \"Verdana\";}");
}
ui->prefixLabel->setText(chatPrefix);
fitView();
}
示例3: producerSatisfiedAuthRequest
void producerSatisfiedAuthRequest( const Name& producer_name,
const Name& request_name,
const NdnParameterSet& credentials )
{
if( logging_enabled )
{
lock.lock();
log_file << "Producer:SatisfiedAuth" << endl
<< "{" << endl
<< " time = " << time::system_clock::now() << endl
<< " producer = " << producer_name.toUri() << endl
<< " request = " << request_name.toUri() << endl
<< " username = " <<
( ( credentials.hasParameter( "username" ) )
? credentials.getParameter( "username" )
: "none" )
<< endl
<< " password = " <<
( ( credentials.hasParameter( "password" ) )
? credentials.getParameter( "password" )
: "none" )
<< endl
<< "}" << endl;
lock.unlock();
}
}
示例4: idString
Name
IdentityCertificate::certificateNameToPublicKeyName(const Name& certificateName)
{
int i = certificateName.size() - 1;
string idString("ID-CERT");
bool foundIdString = false;
for (; i >= 0; i--) {
if (certificateName.get(i).toEscapedString() == idString)
{
foundIdString = true;
break;
}
}
if(!foundIdString)
throw Error("Incorrect identity certificate name " + certificateName.toUri());
Name tmpName = certificateName.getSubName(0, i);
string keyString("KEY");
bool foundKeyString = false;
for (i = 0; i < tmpName.size(); i++) {
if (tmpName.get(i).toEscapedString() == keyString)
{
foundKeyString = true;
break;
}
}
if(!foundKeyString)
throw Error("Incorrect identity certificate name " + certificateName.toUri());
return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
}
示例5: Error
ptr_lib::shared_ptr<PublicKey>
SecTpmMemory::getPublicKeyFromTpm(const Name& keyName)
{
PublicKeyStore::iterator publicKey = publicKeyStore_.find(keyName.toUri());
if (publicKey == publicKeyStore_.end())
throw Error(string("MemoryPrivateKeyStorage: Cannot find public key ") + keyName.toUri());
return publicKey->second;
}
示例6:
void
SecTpmMemory::setKeyPairForKeyName(const Name& keyName,
uint8_t *publicKeyDer, size_t publicKeyDerLength,
uint8_t *privateKeyDer, size_t privateKeyDerLength)
{
publicKeyStore_[keyName.toUri()] = ptr_lib::make_shared<PublicKey>(publicKeyDer, publicKeyDerLength);
privateKeyStore_[keyName.toUri()] = ptr_lib::make_shared<RsaPrivateKey>(privateKeyDer, privateKeyDerLength);
}
示例7: Error
shared_ptr<IdentityCertificate>
SecPublicInfoMemory::getCertificate(const Name& certificateName)
{
CertificateStore::iterator record = m_certificateStore.find(certificateName.toUri());
if (record == m_certificateStore.end())
throw Error("SecPublicInfoMemory::getCertificate " + certificateName.toUri());
return record->second;
}
示例8: if
bool
SecTpmMemory::doesKeyExistInTpm(const Name& keyName, KeyClass keyClass)
{
if (keyClass == KEY_CLASS_PUBLIC)
return publicKeyStore_.find(keyName.toUri()) != publicKeyStore_.end();
else if (keyClass == KEY_CLASS_PRIVATE)
return privateKeyStore_.find(keyName.toUri()) != privateKeyStore_.end();
else
// KEY_CLASS_SYMMETRIC not implemented yet.
return false;
}
示例9: publicKeyPath
void
SecTpmFile::deleteKeyPairInTpm(const Name& keyName)
{
boost::filesystem::path publicKeyPath(m_impl->transformName(keyName.toUri(), ".pub"));
boost::filesystem::path privateKeyPath(m_impl->transformName(keyName.toUri(), ".pri"));
if (boost::filesystem::exists(publicKeyPath))
boost::filesystem::remove(publicKeyPath);
if (boost::filesystem::exists(privateKeyPath))
boost::filesystem::remove(privateKeyPath);
}
示例10: Name
shared_ptr<Data> StorageEngineImpl::read(const Interest &interest)
{
shared_ptr<Data> data;
#if HAVE_PERSISTENT_STORAGE
bool canBePrefix = interest.getCanBePrefix();
if (canBePrefix)
{
// extract by prefix match
Name prefix = interest.getName(), keyName;
auto it = db_->NewIterator(db_namespace::ReadOptions());
std::string key = "";
bool checkMaxSuffixComponents = interest.getMaxSuffixComponents() != -1;
bool checkMinSuffixComponents = interest.getMinSuffixComponents() != -1;
for (it->Seek(prefix.toUri());
it->Valid() && it->key().starts_with(prefix.toUri());
it->Next())
{
if (checkMaxSuffixComponents || checkMinSuffixComponents)
{
keyName = Name(it->key().ToString());
int nSuffixComponents = keyName.size() - prefix.size();
bool passCheck = false;
if (checkMaxSuffixComponents &&
nSuffixComponents <= interest.getMaxSuffixComponents())
passCheck = true;
if (checkMinSuffixComponents &&
nSuffixComponents >= interest.getMinSuffixComponents())
passCheck = true;
if (passCheck)
key = it->key().ToString();
}
else
key = it->key().ToString();
}
if (key != "")
data = get(Name(key));
delete it;
}
else
data = get(interest.getName());
#endif
return data;
}
示例11: producerSatisfiedRequest
void producerSatisfiedRequest( const Name& producer_name,
const Name& request_name )
{
if( logging_enabled )
{
lock.lock();
log_file << "Producer:Satisfied" << endl
<< "{" << endl
<< " time = " << time::system_clock::now() << endl
<< " producer = " << producer_name.toUri() << endl
<< " request = " << request_name.toUri() << endl
<< "}" << endl;
lock.unlock();
}
}
示例12:
bool
SecTpmFile::doesKeyExistInTpm(const Name& keyName, KeyClass keyClass)
{
string keyURI = keyName.toUri();
if (keyClass == KEY_CLASS_PUBLIC)
{
if (boost::filesystem::exists(m_impl->transformName(keyURI, ".pub")))
return true;
else
return false;
}
if (keyClass == KEY_CLASS_PRIVATE)
{
if (boost::filesystem::exists(m_impl->transformName(keyURI, ".pri")))
return true;
else
return false;
}
if (keyClass == KEY_CLASS_SYMMETRIC)
{
if (boost::filesystem::exists(m_impl->transformName(keyURI, ".key")))
return true;
else
return false;
}
return false;
}
示例13: namespace
void
MulticastDiscovery::onSetStrategyFailure(const std::string& error)
{
m_nextStageOnFailure("Failed to set multicast strategy for " +
LOCALHOP_HUB_DISCOVERY_PREFIX.toUri() + " namespace (" + error + "). "
"Skipping multicast discovery stage");
}
示例14: remove
void
FilePrivateKeyStorage::deleteKeyPair(const Name& keyName)
{
string keyUri = keyName.toUri();
remove(nameTransform(keyUri, ".pub").c_str());
remove(nameTransform(keyUri, ".pri").c_str());
}
示例15: Error
void
SecPublicInfoMemory::addIdentity(const Name& identityName)
{
string identityUri = identityName.toUri();
if (find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end())
throw Error("Identity already exists: " + identityUri);
identityStore_.push_back(identityUri);
}