32 Pib::Pib(
const std::string& scheme,
const std::string& location, shared_ptr<PibImpl> impl)
34 , m_location(location)
35 , m_isDefaultIdentityLoaded(false)
39 BOOST_ASSERT(impl !=
nullptr);
47 return m_scheme +
":" + m_location;
53 if (tpmLocator == m_impl->getTpmLocator()) {
57 m_impl->setTpmLocator(tpmLocator);
63 std::string tpmLocator = m_impl->getTpmLocator();
64 if (tpmLocator.empty()) {
65 BOOST_THROW_EXCEPTION(
Pib::Error(
"TPM info does not exist"));
73 m_impl->clearIdentities();
74 m_impl->setTpmLocator(
"");
75 m_isDefaultIdentityLoaded =
false;
80 Pib::addIdentity(
const Name& identity)
82 BOOST_ASSERT(m_identities.isConsistent());
84 return m_identities.add(identity);
88 Pib::removeIdentity(
const Name& identity)
90 BOOST_ASSERT(m_identities.isConsistent());
92 if (m_isDefaultIdentityLoaded && m_defaultIdentity.getName() == identity) {
93 m_isDefaultIdentityLoaded =
false;
96 m_identities.remove(identity);
102 BOOST_ASSERT(m_identities.isConsistent());
104 return m_identities.get(identity);
110 BOOST_ASSERT(m_identities.isConsistent());
116 Pib::setDefaultIdentity(
const Name& identityName)
118 BOOST_ASSERT(m_identities.isConsistent());
120 m_defaultIdentity = m_identities.add(identityName);
121 m_isDefaultIdentityLoaded =
true;
122 NDN_LOG_DEBUG(
"Default identity is set to " << identityName);
124 m_impl->setDefaultIdentity(identityName);
125 return m_defaultIdentity;
131 BOOST_ASSERT(m_identities.isConsistent());
133 if (!m_isDefaultIdentityLoaded) {
134 m_defaultIdentity = m_identities.get(m_impl->getDefaultIdentity());
135 m_isDefaultIdentityLoaded =
true;
136 NDN_LOG_DEBUG(
"Default identity is " << m_defaultIdentity.getName());
139 BOOST_ASSERT(m_impl->getDefaultIdentity() == m_defaultIdentity.getName());
141 return m_defaultIdentity;
Copyright (c) 2013-2017 Regents of the University of California.
represents a semantic error
std::string getTpmLocator() const
Get TPM Locator.
std::string getPibLocator() const
Get PIB Locator.
#define NDN_LOG_DEBUG(expression)
log at DEBUG level
#define NDN_LOG_INIT(name)
declare a log module
void reset()
Reset content in PIB, including reset of the TPM locator.
void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
const IdentityContainer & getIdentities() const
Get all the identities.
Represents an absolute name.
const Identity & getDefaultIdentity() const
Get the default identity.
Container of identities of a Pib.
A frontend handle of an Identity.
Identity getIdentity(const Name &identityName) const
Get an identity with name identityName.