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-2022 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_CXX_SECURITY_PIB_IDENTITY_HPP
23 #define NDN_CXX_SECURITY_PIB_IDENTITY_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 
30 inline namespace v2 {
31 class KeyChain;
32 } // inline namespace v2
33 
34 namespace pib {
35 
36 namespace detail {
37 class IdentityImpl;
38 } // namespace detail
39 
47 class Identity
48 {
49 public:
68  Identity();
69 
75  explicit
76  Identity(weak_ptr<detail::IdentityImpl> impl);
77 
81  const Name&
82  getName() const;
83 
89  Key
90  getKey(const Name& keyName) const;
91 
95  const KeyContainer&
96  getKeys() const;
97 
102  const Key&
103  getDefaultKey() const;
104 
108  explicit
109  operator bool() const;
110 
111 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
119  Key
120  addKey(span<const uint8_t> key, const Name& keyName) const;
121 
126  void
127  removeKey(const Name& keyName) const;
128 
135  const Key&
136  setDefaultKey(const Name& keyName) const;
137 
144  const Key&
145  setDefaultKey(span<const uint8_t> key, const Name& keyName) const;
146 
147 private:
153  shared_ptr<detail::IdentityImpl>
154  lock() const;
155 
156 private:
157  weak_ptr<detail::IdentityImpl> m_impl;
158 
159  friend KeyChain;
160  friend bool operator!=(const Identity&, const Identity&);
161 };
162 
163 bool
164 operator!=(const Identity& lhs, const Identity& rhs);
165 
166 inline bool
167 operator==(const Identity& lhs, const Identity& rhs)
168 {
169  return !(lhs != rhs);
170 }
171 
172 std::ostream&
173 operator<<(std::ostream& os, const Identity& id);
174 
175 } // namespace pib
176 
177 using pib::Identity;
178 
179 } // namespace security
180 } // namespace ndn
181 
182 #endif // NDN_CXX_SECURITY_PIB_IDENTITY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
ndn security KeyChain
Definition: key-chain.cpp:70
bool operator!=(const Data &lhs, const Data &rhs)
Definition: data.hpp:352
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
Container of keys of an identity.
A frontend handle of a key instance.
Definition: key.hpp:49
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Represents an absolute name.
Definition: name.hpp:41
A frontend handle of an Identity.
Definition: identity.hpp:47
bool operator==(const Data &lhs, const Data &rhs)
Definition: data.cpp:366