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


C++ Name::getPrefix方法代码示例

本文整理汇总了C++中Name::getPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::getPrefix方法的具体用法?C++ Name::getPrefix怎么用?C++ Name::getPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Name的用法示例。


在下文中一共展示了Name::getPrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

inline size_t
calculateSkip(const Name& name,
              const Name& hint, const Name& zone)
{
  size_t skip = 0;

  if (!hint.empty()) {
    // These are only asserts. The caller should supply the right parameters
    skip = hint.size() + 1 + zone.size();
    BOOST_ASSERT(name.size() > skip);

    BOOST_ASSERT(name.getPrefix(hint.size()) == hint);
    BOOST_ASSERT(name.get(hint.size()) == FORWARDING_HINT_LABEL);
    BOOST_ASSERT(name.getSubName(hint.size() + 1, zone.size()) == zone);

  }
  else {
    skip = zone.size();
    BOOST_ASSERT(name.size() > skip);
    BOOST_ASSERT(name.getPrefix(zone.size()) == zone);
  }

  BOOST_ASSERT(name.get(skip) == NDNS_ITERATIVE_QUERY ||
               name.get(skip) == NDNS_CERT_QUERY);

  ++skip;
  return skip;
}
开发者ID:cawka,项目名称:ndns,代码行数:28,代码来源:ndns-label.cpp

示例2: onValidationFailed

void
ValidatorInvitation::internalCheck(const uint8_t* buf, size_t size,
                                   const Signature& signature,
                                   const Name& keyLocatorName,
                                   const Data& innerData,
                                   const OnValidated& onValidated,
                                   const OnValidationFailed& onValidationFailed)
{
  Name signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);

  TrustAnchors::const_iterator keyIt = m_trustAnchors.find(signingKeyName);
  if (keyIt == m_trustAnchors.end())
    return onValidationFailed("Cannot reach any trust anchor");

  if (!Validator::verifySignature(buf, size, signature, keyIt->second))
    return onValidationFailed("Cannot verify outer signature");

  // Temporarily disabled, we should get it back when we create a specific key for the chatroom.
  // if(!Validator::verifySignature(innerData, m_trustAnchors[signingKeyName]))
  //   return onValidationFailed("Cannot verify inner signature");

  if (!m_innerKeyRegex.match(innerData.getName()) ||
      m_innerKeyRegex.expand() != signingKeyName.getPrefix(-1))
    return onValidationFailed("Inner certificate does not comply with the rule");

  return onValidated();
}
开发者ID:bruinfish,项目名称:ChronoChat,代码行数:27,代码来源:validator-invitation.cpp

示例3:

inline void
CertificateCacheTtl::remove(const Name& certificateName)
{
  Name name = certificateName.getPrefix(-1);
  Cache::iterator it = m_cache.find(name);
  if (it != m_cache.end())
    m_cache.erase(it);
}
开发者ID:JianpengWang,项目名称:ndn-cxx,代码行数:8,代码来源:certificate-cache-ttl.hpp

示例4:

void
setNameComponent(Name& name, ssize_t index, const A& ...a)
{
  Name name2 = name.getPrefix(index);
  name2.append(name::Component(a...));
  name2.append(name.getSubName(name2.size()));
  name = name2;
}
开发者ID:eric135,项目名称:NFD,代码行数:8,代码来源:test-common.hpp

