28 Pib::Pib(
const std::string scheme,
const std::string& location, shared_ptr<PibImpl> impl)
30 , m_location(location)
31 , m_hasDefaultIdentity(false)
32 , m_needRefreshIdentities(true)
44 return m_scheme +
":" + m_location;
50 m_impl->setTpmLocator(tpmLocator);
56 return m_impl->getTpmLocator();
60 Pib::addIdentity(
const Name& identity)
62 if (!m_needRefreshIdentities && m_identities.find(identity) == m_identities.end()) {
65 m_needRefreshIdentities =
true;
67 return Identity(identity, m_impl,
true);
73 if (m_hasDefaultIdentity && m_defaultIdentity.getName() == identity)
74 m_hasDefaultIdentity =
false;
76 m_impl->removeIdentity(identity);
77 m_needRefreshIdentities =
true;
83 return Identity(identity, m_impl,
false);
89 if (m_needRefreshIdentities) {
91 m_needRefreshIdentities =
false;
101 m_hasDefaultIdentity =
true;
103 m_impl->setDefaultIdentity(identityName);
104 return m_defaultIdentity;
110 if (!m_hasDefaultIdentity) {
111 m_defaultIdentity = std::move(
Identity(m_impl->getDefaultIdentity(), m_impl,
false));
112 m_hasDefaultIdentity =
true;
115 return m_defaultIdentity;
Copyright (c) 2011-2015 Regents of the University of California.
virtual void addIdentity(const Name &identity) final
Add an identity.
Identity getIdentity(const Name &identityName) const
Get an identity with name identityName.
void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
A handler to search or enumerate identities in PIB.
std::string getPibLocator() const
Get PIB Locator.
void removeIdentity(const Name &identityName)
Identity & setDefaultIdentity(const Name &identityName)
Set an identity with name identityName as the default identity.
const IdentityContainer & getIdentities() const
Get all the identities.
Identity & getDefaultIdentity() const
Get the default identity.
Name abstraction to represent an absolute name.
std::string getTpmLocator() const
Get TPM Locator.