Adjust fetching ksk certificate
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index 8ce77c8..bea8d7f 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -152,15 +152,9 @@
 {
   m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
 
-  const Blob& keyBlob = endorseCertificate.getPublicKeyInfo().getKeyBlob();
-  string encoded;
-  CryptoPP::StringSource ss(reinterpret_cast<const unsigned char *>(keyBlob.buf()), keyBlob.size(), true,
-                            new CryptoPP::Base64Encoder(new CryptoPP::StringSink(encoded), true, 64));
-  
-  ui->infoView->setColumnCount(1);  
-  ui->infoView->insertRow(0);  
-  QTableWidgetItem *keyBits = new QTableWidgetItem(QString::fromUtf8(encoded.c_str()));
-  ui->infoView->setItem(0, 0, keyBits);
+  m_currentCollectEndorseReady = NULL;
+
+  displayContactInfo();
 }
 
 void
diff --git a/src/addcontactpanel.ui b/src/addcontactpanel.ui
index 1955964..fb6f4fa 100644
--- a/src/addcontactpanel.ui
+++ b/src/addcontactpanel.ui
@@ -50,7 +50,7 @@
       <item>
        <widget class="QPushButton" name="searchButton">
         <property name="text">
-         <string>Search</string>
+         <string>Fetch</string>
         </property>
         <property name="autoDefault">
          <bool>false</bool>
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index de3a9ca..71b9ea2 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -185,13 +185,8 @@
 ContactManager::onKeyVerified(Ptr<Data> data, const Name& identity)
 {
   IdentityCertificate identityCertificate(*data);
-  Name keyName = identityCertificate.getPublicKeyName();
-  Profile profile(keyName.getPrefix(keyName.size()-1), 
-                  keyName.get(-2).toUri(),
-                  keyName.getPrefix(keyName.size()-2).toUri());
-  
-  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(keyName.getPrefix(keyName.size()-1),
-                                                                  profile));
+
+  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(Profile(identityCertificate)));
   
   Ptr<IdentityManager> identityManager = m_keychain->getIdentityManager();
   Name certificateName = identityManager->getDefaultCertificateName ();
@@ -313,7 +308,7 @@
   if(0 == certificateName.size())
     return NULL;
 
-  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(identity, profile));
+  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(profile));
   identityManager->signByCertificate(*profileData, certificateName);
 
   Ptr<security::IdentityCertificate> signingCert = identityManager->getCertificate(certificateName);
diff --git a/src/profile-data.cpp b/src/profile-data.cpp
index 9a8087b..ef067f9 100644
--- a/src/profile-data.cpp
+++ b/src/profile-data.cpp
@@ -19,13 +19,12 @@
 
 INIT_LOGGER("ProfileData");
 
-ProfileData::ProfileData(const Name& identity,
-			 const Profile& profile)
+ProfileData::ProfileData(const Profile& profile)
   : Data()
-  , m_identity(identity)
+  , m_identity(profile.getIdentityName())
   , m_profile(profile)
 {
-  Name dataName = identity;
+  Name dataName = m_identity;
 
   dataName.append("PROFILE").appendVersion();
   setName(dataName);
diff --git a/src/profile-data.h b/src/profile-data.h
index 4c2ac71..9c8e184 100644
--- a/src/profile-data.h
+++ b/src/profile-data.h
@@ -17,8 +17,7 @@
 class ProfileData : public ndn::Data
 {
 public:
-  ProfileData(const ndn::Name& identity,
-              const Profile& profile);
+  ProfileData(const Profile& profile);
 
   ProfileData(const ProfileData& profileData);
 
diff --git a/src/profile.cpp b/src/profile.cpp
index e5c5325..5261207 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -18,6 +18,48 @@
 using namespace ndn;
 
 INIT_LOGGER("Profile");
+
+static string nameOid("2.5.4.41");
+static string orgOid("2.5.4.11");
+static string groupOid("2.5.4.1");
+static string homepageOid("2.5.4.3");
+static string advisor("2.5.4.80");
+static string emailOid("1.2.840.113549.1.9.1");
+
+Profile::Profile(security::IdentityCertificate& identityCertificate)
+{
+  using namespace ndn::security;
+
+  Name keyName = identityCertificate.getPublicKeyName();
+  m_identityName = keyName.getPrefix(keyName.size()-1);
+
+  const string& identityString = m_identityName.toUri();
+  Blob identityBlob (identityString.c_str(), identityString.size());
+  m_entries[string("IDENTITY")] = identityBlob;
+  
+  const vector<CertificateSubDescrypt>& subList = identityCertificate.getSubjectDescriptionList();
+  vector<CertificateSubDescrypt>::const_iterator it = subList.begin();
+  for(; it != subList.end(); it++)
+    {
+      string oidStr = it->getOidStr();
+      Blob blob (it->getValue().c_str(), it->getValue().size());
+      if(oidStr == nameOid)
+        m_entries[string("name")] = blob;
+      else if(oidStr == orgOid)
+        m_entries[string("institution")] = blob;
+      else if(oidStr == groupOid)
+        m_entries[string("group")] = blob;
+      else if(oidStr == homepageOid)
+        m_entries[string("homepage")] = blob;
+      else if(oidStr == advisor)
+        m_entries[string("advisor")] = blob;
+      else if(oidStr == emailOid)
+        m_entries[string("email")] = blob;
+      else
+        m_entries[oidStr] = blob;
+    }
+}
+
 Profile::Profile(const Name& identityName)
   : m_identityName(identityName)
 {
diff --git a/src/profile.h b/src/profile.h
index 5c9ce24..b020408 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -14,6 +14,7 @@
 #include <ndn.cxx/common.h>
 #include <ndn.cxx/fields/name.h>
 #include <ndn.cxx/fields/blob.h>
+#include <ndn.cxx/security/certificate/identity-certificate.h>
 #include <map>
 #include <string>
 
@@ -25,6 +26,8 @@
 public:
   Profile() {}
 
+  Profile(ndn::security::IdentityCertificate& identityCertificate);
+
   Profile(const ndn::Name& identityName);
 
   Profile(const ndn::Name& identityName,
@@ -69,6 +72,10 @@
   getEntries() const
   { return m_entries; }
 
+  inline const ndn::Name&
+  getIdentityName() const
+  { return m_identityName; }
+
 protected:
   ndn::Name m_identityName;
   std::map<std::string, ndn::Blob> m_entries;