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) 2011-2015 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 SignatureType-specific sub-element.
static const size_t MIN_KEY_NAME_LENGTH
const time::milliseconds & getFreshnessPeriod() const
uint32_t getContentType() const
Abstraction of AdditionalDescription.
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.
const Signature & getSignature() const
Get Signature.
bool hasKeyLocator() const
Check if KeyLocator exists in SignatureInfo.
const KeyLocator & getKeyLocator() const
Get KeyLocator.
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
Represents a TLV element of NDN packet format.
indicates KeyLocator contains a Name
static const size_t MIN_CERT_NAME_LENGTH
Catch-all error for security policy errors that don't fit in other categories.
const SignatureInfo & getSignatureInfo() const
Get SignatureInfo.
std::string toUri() const
Get URI representation of the name.
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 number of components.
Name getIdentity() const
Get identity name.
Represents an absolute name.
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
const Component & at(ssize_t i) const
Get the component at the given index.
Buffer getPublicKey() const
Get public key bits (in PKCS#8 format)
tlv::SignatureTypeValue getType() const
Get SignatureType.
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &other)
const Name & getName() const
Get name.
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.
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 of the name.
static const ssize_t ISSUER_ID_OFFSET
a concept check for TLV abstraction with .wireEncode method
Represents a Data packet.
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
General-purpose 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.
Name extractIdentityFromCertName(const Name &certName)
Extract identity namespace from the certificate name certName.