blob: d5d4664d88d4b9751dbdd0a176440542be4e96ef [file] [log] [blame]
Yingdi Yu233a9722014-03-07 15:47:09 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
Yingdi Yu0b0a7362014-08-05 16:31:30 -07008#include "common.hpp"
9#include <ndn-cxx/security/key-chain.hpp>
10#include <ndn-cxx/face.hpp>
Yingdi Yu233a9722014-03-07 15:47:09 -080011
12using namespace ndn;
13
Yingdi Yu0b0a7362014-08-05 16:31:30 -070014int
Yingdi Yu233a9722014-03-07 15:47:09 -080015main()
16{
17 Name root("/ndn");
18
Yingdi Yu0b0a7362014-08-05 16:31:30 -070019 KeyChain keyChain("sqlite3", "file");
Yingdi Yu233a9722014-03-07 15:47:09 -080020
21 if(!keyChain.doesIdentityExist(root))
22 return 1;
23
Yingdi Yu0b0a7362014-08-05 16:31:30 -070024 Face face;
Yingdi Yu233a9722014-03-07 15:47:09 -080025
26 Name name("/local/ndn/prefix");
27 name.appendVersion().appendSegment(0);
28
Yingdi Yu6c3c5962014-09-09 16:52:38 -070029 shared_ptr<Data> data = make_shared<Data>(name);
Yingdi Yu233a9722014-03-07 15:47:09 -080030 std::string prefix("/ndn/test");
Yingdi Yu6c3c5962014-09-09 16:52:38 -070031 data->setContent(reinterpret_cast<const uint8_t*>(prefix.c_str()), prefix.size());
32 keyChain.signByIdentity(*data, root);
Yingdi Yu233a9722014-03-07 15:47:09 -080033
Yingdi Yu6c3c5962014-09-09 16:52:38 -070034 face.put(*data);
Yingdi Yu0b0a7362014-08-05 16:31:30 -070035
36 face.getIoService().run();
Yingdi Yu233a9722014-03-07 15:47:09 -080037}