示例5: makeNack

    shared_ptr<ndn::Data>
    NdnDataManager::operator[]( shared_ptr<const ndn::Interest> interest )
    {
            Name subname = interest->getName();
            auto it = subname.end()-1;

            while( ( it->isVersion() || it->isSegment()
                     || it->isSegmentOffset() || it->isTimestamp()
                     || it->isSequenceNumber() ) && ( it-- ) != subname.begin() );

            subname = subname.getPrefix( it - subname.begin() + 1 );

            if( m_producers.find( subname ) != m_producers.end() )
            {
                // find data producer
                auto producer = m_producers[subname];

                // if access level is 0, no access needs to be provided
                if( interest->getAuthTag().getAccessLevel() == 0 )
                {
                    Coordinator::
                    producerSatisfiedRequest( interest->getName().getPrefix( 2 ),
                                                interest->getName() );
                    return producer->makeData( interest );
                }

                // generate data packet
                shared_ptr<Data> data = producer->makeData( interest );

                // check that the interest's access rights
                // satisfy the data's requirements
                if( m_auth_manager->getTagAccess( interest->getAuthTag() )
                    < data->getAccessLevel() )
                {
                    Coordinator::
                    producerDeniedRequest( interest->getName().getPrefix( 2 ),
                                           interest->getName(),
                                           "Insufficient Auth" );
                    return makeNack( *data );
                }



                // check that the data satisfies interest
                if( interest->matchesData( *data ) )
                {
                    Coordinator::
                    producerSatisfiedRequest( interest->getName().getPrefix(2),
                                               interest->getName() );
                    return data;
                }
            }
           Coordinator::producerOther( interest->getName().getPrefix( 2 ),
                                       "No data matching "
                                       + interest->getName().toUri() );
           return NULL;

    };
开发者ID:raystubbs,项目名称:NMSU-BigData-REU-NDN-Access-Control-Simulation,代码行数:58,代码来源:NdnDataManager.cpp

示例6: subjectName

shared_ptr<IdentityCertificate>
Pib::prepareCertificate(const Name& keyName, const KeyParams& keyParams,
                        const time::system_clock::TimePoint& notBefore,
                        const time::system_clock::TimePoint& notAfter,
                        const Name& signerName)
{
  // Generate mgmt key
  m_tpm->generateKeyPairInTpm(keyName, keyParams);
  shared_ptr<PublicKey> publicKey = m_tpm->getPublicKeyFromTpm(keyName);

  // Set mgmt cert
  auto certificate = make_shared<IdentityCertificate>();
  Name certName = keyName.getPrefix(-1);
  certName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
  certificate->setName(certName);
  certificate->setNotBefore(notBefore);
  certificate->setNotAfter(notAfter);
  certificate->setPublicKeyInfo(*publicKey);
  CertificateSubjectDescription subjectName(oid::ATTRIBUTE_NAME, keyName.getPrefix(-1).toUri());
  certificate->addSubjectDescription(subjectName);
  certificate->encode();


  Name signingKeyName;
  KeyLocator keyLocator;
  if (signerName == EMPTY_SIGNER_NAME) {
    // Self-sign mgmt cert
    keyLocator = KeyLocator(certificate->getName().getPrefix(-1));
    signingKeyName = keyName;
  }
  else {
    keyLocator = KeyLocator(signerName.getPrefix(-1));
    signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(signerName);
  }

  SignatureSha256WithRsa signature(keyLocator);
  certificate->setSignature(signature);
  EncodingBuffer encoder;
  certificate->wireEncode(encoder, true);
  Block signatureValue = m_tpm->signInTpm(encoder.buf(), encoder.size(),
                                          signingKeyName, DIGEST_ALGORITHM_SHA256);
  certificate->wireEncode(encoder, signatureValue);

  return certificate;
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:45,代码来源:pib.cpp

示例7: addIdentity

void
SecPublicInfoMemory::addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKey)
{
  Name identityName = keyName.getPrefix(-1);

  addIdentity(identityName);

  m_keyStore[keyName.toUri()] = make_shared<KeyRecord>(keyType, publicKey);
}
开发者ID:PatrickGuo,项目名称:ndn-cxx-master,代码行数:9,代码来源:sec-public-info-memory.cpp

示例8: PartialName

Strategy::ParsedInstanceName
Strategy::parseInstanceName(const Name& input)
{
  for (ssize_t i = input.size() - 1; i > 0; --i) {
    if (input[i].isVersion()) {
      return {input.getPrefix(i + 1), input[i].toVersion(), input.getSubName(i + 1)};
    }
  }
  return {input, nullopt, PartialName()};
}
开发者ID:cawka,项目名称:NFD,代码行数:10,代码来源:strategy.cpp

