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) 2013-2017 Regents of the University of California.
Data & setName(const Name &name)
Set name.
Represents a TLV element of NDN packet format.
BOOST_CONCEPT_ASSERT((WireEncodable< Certificate >))
Name & append(const Component &component)
Append a component.
IdentityCertificate()
The default constructor.
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
std::string toUri() const
Get URI representation of the name.
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.
size_t size() const
Get number of components.
Represents an absolute name.
const Name & getName() const
Get name.
void setName(const Name &name)
PartialName getSubName(ssize_t iStartComponent, size_t nComponents=npos) const
Extract some components as a sub-name (PartialName)
Represents a Data packet.
void wireDecode(const Block &wire)
const Component & get(ssize_t i) const
Get the component at the given index.