NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
key-container.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_KEY_CONTAINER_HPP
23 #define NDN_SECURITY_PIB_KEY_CONTAINER_HPP
24 
25 #include "key.hpp"
26 
27 #include <set>
28 #include <unordered_map>
29 
30 namespace ndn {
31 namespace security {
32 namespace pib {
33 
34 class PibImpl;
35 
36 namespace detail {
37 class KeyImpl;
38 class IdentityImpl;
39 } // namespace detail
40 
47 class KeyContainer : noncopyable
48 {
49 public:
50  class const_iterator : public std::iterator<std::forward_iterator_tag, const Key>
51  {
52  public:
54 
55  Key
56  operator*();
57 
59  operator++();
60 
62  operator++(int);
63 
64  bool
65  operator==(const const_iterator& other);
66 
67  bool
68  operator!=(const const_iterator& other);
69 
70  private:
71  const_iterator(std::set<Name>::const_iterator it, const KeyContainer& container);
72 
73  private:
74  std::set<Name>::const_iterator m_it;
75  const KeyContainer* m_container;
76 
77  friend class KeyContainer;
78  };
79 
81 
82 public:
84  begin() const;
85 
87  end() const;
88 
90  find(const Name& keyName) const;
91 
92  size_t
93  size() const;
94 
101  Key
102  add(const uint8_t* key, size_t keyLen, const Name& keyName);
103 
108  void
109  remove(const Name& keyName);
110 
116  Key
117  get(const Name& keyName) const;
118 
124  bool
125  isConsistent() const;
126 
132  KeyContainer(const Name& identity, shared_ptr<PibImpl> pibImpl);
133 
134  const std::set<Name>&
135  getKeyNames() const
136  {
137  return m_keyNames;
138  }
139 
140  const std::unordered_map<Name, shared_ptr<detail::KeyImpl>>&
142  {
143  return m_keys;
144  }
145 
146 private:
147  Name m_identity;
148  std::set<Name> m_keyNames;
150  mutable std::unordered_map<Name, shared_ptr<detail::KeyImpl>> m_keys;
151 
152  shared_ptr<PibImpl> m_pib;
153 
154  friend class detail::IdentityImpl;
155 };
156 
157 } // namespace pib
158 
159 using pib::KeyContainer;
160 
161 } // namespace security
162 } // namespace ndn
163 
164 #endif // NDN_SECURITY_PIB_KEY_CONTAINER_HPP
Backend instance of Identity.
Copyright (c) 2011-2015 Regents of the University of California.
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:162
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
Table::const_iterator iterator
Definition: cs-internal.hpp:41
Container of keys of an identity.
const std::unordered_map< Name, shared_ptr< detail::KeyImpl > > & getLoadedKeys() const
A frontend handle of a key instance.
Definition: key.hpp:49
Represents an absolute name.
Definition: name.hpp:42
const std::set< Name > & getKeyNames() const
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101