security: Implement interface to IdentityManager.
diff --git a/ndn-cpp/security/identity/identity-manager.hpp b/ndn-cpp/security/identity/identity-manager.hpp
index fee8b99..1d497ec 100644
--- a/ndn-cpp/security/identity/identity-manager.hpp
+++ b/ndn-cpp/security/identity/identity-manager.hpp
@@ -8,8 +8,9 @@
 #ifndef NDN_IDENTITY_MANAGER_HPP
 #define	NDN_IDENTITY_MANAGER_HPP
 
-#include "../../data.hpp"
+#include "../certificate/certificate.hpp"
 #include "identity-storage.hpp"
+#include "../certificate/public-key.hpp"
 #include "private-key-storage.hpp"
 
 namespace ndn {
@@ -24,15 +25,13 @@
   {
   }
   
-#if 0
   /**
-   * Create identity, by default it will create a pair of Key-Signing-Key(KSK) for this identity and a self-signed certificate of the KSK
-   * @param identityName the name of the identity
-   * @return the key name of the auto-generated KSK of the identity 
+   * Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed certificate of the KSK.
+   * @param identityName The name of the identity.
+   * @return The key name of the auto-generated KSK of the identity.
    */
   Name
   createIdentity(const Name& identityName);
-#endif
     
   /**
    * Get the default identity.
@@ -44,87 +43,104 @@
     return identityStorage_->getDefaultIdentity();
   }
 
-#if 0
   /**
-   * Generate a pair of RSA keys for the specified identity
-   * @param identityName the name of the identity
-   * @param ksk create a KSK or not, true for KSK, false for DSK 
-   * @param keySize the size of the key
-   * @return the generated key name 
+   * Generate a pair of RSA keys for the specified identity.
+   * @param identityName The name of the identity.
+   * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
+   * @param keySize The size of the key.
+   * @return The generated key name.
    */
   Name
-  generateRSAKeyPair(const Name& identityName, bool ksk = false, int keySize = 2048);
+  generateRSAKeyPair(const Name& identityName, bool isKsk = false, int keySize = 2048);
 
   /**
-   * Set a key as the default key of an identity
-   * @param keyName the name of the key
-   * @param identityName the name of the identity, if not specified the identity name can be inferred from the keyName
+   * Set a key as the default key of an identity.
+   * @param keyName The name of the key.
+   * @param identityName the name of the identity. If not specified, the identity name is inferred from the keyName.
    */
   void
-  setDefaultKeyForIdentity(const Name& keyName, const Name& identityName = Name());
+  setDefaultKeyForIdentity(const Name& keyName, const Name& identityName = Name())
+  {
+    identityStorage_->setDefaultKeyNameForIdentity(keyName, identityName);
+  }
 
   /**
-   * Generate a pair of RSA keys for the specified identity and set it as default key of the identity
-   * @param identityName the name of the identity
-   * @param ksk create a KSK or not, true for KSK, false for DSK 
-   * @param keySize the size of the key
-   * @return the generated key name
+   * Generate a pair of RSA keys for the specified identity and set it as default key for the identity.
+   * @param identityName The name of the identity.
+   * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
+   * @param keySize The size of the key.
+   * @return The generated key name.
    */
   Name
-  generateRSAKeyPairAsDefault(const Name& identityName, bool ksk = false, int keySize = 2048);
+  generateRSAKeyPairAsDefault(const Name& identityName, bool isKsk = false, int keySize = 2048);
 
   /**
-   * Get public key with the specified name
-   * @param keyName name of the key
-   * @return the public key
+   * Get the public key with the specified name.
+   * @param keyName The name of the key.
+   * @return The public key.
    */
-  Ptr<Publickey>
-  getPublickey(const Name& keyName);
+  ptr_lib::shared_ptr<PublicKey>
+  getPublicKey(const Name& keyName)
+  {
+    return PublicKey::fromDer(identityStorage_->getKey(keyName));
+  }
 
   /**
-   * Add a certificate into the public storage
-   * @param certificate the certificate to to added
+   * Add a certificate into the public key identity storage.
+   * @param certificate The certificate to to added.
    */
   void
-  addCertificate(Ptr<Certificate> certificate);
+  addCertificate(const Certificate& certificate)
+  {
+    identityStorage_->addCertificate(certificate);
+  }
 
   /**
-   * Set the certificate as the default of its corresponding key
-   * @param certificateName name of the certificate
+   * Set the certificate as the default for its corresponding key.
+   * @param certificateName The name of the certificate.
    */
   void
   setDefaultCertificateForKey(const Name& certificateName);
 
   /**
-   * Add a certificate into the public storage and set the certificate as the default of its corresponding identity
-   * @param certificate the certificate to be added
+   * Add a certificate into the public key identity storage and set the certificate as the default for its corresponding identity.
+   * @param certificate The certificate to be added.
    */
   void
   addCertificateAsIdentityDefault(const Certificate& certificate);
 
   /**
-   * Add a certificate into the public storage and set the certificate as the default of its corresponding key
+   * Add a certificate into the public key identity storage and set the certificate as the default of its corresponding key.
    * certificate the certificate to be added
    */
   void
-  addCertificateAsDefault(const Certificate& certificate);
+  addCertificateAsDefault(const Certificate& certificate)
+  {
+    identityStorage_->addCertificate(certificate);    
+    setDefaultCertificateForKey(certificate.getName());
+  }
 
   /**
-   * Get a certificate with the specified name
-   * @param certificateName name of the requested certificate
-   * @return the requested certificate
+   * Get a certificate with the specified name.
+   * @param certificateName The name of the requested certificate.
+   * @return the requested certificate which is valid.
    */
-  Ptr<Certificate>
-  getCertificate(const Name& certificateName);
+  ptr_lib::shared_ptr<Certificate>
+  getCertificate(const Name& certificateName)
+  {
+    return identityStorage_->getCertificate(certificateName, false);
+  }
     
   /**
-   * Get a certificate even if the certificate is not valid anymore
-   * @param certificateName name of the requested certificate
-   * @return the requested certificate
+   * Get a certificate even if the certificate is not valid anymore.
+   * @param certificateName The name of the requested certificate.
+   * @return the requested certificate.
    */
-  Ptr<Certificate>
-  getAnyCertificate(const Name& certificateName);
-#endif
+  ptr_lib::shared_ptr<Certificate>
+  getAnyCertificate(const Name& certificateName)
+  {
+    return identityStorage_->getCertificate(certificateName, true);
+  }
     
   /**
    * Get the default certificate name for the specified identity, which will be used when signing is performed based on identity.
@@ -150,23 +166,6 @@
         
 #if 0
   /**
-   * Sign blob based on identity
-   * @param blob the blob to be signed
-   * @param identityName the signing identity name
-   * @return the generated signature
-   */
-  Ptr<Signature>
-  signByIdentity(const Blob& blob, const Name& identityName);
-
-  /**
-   * Sign data based on identity
-   * @param data the data packet to be signed, on return the Signature inside the data packet will be set
-   * @param identityName the signing identity name
-   */
-  void
-  signByIdentity(Data& data, const Name& identityName);
-
-  /**
    * sign blob based on certificate name
    * @param blob the blob to be signed
    * @param certificateName the signing certificate name
@@ -188,6 +187,25 @@
   signByCertificate(Data& data, const Name& certificateName, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
   
 private:
+  /**
+   * Generate a key pair for the specified identity.
+   * @param identityName The name of the specified identity.
+   * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
+   * @param keyType The type of the key pair, e.g. KEY_TYPE_RSA.
+   * @param keySize The size of the key pair.
+   * @return The name of the generated key.
+   */
+  Name
+  generateKeyPair(const Name& identityName, bool isKsk = false, KeyType keyType = KEY_TYPE_RSA, int keySize = 2048);
+
+  /**
+   * Generate a self-signed certificate for a public key.
+   * @param keyName The name of the public key.
+   * @return The generated certificate.
+   */
+  ptr_lib::shared_ptr<Certificate>
+  selfSign(const Name& keyName);
+  
   ptr_lib::shared_ptr<IdentityStorage> identityStorage_;
   ptr_lib::shared_ptr<PrivateKeyStorage> privateKeyStorage_;
 };