25 #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 int 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));
Copyright (c) 2011-2015 Regents of the University of California.
Data & setName(const Name &name)
Set name to a copy of the given Name.
void wireDecode(const Block &wire)
static Name certificateNameToPublicKeyName(const Name &certificateName)
Get the public key name from the full certificate name.
Class representing a wire element of NDN-TLV packet format.
void wireDecode(const Block &wire)
Data & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
const Name & getName() const
Get name of the Data packet.
std::string toUri() const
Encode this name as a URI.
IdentityCertificate()
The default constructor.
void setName(const Name &name)
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 the number of components.
static bool isIdentityCertificate(const Certificate &certificate)
Name abstraction to represent an absolute name.
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
PartialName getSubName(ssize_t iStartComponent, size_t nComponents=npos) const
Extract a sub-name (PartialName) of nComponents components starting from iStartComponent.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
const Component & get(ssize_t i) const
Get the component at the given index.