23 #include "../../util/concepts.hpp" 33 static_assert(std::is_base_of<Certificate::Error, IdentityCertificate::Error>::value,
34 "IdentityCertificate::Error must inherit from Certificate::Error");
68 IdentityCertificate::isCorrectName(
const Name&
name)
70 string idString(
"ID-CERT");
71 ssize_t i = name.
size() - 1;
80 string keyString(
"KEY");
82 for (; keyIndex < name.
size(); keyIndex++) {
83 if (name.
get(keyIndex).
toUri() == keyString)
87 if (keyIndex >= name.
size())
94 IdentityCertificate::setPublicKeyName()
97 BOOST_THROW_EXCEPTION(
Error(
"Wrong Identity Certificate Name"));
111 string idString(
"ID-CERT");
112 bool foundIdString =
false;
113 size_t idCertComponentIndex = certificateName.
size() - 1;
114 for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
115 if (certificateName.
get(idCertComponentIndex).
toUri() == idString)
117 foundIdString =
true;
123 BOOST_THROW_EXCEPTION(
Error(
"Incorrect identity certificate name " + certificateName.
toUri()));
125 Name tmpName = certificateName.
getSubName(0, idCertComponentIndex);
126 string keyString(
"KEY");
127 bool foundKeyString =
false;
128 size_t keyComponentIndex = 0;
129 for (; keyComponentIndex < tmpName.
size(); keyComponentIndex++) {
130 if (tmpName.
get(keyComponentIndex).
toUri() == keyString)
132 foundKeyString =
true;
138 BOOST_THROW_EXCEPTION(
Error(
"Incorrect identity certificate name " + certificateName.
toUri()));
143 tmpName.
size() - keyComponentIndex - 1));
static Name certificateNameToPublicKeyName(const Name &certificateName)
Get the public key name from the full certificate name.
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Encode this name as a URI.
const Component & get(ssize_t i) const
Get the component at the given index.
Data & setName(const Name &name)
Set name to a copy of the given Name.
const Name & getName() const
Get name of the Data packet.
Class representing a wire element of NDN-TLV packet format.
IdentityCertificate()
The default constructor.
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
static bool isIdentityCertificate(const Certificate &certificate)
void wireDecode(const Block &wire)
void toUri(std::ostream &os) const
Write *this to the output stream, escaping characters according to the NDN URI Scheme.
Name abstraction to represent an absolute name.
size_t size() const
Get the number of components.
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
void setName(const Name &name)
a concept check for TLV abstraction with .wireEncode method
void wireDecode(const Block &wire)
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
PartialName getSubName(ssize_t iStartComponent, size_t nComponents=npos) const
Extract a sub-name (PartialName) of nComponents components starting from iStartComponent.