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


C++ KeyChain::getDefaultCertificateName方法代码示例

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


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

示例1: main

int main(int argc, char** argv)
{

    std::string logfile = createLogDir("./logs");
    GLogger glog( argv[0], logfile.c_str() );
    std::cout << "Log to path: " << logfile << std::endl;

    try {
        boost::asio::io_service ioService;

        ptr_lib::shared_ptr<ThreadsafeFace> face;
        face.reset(new ThreadsafeFace (ioService, "localhost"));

        // Use the system default key chain and certificate name to sign commands.
        KeyChain keyChain;
        face->setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());

        // Also use the default certificate name to sign data packets.
        Publisher publisher(ioService, face, keyChain, keyChain.getDefaultCertificateName());

        if( !publisher.init() )
        {
            cout << "Publisher init fail" << endl;
            return 0;
        }
        else
        {
            std::thread *captureThread =
                    new std::thread(bind(&Publisher::start,&publisher));

            captureThread->detach();

            LOG(INFO) << "ioservice start" << endl;
            boost::asio::io_service::work work(ioService);
            ioService.run();
            LOG(INFO) << "ioservice started" << endl;
        }
    }
    catch (std::exception& e) {
        cout << "exception: " << e.what() << endl;
    }
    return 0;
}
开发者ID:xyhGit,项目名称:MTNDN,代码行数:43,代码来源:main.cpp

示例2: main

int main(int argc, char** argv)
{
  try {
    Name prefix("/nfd/edu/ucla/remap/test");
    // Route to aleph.ndn.ucla.edu.  Have to use the canonical name with
    // an IP address and port.
    string uri = "udp4://128.97.98.7:6363";

    // The default Face connects to the local NFD.
    Face face;

    // Use the system default key chain and certificate name to sign commands.
    KeyChain keyChain;
    face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());

    // Create the /localhost/nfd/faces/query command interest, including the
    // FaceQueryFilter. Construct the FaceQueryFilter using the structure in
    // face-query-filter.pb.h which was produced by protoc.
    ndn_message::FaceQueryFilterMessage message;
    ndn_message::FaceQueryFilterMessage_FaceQueryFilter* filter =
      message.add_face_query_filter();
    filter->set_uri(uri);
    Blob encodedFilter = ProtobufTlv::encode(message);

    Interest interest(Name("/localhost/nfd/faces/query"));
    interest.getName().append(encodedFilter);

    bool enabled = true;
    SegmentFetcher::fetch
      (face, interest, SegmentFetcher::DontVerifySegment,
       bind(&processFaceStatus, _1, prefix, uri, &face, &enabled),
       bind(&onError, _1, _2, &enabled));

    // Loop calling processEvents until a callback sets enabled = false.
    while (enabled) {
      face.processEvents();
      // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
      usleep(10000);
    }
  } catch (std::exception& e) {
    cout << "exception: " << e.what() << endl;
  }
  return 0;
}
开发者ID:jiachenwang,项目名称:ndncon_Ubuntu_NDN_Hackathon2015,代码行数:44,代码来源:test-register-route.cpp

示例3: description

int
ndnsec_op_tool(int argc, char** argv)
{
  using namespace ndn;
  namespace po = boost::program_options;

  std::string command;

  po::options_description description("General options");
  description.add_options()
    ("help,h", "produce this help message")
    ("command", po::value<std::string>(&command), "command")
    ;

  po::positional_options_description p;
  p.add("command", 1);

  po::variables_map vm;
  try
    {
      po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(),
                vm);
      po::notify(vm);
    }
  catch (const std::exception& e)
    {
      std::cerr << "ERROR: " << e.what() << std::endl;
      std::cerr << description << std::endl;
      return -1;
    }

  if (vm.count("help") != 0)
    {
      std::cerr << description << std::endl;
      return 0;
    }

  if (vm.count("command") == 0)
    {
      std::cerr << "command must be specified" << std::endl;
      std::cerr << description << std::endl;
      return 1;
    }

  if (command == "sign") // the content to be signed from stdin
    {
      KeyChain keyChain;

      Buffer dataToSign((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>());

      Block value = keyChain.sign(dataToSign.buf(), dataToSign.size(),
                                  security::SigningInfo(security::SigningInfo::SIGNER_TYPE_CERT,
                                                        keyChain.getDefaultCertificateName()));

      if (value.value_size() == 0)
        {
          std::cerr << "Error signing with default key" << std::endl;
          return -1;
        }

      std::cout.write(reinterpret_cast<const char*>(value.wire()), value.size());
    }

  return 0;
}
开发者ID:AaronTien,项目名称:ndn-cxx,代码行数:65,代码来源:op-tool.hpp


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