29 : m_hasDefaultIdentity(false)
36 BOOST_THROW_EXCEPTION(
Error(
"PibMemory does not need a locator"));
48 return (m_identities.count(identity) > 0);
54 m_identities.insert(identity);
56 if (!m_hasDefaultIdentity) {
57 m_defaultIdentity = identity;
58 m_hasDefaultIdentity =
true;
65 m_identities.erase(identity);
66 if (identity == m_defaultIdentity)
67 m_hasDefaultIdentity =
false;
85 m_defaultIdentity = identityName;
86 m_hasDefaultIdentity =
true;
92 if (m_hasDefaultIdentity)
93 return m_defaultIdentity;
95 BOOST_THROW_EXCEPTION(
Pib::Error(
"No default identity"));
101 return (m_keys.count(getKeyName(identity, keyId)) > 0);
109 Name keyName = getKeyName(identity, keyId);
110 m_keys[keyName] = publicKey;
112 if (m_defaultKey.find(identity) == m_defaultKey.end())
113 m_defaultKey[identity] = keyName;
119 Name keyName = getKeyName(identity, keyId);
120 m_keys.erase(keyName);
121 m_defaultKey.erase(identity);
125 for (
const auto& certName : certNames) {
133 if (!
hasKey(identity, keyId))
136 auto it = m_keys.find(getKeyName(identity, keyId));
140 std::set<name::Component>
143 std::set<name::Component> ids;
144 for (
const auto& it : m_keys) {
146 ids.insert(it.first.get(-1));
154 Name keyName = getKeyName(identity, keyId);
156 if (!
hasKey(identity, keyId))
159 m_defaultKey[identity] = keyName;
165 auto it = m_defaultKey.find(identity);
166 if (it == m_defaultKey.end())
167 BOOST_THROW_EXCEPTION(
Pib::Error(
"No default key"));
169 return it->second.get(-1);
175 Name keyName = identity;
183 return (m_certs.count(certName) > 0);
193 m_certs[certificate.
getName()] = certificate;
196 if (m_defaultCert.find(keyName) == m_defaultCert.end())
197 m_defaultCert[keyName] = certificate.
getName();
203 m_certs.erase(certName);
213 auto it = m_certs.find(certName);
220 Name keyName = getKeyName(identity, keyId);
222 std::set<Name> certNames;
223 for (
const auto& it : m_certs) {
224 if (it.second.getPublicKeyName() == keyName)
225 certNames.insert(it.first);
236 Name keyName = getKeyName(identity, keyId);
237 m_defaultCert[keyName] = certName;
243 Name keyName = getKeyName(identity, keyId);
245 auto it = m_defaultCert.find(keyName);
246 if (it == m_defaultCert.end())
247 BOOST_THROW_EXCEPTION(
Pib::Error(
"No default certificate"));
249 auto certIt = m_certs.find(it->second);
250 if (certIt == m_certs.end())
251 BOOST_THROW_EXCEPTION(
Pib::Error(
"No default certificate"));
253 return certIt->second;
virtual v1::PublicKey getKeyBits(const Name &identity, const name::Component &keyId) const override
Get the key bits of a key.
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
static Name certificateNameToPublicKeyName(const Name &certificateName)
Get the public key name from the full certificate name.
Copyright (c) 2011-2015 Regents of the University of California.
virtual Name getDefaultIdentity() const override
Get the default identity.
virtual void removeIdentity(const Name &identity) override
Remove an identity.
virtual bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
virtual void addIdentity(const Name &identity) override
Add an identity.
const Component & get(ssize_t i) const
Get the component at the given index.
const Name & getName() const
Get name of the Data packet.
virtual void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
virtual bool hasKey(const Name &identity, const name::Component &keyId) const override
Check the existence of a key.
const Name & getPublicKeyName() const
virtual bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
virtual v1::IdentityCertificate getCertificate(const Name &certName) const override
Get a certificate with name certName.
virtual std::set< name::Component > getKeysOfIdentity(const Name &identity) const override
Get all the key ids of an identity with name identity.
virtual std::set< Name > getCertificatesOfKey(const Name &identity, const name::Component &keyId) const override
Get a list of certificate names of a key with id keyId of identity.
represents a semantic error
PublicKey & getPublicKeyInfo()
virtual std::set< Name > getIdentities() const override
Get the name of all the identities.
virtual void addKey(const Name &identity, const name::Component &keyId, const v1::PublicKey &publicKey) override
Add a key.
virtual void setDefaultCertificateOfKey(const Name &identity, const name::Component &keyId, const Name &certName) override
Set a cert with name certName as the default of a key with id keyId of identity.
virtual void addCertificate(const v1::IdentityCertificate &certificate) override
Add a certificate.
Name abstraction to represent an absolute name.
virtual void removeKey(const Name &identity, const name::Component &keyId) override
Remove a key.
virtual void setDefaultIdentity(const Name &identityName) override
Set an identity with name identityName as the default identity.
virtual v1::IdentityCertificate getDefaultCertificateOfKey(const Name &identity, const name::Component &keyId) const override
Get the default certificate of a key with id keyId of identity.
Component holds a read-only name component value.
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
virtual void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
virtual name::Component getDefaultKeyOfIdentity(const Name &identity) const override
Get the id of the default key of an identity with name identity.
virtual void setDefaultKeyOfIdentity(const Name &identity, const name::Component &keyId) override
Set an key with id keyId as the default key of an identity with name identity.
virtual std::string getTpmLocator() const override
Get TPM Locator.