NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
identity.cpp
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
#include "
ndn-cxx/security/pib/identity.hpp
"
23
#include "
ndn-cxx/security/pib/impl/identity-impl.hpp
"
24
25
namespace
ndn
{
26
namespace
security
{
27
namespace
pib {
28
29
Identity::Identity
() =
default
;
30
31
Identity::Identity
(weak_ptr<detail::IdentityImpl> impl)
32
: m_impl(
std
::
move
(impl))
33
{
34
}
35
36
const
Name
&
37
Identity::getName
()
const
38
{
39
return
lock()->getName();
40
}
41
42
Key
43
Identity::addKey(span<const uint8_t> key,
const
Name
& keyName)
const
44
{
45
return
lock()->addKey(key, keyName);
46
}
47
48
void
49
Identity::removeKey
(
const
Name
& keyName)
const
50
{
51
lock()->removeKey(keyName);
52
}
53
54
Key
55
Identity::getKey
(
const
Name
& keyName)
const
56
{
57
return
lock()->getKey(keyName);
58
}
59
60
const
KeyContainer
&
61
Identity::getKeys
()
const
62
{
63
return
lock()->getKeys();
64
}
65
66
const
Key
&
67
Identity::setDefaultKey
(
const
Name
& keyName)
const
68
{
69
return
lock()->setDefaultKey(keyName);
70
}
71
72
const
Key
&
73
Identity::setDefaultKey
(span<const uint8_t> key,
const
Name
& keyName)
const
74
{
75
return
lock()->setDefaultKey(key, keyName);
76
}
77
78
const
Key
&
79
Identity::getDefaultKey
()
const
80
{
81
return
lock()->getDefaultKey();
82
}
83
84
Identity::operator bool()
const
85
{
86
return
!m_impl.expired();
87
}
88
89
shared_ptr<detail::IdentityImpl>
90
Identity::lock()
const
91
{
92
auto
impl = m_impl.lock();
93
94
if
(impl ==
nullptr
)
95
NDN_THROW
(std::domain_error(
"Invalid Identity instance"
));
96
97
return
impl;
98
}
99
100
bool
101
operator!=
(
const
Identity
& lhs,
const
Identity
& rhs)
102
{
103
return
lhs.m_impl.owner_before(rhs.m_impl) || rhs.m_impl.owner_before(lhs.m_impl);
104
}
105
106
std::ostream&
107
operator<<
(std::ostream& os,
const
Identity
&
id
)
108
{
109
if
(
id
) {
110
os <<
id
.getName();
111
}
112
else
{
113
os <<
"(empty)"
;
114
}
115
return
os;
116
}
117
118
}
// namespace pib
119
}
// namespace security
120
}
// namespace ndn
ndn::security::pib::operator<<
std::ostream & operator<<(std::ostream &os, const Identity &id)
Definition:
identity.cpp:107
ndn::security::pib::Identity::getKey
Key getKey(const Name &keyName) const
Get a key with id keyName.
Definition:
identity.cpp:55
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 name keyName as the default key.
Definition:
identity.cpp:67
ndn::security::pib::Identity::removeKey
void removeKey(const Name &keyName) const
Remove a key with keyName.
Definition:
identity.cpp:49
nonstd::optional_lite::std11::move
T & move(T &t)
Definition:
optional-lite.hpp:472
ndn::security::pib::Identity::Identity
Identity()
Default Constructor.
std
STL namespace.
ndn::security::pib::Identity::operator!=
friend bool operator!=(const Identity &, const Identity &)
Definition:
identity.cpp:101
NDN_THROW
#define NDN_THROW(e)
Definition:
exception.hpp:61
identity-impl.hpp
ndn::security::pib::KeyContainer
Container of keys of an identity.
Definition:
key-container.hpp:48
ndn::security::pib::Key
A frontend handle of a key instance.
Definition:
key.hpp:49
identity.hpp
ndn::Name
Represents an absolute name.
Definition:
name.hpp:41
ndn::security
Definition:
dummy-keychain.cpp:28
ndn::security::pib::Identity::getDefaultKey
const Key & getDefaultKey() const
Get the default key for this Identity.
Definition:
identity.cpp:79
ndn::security::pib::Identity::getName
const Name & getName() const
Get the name of the identity.
Definition:
identity.cpp:37
ndn::security::pib::Identity
A frontend handle of an Identity.
Definition:
identity.hpp:47
ndn::security::pib::Identity::getKeys
const KeyContainer & getKeys() const
Get all keys for this identity.
Definition:
identity.cpp:61
ndnSIM
ndn-cxx
ndn-cxx
security
pib
identity.cpp
Generated on Fri May 6 2022 12:34:12 for ndnSIM by
1.8.13