security: Added IdentityCertificate::certificateNameToPublicKeyName and use it in signByCertificate so that it doesn't t need to retrieve the certificate just to get the key name.
diff --git a/src/security/certificate/identity-certificate.cpp b/src/security/certificate/identity-certificate.cpp
index 2e2ea79..95f6c1b 100644
--- a/src/security/certificate/identity-certificate.cpp
+++ b/src/security/certificate/identity-certificate.cpp
@@ -67,8 +67,18 @@
void
IdentityCertificate::setPublicKeyName()
{
- const Name& certificateName = getName();
+ publicKeyName_ = certificateNameToPublicKeyName(getName());
+}
+bool
+IdentityCertificate::isIdentityCertificate(const Certificate& certificate)
+{
+ return isCorrectName(certificate.getName());
+}
+
+Name
+IdentityCertificate::certificateNameToPublicKeyName(const Name& certificateName)
+{
int i = certificateName.size() - 1;
string idString("ID-CERT");
for (; i >= 0; i--) {
@@ -83,13 +93,7 @@
break;
}
- publicKeyName_ = tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
-}
-
-bool
-IdentityCertificate::isIdentityCertificate(const Certificate& certificate)
-{
- return isCorrectName(certificate.getName());
+ return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
}
}