示例9: addCertificate

inline void
SecPublicInfo::addCertificateAsSystemDefault(const IdentityCertificate& certificate)
{
  addCertificate(certificate);
  Name certName = certificate.getName();
  Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certName);
  setDefaultIdentityInternal(keyName.getPrefix(-1));
  setDefaultKeyNameForIdentityInternal(keyName);
  setDefaultCertificateNameForKeyInternal(certName);
  refreshDefaultCertificate();
}
开发者ID:JianpengWang,项目名称:ndn-cxx,代码行数:11,代码来源:sec-public-info.hpp

示例10: return

shared_ptr<RibEntry>
Rib::findParent(const Name& prefix) const
{
  for (int i = prefix.size() - 1; i >= 0; i--) {
    RibTable::const_iterator it = m_rib.find(prefix.getPrefix(i));

    if (it != m_rib.end()) {
      return (it->second);
    }
  }

  return shared_ptr<RibEntry>();
}
开发者ID:named-data-ndnSIM,项目名称:NFD,代码行数:13,代码来源:rib.cpp

示例11: if

ptr_lib::shared_ptr<Signature>
IdentityManager::makeSignatureByCertificate
  (const Name& certificateName, DigestAlgorithm& digestAlgorithm)
{
  Name keyName = IdentityCertificate::certificateNameToPublicKeyName
    (certificateName);
  ptr_lib::shared_ptr<PublicKey> publicKey = privateKeyStorage_->getPublicKey
    (keyName);
  KeyType keyType = publicKey->getKeyType();

  if (keyType == KEY_TYPE_RSA) {
    ptr_lib::shared_ptr<Sha256WithRsaSignature> signature
      (new Sha256WithRsaSignature());
    digestAlgorithm = DIGEST_ALGORITHM_SHA256;

    signature->getKeyLocator().setType(ndn_KeyLocatorType_KEYNAME);
    signature->getKeyLocator().setKeyName(certificateName.getPrefix(-1));
    // Ignore witness and leave the digestAlgorithm as the default.
    signature->getPublisherPublicKeyDigest().setPublisherPublicKeyDigest
      (publicKey->getDigest());

    return signature;
  }
  else if (keyType == KEY_TYPE_ECDSA) {
    ptr_lib::shared_ptr<Sha256WithEcdsaSignature> signature
      (new Sha256WithEcdsaSignature());
    digestAlgorithm = DIGEST_ALGORITHM_SHA256;

    signature->getKeyLocator().setType(ndn_KeyLocatorType_KEYNAME);
    signature->getKeyLocator().setKeyName(certificateName.getPrefix(-1));

    return signature;
  }
  else
    throw SecurityException("Key type is not recognized");
}
开发者ID:,项目名称:,代码行数:36,代码来源:

示例12:

