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:
63  Identity();
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
std::ostream & operator<<(std::ostream &os, const Identity &id)
Definition: identity.cpp:107
Definition: data.cpp:26
The interface of signing key management.
Definition: key-chain.hpp:46
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:162
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:43
Represents an absolute name.
Definition: name.hpp:43
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101
A frontend handle of an Identity.
Definition: identity.hpp:42