NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_PIB_IDENTITY_HPP
23 #define NDN_SECURITY_PIB_IDENTITY_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 namespace pib {
30 
31 namespace detail {
32 class IdentityImpl;
33 } // namespace detail
34 
42 class Identity
43 {
44 public:
64 
70  explicit
71  Identity(weak_ptr<detail::IdentityImpl> impl);
72 
76  const Name&
77  getName() const;
78 
84  Key
85  getKey(const Name& keyName) const;
86 
90  const KeyContainer&
91  getKeys() const;
92 
97  const Key&
98  getDefaultKey() const;
99 
103  explicit
104  operator bool() const;
105 
106 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
114  Key
115  addKey(const uint8_t* key, size_t keyLen, const Name& keyName) const;
116 
121  void
122  removeKey(const Name& keyName) const;
123 
130  const Key&
131  setDefaultKey(const Name& keyName) const;
132 
139  const Key&
140  setDefaultKey(const uint8_t* key, size_t keyLen, const Name& keyName) const;
141 
142 private:
148  shared_ptr<detail::IdentityImpl>
149  lock() const;
150 
151 private:
152  weak_ptr<detail::IdentityImpl> m_impl;
153 
154  friend class v2::KeyChain;
155  friend bool operator!=(const Identity&, const Identity&);
156 };
157 
158 bool
159 operator!=(const Identity& lhs, const Identity& rhs);
160 
161 inline bool
162 operator==(const Identity& lhs, const Identity& rhs)
163 {
164  return !(lhs != rhs);
165 }
166 
167 std::ostream&
168 operator<<(std::ostream& os, const Identity& id);
169 
170 } // namespace pib
171 
172 using pib::Identity;
173 
174 } // namespace security
175 } // namespace ndn
176 
177 #endif // NDN_SECURITY_PIB_IDENTITY_HPP
ndn::security::pib::Identity::getName
const Name & getName() const
Get the name of the identity.
Definition: identity.cpp:37
key-container.hpp
ndn::security::pib::Identity::keyLen
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE size_t keyLen
Definition: identity.hpp:115
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::pib::Identity::removeKey
void removeKey(const Name &keyName) const
Remove a key with keyName.
Definition: identity.cpp:49
ndn::security::pib::operator!=
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101
ndn::security::v2::KeyChain
The interface of signing key management.
Definition: key-chain.hpp:47
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::security::pib::operator<<
std::ostream & operator<<(std::ostream &os, const Identity &id)
Definition: identity.cpp:107
ndn::security::pib::operator==
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:162
ndn::security::pib::Identity::Identity
Identity()
Default Constructor.
ndn::security::pib::Identity::operator!=
friend bool operator!=(const Identity &, const Identity &)
Definition: identity.cpp:101
ndn::security::pib::Identity::getKey
Key getKey(const Name &keyName) const
Get a key with id keyName.
Definition: identity.cpp:55
ndn::security::pib::Key
A frontend handle of a key instance.
Definition: key.hpp:50
ndn::security::pib::Identity
A frontend handle of an Identity.
Definition: identity.hpp:43
ndn::security::pib::Identity::getDefaultKey
const Key & getDefaultKey() const
Get the default key for this Identity.
Definition: identity.cpp:79
ndn::security::pib::KeyContainer
Container of keys of an identity.
Definition: key-container.hpp:49
ndn::security::pib::Identity::getKeys
const KeyContainer & getKeys() const
Get all keys for this identity.
Definition: identity.cpp:61
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::pib::Identity::setDefaultKey
const Key & setDefaultKey(const Name &keyName) const
Set an existing key with keyName as the default key.
Definition: identity.cpp:67