18 IdentityCertificate::isCorrectName(
const Name& name)
20 string idString(
"ID-CERT");
21 int i = name.size() - 1;
23 if (name.get(i).toEscapedString() == idString)
30 string keyString(
"KEY");
32 for (; keyIndex < name.size(); keyIndex++) {
33 if (name.get(keyIndex).toEscapedString() == keyString)
37 if (keyIndex >= name.size())
44 IdentityCertificate::setPublicKeyName()
46 if (!isCorrectName(getName()))
47 throw Error(
"Wrong Identity Certificate Name!");
49 m_publicKeyName = certificateNameToPublicKeyName(getName());
53 IdentityCertificate::isIdentityCertificate(
const Certificate& certificate)
59 IdentityCertificate::certificateNameToPublicKeyName(
const Name& certificateName)
61 string idString(
"ID-CERT");
62 bool foundIdString =
false;
63 size_t idCertComponentIndex = certificateName.
size() - 1;
64 for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
73 throw Error(
"Incorrect identity certificate name " + certificateName.
toUri());
75 Name tmpName = certificateName.
getSubName(0, idCertComponentIndex);
76 string keyString(
"KEY");
77 bool foundKeyString =
false;
78 size_t keyComponentIndex = 0;
79 for (; keyComponentIndex < tmpName.size(); keyComponentIndex++) {
80 if (tmpName.get(keyComponentIndex).toEscapedString() == keyString)
82 foundKeyString =
true;
88 throw Error(
"Incorrect identity certificate name " + certificateName.
toUri());
91 .getSubName(0, keyComponentIndex)
92 .append(tmpName.getSubName(keyComponentIndex + 1,
93 tmpName.size() - keyComponentIndex - 1));
Name getSubName(size_t iStartComponent, size_t nComponents) const
Get a new name, constructed as a subset of components.
void toEscapedString(std::ostream &result) const
Write the value to result, escaping characters according to the NDN URI Scheme.
std::string toUri() const
Encode this name as a URI.
size_t size() const
Get the number of components.
A Name holds an array of Name::Component and represents an NDN name.
const Component & get(ssize_t i) const
Get the component at the given index.