24 #include "../v2/certificate.hpp" 40 return lock()->getName();
46 return lock()->getIdentity();
52 return lock()->getKeyType();
58 return lock()->getPublicKey();
64 return lock()->addCertificate(certificate);
70 return lock()->removeCertificate(certName);
76 return lock()->getCertificate(certName);
82 return lock()->getCertificates();
88 return lock()->setDefaultCertificate(certName);
94 return lock()->setDefaultCertificate(certificate);
100 return lock()->getDefaultCertificate();
103 Key::operator bool()
const 105 return !m_impl.expired();
108 shared_ptr<detail::KeyImpl>
111 auto impl = m_impl.lock();
113 if (impl ==
nullptr) {
114 BOOST_THROW_EXCEPTION(std::domain_error(
"Invalid key instance"));
123 return lhs.m_impl.owner_before(rhs.m_impl) || rhs.m_impl.owner_before(lhs.m_impl);
145 Name keyName = identity;
147 .
append(Certificate::KEY_COMPONENT)
155 return (keyName.
size() >= Certificate::MIN_KEY_NAME_LENGTH &&
156 keyName.
get(-Certificate::MIN_KEY_NAME_LENGTH) == Certificate::KEY_COMPONENT);
163 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` " 164 "does not follow the naming conventions"));
167 return keyName.
getPrefix(-Certificate::MIN_KEY_NAME_LENGTH);
std::ostream & operator<<(std::ostream &os, const Identity &id)
const Name & getName() const
Get key name.
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
const v2::Certificate & setDefaultCertificate(const Name &certName) const
Set an existing certificate with certName as the default certificate.
Name & append(const Component &component)
Append a component.
bool isValidKeyName(const Name &keyName)
Check if keyName follow the naming conventions for the key name.
Catch-all error for security policy errors that don't fit in other categories.
KeyType
The type of a cryptographic key.
std::string toUri() const
Get URI representation of the name.
Container of certificates of a key.
const CertificateContainer & getCertificates() const
Get all certificates for this key.
A frontend handle of a key instance.
KeyType getKeyType() const
Get key type.
void removeCertificate(const Name &certName) const
Remove a certificate with certName.
size_t size() const
Get number of components.
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Represents an absolute name.
const Buffer & getPublicKey() const
Get public key bits.
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this Key.
Component holds a read-only name component value.
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix of the name.
const Name & getIdentity() const
Get the name of the belonging identity.
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
General-purpose automatically managed/resized buffer.
Key()
Default Constructor.
friend bool operator!=(const Key &, const Key &)
const Component & get(ssize_t i) const
Get the component at the given index.