NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
identity-impl.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 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_IMPL_IDENTITY_IMPL_HPP
23 #define NDN_CXX_SECURITY_PIB_IMPL_IDENTITY_IMPL_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 namespace pib {
30 
31 class PibImpl;
32 
33 namespace detail {
34 
43 class IdentityImpl : noncopyable
44 {
45 public:
54  IdentityImpl(const Name& identityName, shared_ptr<PibImpl> pibImpl, bool needInit = false);
55 
59  const Name&
60  getName() const
61  {
62  return m_name;
63  }
64 
74  Key
75  addKey(span<const uint8_t> key, const Name& keyName);
76 
81  void
82  removeKey(const Name& keyName);
83 
90  Key
91  getKey(const Name& keyName) const;
92 
96  const KeyContainer&
97  getKeys() const;
98 
105  const Key&
106  setDefaultKey(const Name& keyName);
107 
114  const Key&
115  setDefaultKey(span<const uint8_t> key, const Name& keyName);
116 
121  const Key&
122  getDefaultKey() const;
123 
124 private:
125  Name m_name;
126 
127  shared_ptr<PibImpl> m_pib;
128 
129  KeyContainer m_keys;
130  mutable bool m_isDefaultKeyLoaded;
131  mutable Key m_defaultKey;
132 };
133 
134 } // namespace detail
135 } // namespace pib
136 } // namespace security
137 } // namespace ndn
138 
139 #endif // NDN_CXX_SECURITY_PIB_IMPL_IDENTITY_IMPL_HPP
Backend instance of Identity.
Copyright (c) 2011-2015 Regents of the University of California.
const Key & setDefaultKey(const Name &keyName)
Set the key with id keyName.
const KeyContainer & getKeys() const
Get all keys for this Identity.
Container of keys of an identity.
A frontend handle of a key instance.
Definition: key.hpp:49
IdentityImpl(const Name &identityName, shared_ptr< PibImpl > pibImpl, bool needInit=false)
Create an Identity with identityName.
Represents an absolute name.
Definition: name.hpp:41
Key addKey(span< const uint8_t > key, const Name &keyName)
Add key with name keyName (in PKCS #8 format).
void removeKey(const Name &keyName)
Remove a key with keyName.
const Name & getName() const
Get the name of the identity.
Key getKey(const Name &keyName) const
Get a key with id keyName.
const Key & getDefaultKey() const
Get the default key for this Identity.