shared_ptr<const Data>
ResponseCache::find(const Name& dataName, bool hasVersion) const
{
  if (!hasVersion) {
    Storage::const_iterator it = m_storage.find(dataName);
    if (it != m_storage.end())
      return it->second;
    else
      return shared_ptr<const Data>();
  }
  else {
    Storage::const_iterator it = m_storage.find(dataName.getPrefix(-1));
    if (it != m_storage.end() && it->second->getName() == dataName)
      return it->second;
    else
      return shared_ptr<const Data>();
  }
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:18,代码来源:response-cache.cpp

示例13: Error

uint64_t
RepoEnumerator::enumerate(bool showImplicitDigest)
{
  sqlite3_stmt* m_stmt = 0;
  int rc = SQLITE_DONE;
  string sql = string("SELECT id, name, keylocatorHash FROM NDN_REPO;");
  rc = sqlite3_prepare_v2(m_db, sql.c_str(), -1, &m_stmt, 0);
  if (rc != SQLITE_OK)
    throw Error("Initiation Read Entries from Database Prepare error");
  uint64_t entryNumber = 0;
  while (true) {
    rc = sqlite3_step(m_stmt);
    if (rc == SQLITE_ROW) {
      Name name;
      name.wireDecode(Block(sqlite3_column_blob(m_stmt, 1),
                            sqlite3_column_bytes(m_stmt, 1)));
      try {
        if (showImplicitDigest) {
          std::cout << name << std::endl;
        }
        else {
          std::cout << name.getPrefix(-1) << std::endl;
        }
      }
      catch (...){
        sqlite3_finalize(m_stmt);
        throw;
      }
      entryNumber++;
    }
    else if (rc == SQLITE_DONE) {
      sqlite3_finalize(m_stmt);
      break;
    }
    else {
      sqlite3_finalize(m_stmt);
      throw Error("Initiation Read Entries error");
    }
  }
  return entryNumber;
}
开发者ID:chenatu,项目名称:repo-service,代码行数:41,代码来源:repo-ng-ls.cpp

示例14: fail

void
PipelineInterests::runWithExcludedSegment(const Data& data, DataCallback onData,
                                          FailureCallback onFailure)
{
  BOOST_ASSERT(onData != nullptr);

  // record the start time of running pipeline
  m_startTime = time::steady_clock::now();

  m_onData = std::move(onData);
  m_onFailure = std::move(onFailure);
  m_numOfSegmentReceived++; // count the excluded segment

  Name dataName = data.getName();
  m_prefix = dataName.getPrefix(-1);
  m_excludeSegmentNo = dataName[-1].toSegment();

  if (!data.getFinalBlockId().empty()) {
    m_hasFinalBlockId = true;
    m_lastSegmentNo = data.getFinalBlockId().toSegment();
  }
  else { // Name must contain a final block ID so that consumer knows when download finishes
    fail("Name of Data packet: " + data.getName().toUri() +
         " must a final block ID!");
  }

  // schedule the event to check retransmission timer.
  m_eventCheckRto = m_scheduler.scheduleEvent(time::milliseconds(m_options.rtoCheckInterval),
                                              bind(&PipelineInterests::checkRto, this));

  if (m_options.keepStats) {
    // schedule the event to keep track the history of cwnd size
    m_eventRecordCwnd =
      m_scheduler.scheduleEvent(time::milliseconds(m_options.cwndRecordInterval),
                                bind(&PipelineInterests::recordCwnd, this));
  }

  sendFirstInterest();
}
开发者ID:imsure,项目名称:ndnchunks_with_congestion_control,代码行数:39,代码来源:pipeline-interests.cpp

示例15: SecurityException

ptr_lib::shared_ptr<IdentityCertificate>
IdentityManager::selfSign(const Name& keyName)
{
  ptr_lib::shared_ptr<IdentityCertificate> certificate(new IdentityCertificate());

  Blob keyBlob = identityStorage_->getKey(keyName);
  ptr_lib::shared_ptr<PublicKey> publicKey(new PublicKey(keyBlob));

#if NDN_CPP_HAVE_GMTIME_SUPPORT
  time_t nowSeconds = time(NULL);
  struct tm current = *gmtime(&nowSeconds);
  current.tm_hour = 0;
  current.tm_min  = 0;
  current.tm_sec  = 0;
  MillisecondsSince1970 notBefore = timegm(&current) * 1000.0;
  current.tm_year = current.tm_year + 2;
  MillisecondsSince1970 notAfter = timegm(&current) * 1000.0;

  certificate->setNotBefore(notBefore);
  certificate->setNotAfter(notAfter);
#else
  // Don't really expect this to happen.
  throw SecurityException("selfSign: Can't set certificate validity because time functions are not supported by the standard library.");
#endif

  Name certificateName = keyName.getPrefix(-1).append("KEY").append
    (keyName.get(-1)).append("ID-CERT").append
    (Name::Component::fromNumber((uint64_t)ndn_getNowMilliseconds()));
  certificate->setName(certificateName);

  certificate->setPublicKeyInfo(*publicKey);
  certificate->addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
  certificate->encode();

  signByCertificate(*certificate, certificate->getName());

  return certificate;
}
开发者ID:,项目名称:,代码行数:38,代码来源:


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