Allow changing alias
diff --git a/src/contact-item.cpp b/src/contact-item.cpp
index 08f4fa6..c14b328 100644
--- a/src/contact-item.cpp
+++ b/src/contact-item.cpp
@@ -13,10 +13,14 @@
#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
+#include "logging.h"
+
using namespace std;
using namespace ndn;
using namespace ndn::security;
+INIT_LOGGER("ContactItem");
+
ContactItem::ContactItem(const EndorseCertificate& selfEndorseCertificate,
const string& alias)
: m_selfEndorseCertificate(selfEndorseCertificate)
@@ -24,8 +28,31 @@
Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName();
Ptr<const signature::Sha256WithRsa> endorseSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(selfEndorseCertificate.getSignature());
const Name& signingKeyName = endorseSig->getKeyLocator().getKeyName();
+
+ int i = 0;
+ int j = -1;
+ string keyString("KEY");
+ string idString("ID-CERT");
+ for(; i < signingKeyName.size(); i++)
+ {
+ if(keyString == signingKeyName.get(i).toUri())
+ j = i;
+ if(idString == signingKeyName.get(i).toUri())
+ break;
+ }
- if(endorsedkeyName != signingKeyName)
+ if(i >= signingKeyName.size() || j < 0)
+ throw LnException("Wrong name!");
+
+ Name subName = signingKeyName.getSubName(0, j);
+ subName.append(signingKeyName.getSubName(j+1, i-j-1));
+
+
+
+ // _LOG_DEBUG("endorsedkeyName " << endorsedkeyName.toUri());
+ // _LOG_DEBUG("subKeyName " << subName.toUri());
+
+ if(endorsedkeyName != subName)
throw LnException("not a self-claimed");
m_namespace = endorsedkeyName.getSubName(0, endorsedkeyName.size() - 1);