represents a key More...
#include <key.hpp>
Public Member Functions | |
Key () | |
Default Constructor. More... | |
const Name & | getName () const |
Get the name of the key. More... | |
const Name & | getIdentity () const |
Get the name of the belonging identity. More... | |
const name::Component & | getKeyId () const |
Get the key id of the key. More... | |
const PublicKey & | getPublicKey () const |
Get public key. More... | |
IdentityCertificate | getCertificate (const Name &certName) const |
Get a certificate. More... | |
const CertificateContainer & | getCertificates () const |
Get all the certificates for this key. More... | |
const IdentityCertificate & | getDefaultCertificate () const |
Get the default certificate for this Key. More... | |
operator bool () const | |
Check if the Key instance is valid. More... | |
bool | operator! () const |
Check if the Key instance is invalid. More... | |
void | removeCertificate (const Name &certName) |
Remove a certificate. More... | |
const IdentityCertificate & | setDefaultCertificate (const Name &certName) |
Set the default certificate. More... | |
const IdentityCertificate & | setDefaultCertificate (const IdentityCertificate &certificate) |
Set the default certificate. More... | |
Key (const Name &identityName, const name::Component &keyId, shared_ptr< PibImpl > impl) | |
Create an KeyEntry with identityName and keyId . More... | |
void | validityCheck () const |
Check the validity of this instance. More... | |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad0__: void addCertificate(const IdentityCertificate& certificate) |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad1__: Key(const Name& identityName |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & | keyId |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey & | publicKey |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey shared_ptr< PibImpl > | impl |
Friends | |
class | Identity |
class | KeyContainer |
class | KeyChain |
represents a key
Key is at the second level in PIB's Identity-Key-Certificate hierarchy. An Key has a Name (identity + 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.
PibImpl::Error | when underlying implementation has non-semantic error. |
ndn::security::Key::Key | ( | ) |
Default Constructor.
Key created using this default constructor is just a place holder. It must obtain an actual instance from Identity::getKey(...). A typical usage would be for exception handling:
Key key; try { key = Identity.getKey(...); } catch (Pib::Error&) { ... }
A Key instance created using the constructor is invalid. Calling a member method on an invalid Key instance may cause an std::domain_error.
Definition at line 29 of file key.cpp.
References ndn::Name::append(), impl, keyId, publicKey, and validityCheck().
ndn::security::Key::Key | ( | const Name & | identityName, |
const name::Component & | keyId, | ||
shared_ptr< PibImpl > | impl | ||
) |
Create an KeyEntry with identityName
and keyId
.
identityName | The name of the Identity. |
keyId | The key id of the key. |
impl | The actual backend implementation. |
Pib::Error | if the key does not exist. |
Definition at line 54 of file key.cpp.
References ndn::Name::append(), and validityCheck().
const Name & ndn::security::Key::getName | ( | ) | const |
const Name & ndn::security::Key::getIdentity | ( | ) | const |
Get the name of the belonging identity.
Definition at line 79 of file key.cpp.
References validityCheck().
const name::Component & ndn::security::Key::getKeyId | ( | ) | const |
Get the key id of the key.
Definition at line 87 of file key.cpp.
References validityCheck().
Referenced by ndn::security::Identity::removeKey(), and ndn::security::Identity::setDefaultKey().
const PublicKey & ndn::security::Key::getPublicKey | ( | ) | const |
Get public key.
Definition at line 95 of file key.cpp.
References ndn::security::CertificateContainer::end(), ndn::security::CertificateContainer::find(), ndn::Data::getName(), and validityCheck().
IdentityCertificate ndn::security::Key::getCertificate | ( | const Name & | certName | ) | const |
Get a certificate.
Pib::Error | if the certificate does not exist. |
Definition at line 130 of file key.cpp.
References validityCheck().
const CertificateContainer & ndn::security::Key::getCertificates | ( | ) | const |
Get all the certificates for this key.
Definition at line 138 of file key.cpp.
References validityCheck().
const IdentityCertificate & ndn::security::Key::getDefaultCertificate | ( | ) | const |
Get the default certificate for this Key.
Pib::Error | if the default certificate does not exist. |
Definition at line 170 of file key.cpp.
References validityCheck().
ndn::security::Key::operator bool | ( | ) | const |
bool ndn::security::Key::operator! | ( | ) | const |
Check if the Key instance is invalid.
Definition at line 188 of file key.cpp.
Referenced by operator bool().
void ndn::security::Key::removeCertificate | ( | const Name & | certName | ) |
Remove a certificate.
certName | The name of the certificate to delete. |
Definition at line 118 of file key.cpp.
References ndn::Data::getName(), and validityCheck().
const IdentityCertificate & ndn::security::Key::setDefaultCertificate | ( | const Name & | certName | ) |
Set the default certificate.
certName | The name of the default certificate of the key. |
Pib::Error | if the certificate does not exist. |
Definition at line 152 of file key.cpp.
References validityCheck().
Referenced by setDefaultCertificate().
const IdentityCertificate & ndn::security::Key::setDefaultCertificate | ( | const IdentityCertificate & | certificate | ) |
Set the default certificate.
If the certificate does not exist, add it and set it as the default certificate of the key. If the certificate exists, simply set it as the default certificate of the key.
certificate | The certificate to add. |
Definition at line 163 of file key.cpp.
References ndn::Data::getName(), and setDefaultCertificate().
void ndn::security::Key::validityCheck | ( | ) | const |
Check the validity of this instance.
std::domain_error | if the instance is invalid |
Definition at line 194 of file key.cpp.
Referenced by getCertificate(), getCertificates(), getDefaultCertificate(), getIdentity(), getKeyId(), getName(), getPublicKey(), Key(), removeCertificate(), and setDefaultCertificate().
|
friend |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad0__ |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad1__ |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component& ndn::security::Key::keyId |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey& ndn::security::Key::publicKey |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey shared_ptr<PibImpl> ndn::security::Key::impl |