27 #include "../../encoding/block-helpers.hpp"
28 #include "../../util/indented-stream.hpp"
29 #include "../transform.hpp"
57 BOOST_THROW_EXCEPTION(
Data::Error(
"Name does not follow the naming convention for certificate"));
60 BOOST_THROW_EXCEPTION(
Data::Error(
"ContentType is not KEY"));
63 BOOST_THROW_EXCEPTION(
Data::Error(
"FreshnessPeriod is not set"));
66 BOOST_THROW_EXCEPTION(
Data::Error(
"Content is empty"));
108 BOOST_THROW_EXCEPTION(
Data::Error(
"Content is empty"));
134 return (certName.
size() >= Certificate::MIN_CERT_NAME_LENGTH &&
141 os <<
"Certificate name:\n";
142 os <<
" " << cert.
getName() <<
"\n";
151 os <<
"Additional Description:\n";
153 os <<
" " << item.first <<
": " << item.second <<
"\n";
160 os <<
"Public key bits:\n";
167 os <<
"Signature Information:\n";
172 os <<
" Key Locator: ";
175 os <<
"Self-Signed ";
177 os << keyLocator <<
"\n";
188 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
189 "does not follow the naming conventions"));
192 return certName.
getPrefix(Certificate::KEY_COMPONENT_OFFSET);
199 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
200 "does not follow the naming conventions"));
203 return certName.
getPrefix(Certificate::KEY_ID_OFFSET + 1);
bool isValid(const time::system_clock::TimePoint &ts=time::system_clock::now()) const
Check if the certificate is valid at ts.
Data & setContentType(uint32_t type)
Copyright (c) 2013-2016 Regents of the University of California.
static const ssize_t KEY_ID_OFFSET
The certificate following the certificate format naming convention.
Name getKeyName() const
Get key name.
const Block & getTypeSpecificTlv(uint32_t type) const
Get signature type specific tlv block.
static const size_t MIN_KEY_NAME_LENGTH
uint32_t getContentType() const
Abstraction of AdditionalDescription.
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.
bool hasKeyLocator() const
Check if SignatureInfo block has a KeyLocator.
const KeyLocator & getKeyLocator() const
Get KeyLocator.
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
Class representing a wire element of NDN-TLV packet format.
indicates KeyLocator contains a Name
static const size_t MIN_CERT_NAME_LENGTH
const Name & getName() const
Get name of the Data packet.
const SignatureInfo & getSignatureInfo() const
Get SignatureInfo.
uint32_t getType() const
Get signature type.
std::string toUri() const
Encode this name as a URI.
const Name & getName() const
get Name element
name::Component getKeyId() const
Get key ID.
Abstraction of validity period.
std::pair< time::system_clock::TimePoint, time::system_clock::TimePoint > getPeriod() const
Get the stored validity period.
static const ssize_t KEY_COMPONENT_OFFSET
static const ssize_t VERSION_OFFSET
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.
name::Component getIssuerId() const
Get issuer ID.
const Block & getExtension(uint32_t type) const
Get extension with TLV type.
size_t size() const
Get the number of components.
Name getIdentity() const
Get identity name.
Name abstraction to represent an absolute name.
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
Buffer getPublicKey() const
Get public key bits (in PKCS#8 format)
const Signature & getSignature() const
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &other)
Component holds a read-only name component value.
static bool isValidName(const Name &certName)
Check if the specified name follows the naming convention for the certificate.
const Block & getContent() const
Get content Block.
indicates content is a public key
bool isValid(const time::system_clock::TimePoint &now=time::system_clock::now()) const
Check if now falls within the validity period.
static const name::Component KEY_COMPONENT
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
static const ssize_t ISSUER_ID_OFFSET
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Class representing a general-use automatically managed/resized buffer.
Output to stream with specified indent or prefix.
const Component & get(ssize_t i) const
Get the component at the given index.
const Component & at(ssize_t i) const
Get component at the specified index.
const time::milliseconds & getFreshnessPeriod() const
Name extractIdentityFromCertName(const Name &certName)
Extract identity namespace from the certificate name certName.