NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
identity.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_IDENTITY_HPP
23 #define NDN_SECURITY_IDENTITY_HPP
24 
25 #include "key-container.hpp"
26 
27 namespace ndn {
28 namespace security {
29 
30 class PibImpl;
31 class Pib;
32 class IdentityContainer;
33 
44 class Identity
45 {
46 public:
47  friend class Pib;
48  friend class IdentityContainer;
49  friend class KeyChain;
50 
51 public:
70  Identity();
71 
73  const Name&
74  getName() const;
75 
82  Key
83  getKey(const name::Component& keyId) const;
84 
86  const KeyContainer&
87  getKeys() const;
88 
94  Key&
95  getDefaultKey() const;
96 
98  operator bool() const;
99 
101  bool
102  operator!() const;
103 
104 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
105 
118  Key
119  addKey(const PublicKey& publicKey, const name::Component& keyId = EMPTY_KEY_ID);
120 
126  void
128 
136  Key&
138 
149  Key&
150  setDefaultKey(const PublicKey& publicKey, const name::Component& keyId = EMPTY_KEY_ID);
151 
161  Identity(const Name& identityName, shared_ptr<PibImpl> impl, bool needInit = false);
162 
168  void
169  validityCheck() const;
170 
171 public:
178 
179 private:
180  Name m_name;
181 
182  mutable bool m_hasDefaultKey;
183  mutable Key m_defaultKey;
184 
185  mutable bool m_needRefreshKeys;
186  mutable KeyContainer m_keys;
187 
188  shared_ptr<PibImpl> m_impl;
189 };
190 
191 } // namespace security
192 } // namespace ndn
193 
194 #endif // NDN_SECURITY_IDENTITY_HPP
Key & getDefaultKey() const
Get the default key for this Identity.
Definition: identity.cpp:133
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & keyId
Definition: identity.hpp:119
Copyright (c) 2011-2015 Regents of the University of California.
represents an identity
Definition: identity.hpp:44
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
bool operator!() const
Check if the Identity instance is invalid.
Definition: identity.cpp:151
The packet signing interface.
Definition: key-chain.hpp:48
const KeyContainer & getKeys() const
Get all the keys for this Identity.
Definition: identity.cpp:101
A handler to search or enumerate identities in PIB.
represents a key
Definition: key.hpp:45
Key & setDefaultKey(const name::Component &keyId)
Set the key with id keyId as the default key.
Definition: identity.cpp:114
A handler to search or enumerate keys of an identity.
Identity()
Default Constructor.
Definition: identity.cpp:31
void validityCheck() const
Check the validity of this instance.
Definition: identity.cpp:157
const Name & getName() const
Get the name of the identity.
Definition: identity.cpp:53
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > impl
Definition: identity.hpp:161
void removeKey(const name::Component &keyId)
Remove a key.
Definition: identity.cpp:81
Name abstraction to represent an absolute name.
Definition: name.hpp:46
static const name::Component EMPTY_KEY_ID
The default value of keyId when add a new key.
Definition: identity.hpp:177
Component holds a read-only name component value.
represents the PIB
Definition: pib.hpp:48
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > bool needInit
Definition: identity.hpp:161
Key getKey(const name::Component &keyId) const
Get a key with id keyId.
Definition: identity.cpp:93