security: In IdentityCertificate, added publicKeyName_ and make getPublicKeyName just return it.  Internally call setPublicKeyName as needed to set it.  Make isCorrectName() check for "KEY".
diff --git a/include/ndn-cpp/security/certificate/identity-certificate.hpp b/include/ndn-cpp/security/certificate/identity-certificate.hpp
index 0319774..d111acc 100644
--- a/include/ndn-cpp/security/certificate/identity-certificate.hpp
+++ b/include/ndn-cpp/security/certificate/identity-certificate.hpp
@@ -43,8 +43,8 @@
   virtual Data &
   setName(const Name& name);
 
-  virtual Name 
-  getPublicKeyName() const;
+  Name 
+  getPublicKeyName () const { return publicKeyName_; }
 
   static bool
   isIdentityCertificate(const Certificate& certificate);
@@ -52,6 +52,12 @@
 private:
   static bool
   isCorrectName(const Name& name);
+  
+  void
+  setPublicKeyName();
+    
+protected:
+  Name publicKeyName_;
 };
 
 }
diff --git a/src/encoding/der/visitor/print-visitor.cpp b/src/encoding/der/visitor/print-visitor.cpp
index cba5d2d..4c5ee64 100644
--- a/src/encoding/der/visitor/print-visitor.cpp
+++ b/src/encoding/der/visitor/print-visitor.cpp
@@ -78,7 +78,7 @@
 PrintVisitor::visit(DerOid& derOid, ndnboost::any param)
 {
   const string& indent = ndnboost::any_cast<const string&>(param);
-	
+  
   printData(derOid.getHeader(), indent);
   printData(derOid.getPayload(), indent + "   ");
 
@@ -88,7 +88,7 @@
 PrintVisitor::visit(DerGtime& derGtime, ndnboost::any param)
 {
   const string& indent = ndnboost::any_cast<const string&>(param);
-	
+  
   printData(derGtime.getHeader(), indent);
   printData(derGtime.getPayload(), indent + "   ");
 }
@@ -103,7 +103,7 @@
   const DerNodePtrList& children = derSequence.getChildren();
   DerNodePtrList::const_iterator it = children.begin();
   for(; it != children.end(); it++)
-	(*it)->accept(*this, indent + " | ");
+  (*it)->accept(*this, indent + " | ");
 }
 
 
diff --git a/src/security/certificate/identity-certificate.cpp b/src/security/certificate/identity-certificate.cpp
index a328112..2e2ea79 100644
--- a/src/security/certificate/identity-certificate.cpp
+++ b/src/security/certificate/identity-certificate.cpp
@@ -18,6 +18,8 @@
 {
   if (!isCorrectName(data.getName()))
     throw SecurityException("Wrong Identity Certificate Name!");
+  
+  setPublicKeyName();
 }
 
 IdentityCertificate::~IdentityCertificate()
@@ -29,14 +31,25 @@
 {
   int i = name.size() - 1;
   
+  string idString("ID-CERT");
   for (; i >= 0; i--) {
-    if(name.get(i).toEscapedString() == string("ID-CERT"))
+    if(name.get(i).toEscapedString() == idString)
       break;
   }
 
   if (i < 0)
     return false;
   
+  int keyIdx = 0;
+  string keyString("KEY");
+  for (; keyIdx < name.size(); keyIdx++) {
+    if(name.get(keyIdx).toEscapedString() == keyString)
+      break;
+  }
+
+  if (keyIdx >= name.size())
+    return false;
+
   return true;
 }
 
@@ -47,20 +60,30 @@
     throw SecurityException("Wrong Identity Certificate Name!");
   
   Data::setName(name);
+  setPublicKeyName();
   return *this;
 }
 
-Name
-IdentityCertificate::getPublicKeyName() const
+void
+IdentityCertificate::setPublicKeyName()
 {
   const Name& certificateName = getName();
-  int i = certificateName.size() - 1;
 
-  for (; i >= 0; i--)
-    if(certificateName.get(i).toEscapedString() == string("ID-CERT"))
-  break; 
+  int i = certificateName.size() - 1;
+  string idString("ID-CERT");
+  for (; i >= 0; i--) {
+    if (certificateName.get(i).toEscapedString() == idString)
+      break;
+  }
+    
+  Name tmpName = certificateName.getSubName(0, i);    
+  string keyString("KEY");
+  for (i = 0; i < tmpName.size(); i++) {
+    if (tmpName.get(i).toEscapedString() == keyString)
+      break;
+  }
   
-  return certificateName.getSubName(0, i);
+  publicKeyName_ = tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
 }
 
 bool