A frontend handle of a key instance. More...
#include <key.hpp>
Public Member Functions | |
Key () | |
Default Constructor. More... | |
Key (weak_ptr< detail::KeyImpl > impl) | |
Create a Key with a backend implementation impl . More... | |
const Name & | getName () const |
Get key name. More... | |
const Name & | getIdentity () const |
Get the name of the belonging identity. More... | |
KeyType | getKeyType () const |
Get key type. More... | |
const Buffer & | getPublicKey () const |
Get public key bits. More... | |
v2::Certificate | getCertificate (const Name &certName) const |
Get a certificate with certName . More... | |
const CertificateContainer & | getCertificates () const |
Get all certificates for this key. More... | |
const v2::Certificate & | getDefaultCertificate () const |
Get the default certificate for this Key. More... | |
operator bool () const | |
Check if the Key instance is valid. More... | |
void | removeCertificate (const Name &certName) const |
Remove a certificate with certName . More... | |
const v2::Certificate & | setDefaultCertificate (const Name &certName) const |
Set an existing certificate with certName as the default certificate. More... | |
const v2::Certificate & | setDefaultCertificate (const v2::Certificate &certificate) const |
Add certificate and set it as the default certificate of the key. More... | |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad0__: void addCertificate(const v2::Certificate& certificate) const |
Friends | |
class | v2::KeyChain |
bool | operator!= (const Key &, const Key &) |
A frontend handle of a key instance.
Key is at the second level in PIB's Identity-Key-Certificate hierarchy. A Key has a Name (identity + "KEY" + keyId), and contains one or more certificates, one of which is set as the default certificate of this key. A certificate can be directly accessed from a Key object.
|
default |
Default Constructor.
Key created using this default constructor is just a place holder. It can obtain an actual instance from Identity::getKey(...). A typical usage would be for exception handling:
Key key; try { key = identity.getKey(...); } catch (const Pib::Error&) { ... }
A Key instance created using this constructor is invalid. Calling a member method on an invalid Key instance may cause an std::domain_error.
|
explicit |
Create a Key with a backend implementation impl
.
This method should only be used by KeyContainer.
const Name & ndn::security::pib::Key::getName | ( | ) | const |
Get key name.
Definition at line 38 of file key.cpp.
Referenced by ndn::security::pib::detail::IdentityImpl::getDefaultKey(), ndn::security::pib::operator<<(), ndn::security::v2::parseLocatorUri(), and ndn::security::pib::detail::IdentityImpl::removeKey().
const Name & ndn::security::pib::Key::getIdentity | ( | ) | const |
KeyType ndn::security::pib::Key::getKeyType | ( | ) | const |
Get key type.
Definition at line 50 of file key.cpp.
Referenced by ndn::security::v2::parseLocatorUri().
const Buffer & ndn::security::pib::Key::getPublicKey | ( | ) | const |
Get public key bits.
Definition at line 56 of file key.cpp.
Referenced by ndn::security::verifySignature().
v2::Certificate ndn::security::pib::Key::getCertificate | ( | const Name & | certName | ) | const |
Get a certificate with certName
.
std::invalid_argument | certName does not match key name |
Pib::Error | the certificate does not exist. |
const CertificateContainer & ndn::security::pib::Key::getCertificates | ( | ) | const |
const v2::Certificate & ndn::security::pib::Key::getDefaultCertificate | ( | ) | const |
Get the default certificate for this Key.
Pib::Error | the default certificate does not exist. |
|
explicit |
void ndn::security::pib::Key::removeCertificate | ( | const Name & | certName | ) | const |
const v2::Certificate & ndn::security::pib::Key::setDefaultCertificate | ( | const Name & | certName | ) | const |
Set an existing certificate with certName
as the default certificate.
std::invalid_argument | certName does not match key name |
Pib::Error | the certificate does not exist. |
const v2::Certificate & ndn::security::pib::Key::setDefaultCertificate | ( | const v2::Certificate & | certificate | ) | const |
|
friend |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::pib::Key::__pad0__ |