Migrate to ndn-cxx 0.7.1: Part 1

Change-Id: I621a6230272cfde5d84aa5ca9abdf40a91337491
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 43becc5..40a4060 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -42,7 +42,7 @@
 
 _LOG_INIT(ndncert.ca);
 
-CaModule::CaModule(Face& face, security::v2::KeyChain& keyChain,
+CaModule::CaModule(Face& face, security::KeyChain& keyChain,
                    const std::string& configPath, const std::string& storageType)
     : m_face(face)
     , m_keyChain(keyChain)
@@ -191,7 +191,7 @@
   // get ECDH pub key and cert request
   const auto& parameterTLV = request.getApplicationParameters();
   std::string ecdhPub;
-  shared_ptr<security::v2::Certificate> clientCert;
+  shared_ptr<security::Certificate> clientCert;
   try {
       NEW_RENEW_REVOKE::decodeApplicationParameters(parameterTLV, requestType, ecdhPub, clientCert);
   } catch (const std::exception& e) {
@@ -236,7 +236,7 @@
 
   // verify identity name
   if (!m_config.m_caItem.m_caPrefix.isPrefixOf(clientCert->getIdentity())
-      || !security::v2::Certificate::isValidName(clientCert->getName())
+      || !security::Certificate::isValidName(clientCert->getName())
       || clientCert->getIdentity().size() <= m_config.m_caItem.m_caPrefix.size()) {
       _LOG_ERROR("An invalid certificate name is being requested " << clientCert->getName());
       m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::NAME_NOT_ALLOWED,
@@ -421,13 +421,13 @@
   }
 }
 
-security::v2::Certificate
+security::Certificate
 CaModule::issueCertificate(const CaState& requestState)
 {
   auto expectedPeriod =
       requestState.m_cert.getValidityPeriod().getPeriod();
   security::ValidityPeriod period(expectedPeriod.first, expectedPeriod.second);
-  security::v2::Certificate newCert;
+  security::Certificate newCert;
 
   Name certName = requestState.m_cert.getKeyName();
   certName.append("NDNCERT").append(std::to_string(random::generateSecureWord64()));
diff --git a/src/ca-module.hpp b/src/ca-module.hpp
index 04d594f..64af10a 100644
--- a/src/ca-module.hpp
+++ b/src/ca-module.hpp
@@ -31,7 +31,7 @@
 class CaModule : noncopyable
 {
 public:
-  CaModule(Face& face, security::v2::KeyChain& keyChain, const std::string& configPath,
+  CaModule(Face& face, security::KeyChain& keyChain, const std::string& configPath,
            const std::string& storageType = "ca-storage-sqlite3");
 
   ~CaModule();
@@ -73,7 +73,7 @@
   CaState
   getCertificateRequest(const Interest& request);
 
-  security::v2::Certificate
+  security::Certificate
   issueCertificate(const CaState& requestState);
 
   void
@@ -86,7 +86,7 @@
   Face& m_face;
   CaConfig m_config;
   unique_ptr<CaStorage> m_storage;
-  security::v2::KeyChain& m_keyChain;
+  security::KeyChain& m_keyChain;
   uint8_t m_requestIdGenKey[32];
   std::unique_ptr<Data> m_profileData;
 
diff --git a/src/ca-state.cpp b/src/ca-state.cpp
index e72b19f..b48f82d 100644
--- a/src/ca-state.cpp
+++ b/src/ca-state.cpp
@@ -43,7 +43,7 @@
 }
 
 CaState::CaState(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
-                 const security::v2::Certificate& cert, Block encryptionKey)
+                 const security::Certificate& cert, Block encryptionKey)
     : m_caPrefix(caName)
     , m_requestId(requestId)
     , m_requestType(requestType)
@@ -54,7 +54,7 @@
 }
 
 CaState::CaState(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
-                 const security::v2::Certificate& cert, const std::string& challengeType,
+                 const security::Certificate& cert, const std::string& challengeType,
                  const std::string& challengeStatus, const system_clock::TimePoint& challengeTp,
                  size_t remainingTries, time::seconds remainingTime, JsonSection&& challengeSecrets,
                  Block encryptionKey)
diff --git a/src/ca-state.hpp b/src/ca-state.hpp
index 6806688..baf791c 100644
--- a/src/ca-state.hpp
+++ b/src/ca-state.hpp
@@ -49,9 +49,9 @@
 public:
   CaState();
   CaState(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
-          const security::v2::Certificate& cert, Block m_encryptionKey);
+          const security::Certificate& cert, Block m_encryptionKey);
   CaState(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
-          const security::v2::Certificate& cert, const std::string& challengeType,
+          const security::Certificate& cert, const std::string& challengeType,
           const std::string& challengeStatus, const system_clock::TimePoint& challengeTp,
           size_t remainingTries, time::seconds remainingTime, JsonSection&& challengeSecrets,
           Block m_encryptionKey);
@@ -61,7 +61,7 @@
   std::string m_requestId;
   RequestType m_requestType;
   Status m_status;
-  security::v2::Certificate m_cert;
+  security::Certificate m_cert;
   Block m_encryptionKey;
 
   std::string m_challengeType;
diff --git a/src/ca-storage/ca-memory.cpp b/src/ca-storage/ca-memory.cpp
index 1fe27e1..e08a822 100644
--- a/src/ca-storage/ca-memory.cpp
+++ b/src/ca-storage/ca-memory.cpp
@@ -20,7 +20,7 @@
 
 #include "ca-memory.hpp"
 
-#include <ndn-cxx/security/v2/validation-policy.hpp>
+#include <ndn-cxx/security/validation-policy.hpp>
 
 namespace ndn {
 namespace ndncert {
diff --git a/src/ca-storage/ca-sqlite.cpp b/src/ca-storage/ca-sqlite.cpp
index 8292f36..594df46 100644
--- a/src/ca-storage/ca-sqlite.cpp
+++ b/src/ca-storage/ca-sqlite.cpp
@@ -23,7 +23,7 @@
 #include <sqlite3.h>
 
 #include <boost/filesystem.hpp>
-#include <ndn-cxx/security/v2/validation-policy.hpp>
+#include <ndn-cxx/security/validation-policy.hpp>
 #include <ndn-cxx/util/sqlite3-statement.hpp>
 
 namespace ndn {
@@ -120,7 +120,7 @@
     Name caName(statement.getBlock(1));
     auto status = static_cast<Status>(statement.getInt(2));
     auto challengeStatus = statement.getString(3);
-    security::v2::Certificate cert(statement.getBlock(4));
+    security::Certificate cert(statement.getBlock(4));
     auto challengeType = statement.getString(5);
     auto challengeSecrets = statement.getString(6);
     auto challengeTp = statement.getString(7);
@@ -217,7 +217,7 @@
     Name caName(statement.getBlock(2));
     auto status = static_cast<Status>(statement.getInt(3));
     auto challengeStatus = statement.getString(4);
-    security::v2::Certificate cert(statement.getBlock(5));
+    security::Certificate cert(statement.getBlock(5));
     auto challengeType = statement.getString(6);
     auto challengeSecrets = statement.getString(7);
     auto challengeTp = statement.getString(8);
@@ -254,7 +254,7 @@
     Name caName(statement.getBlock(2));
     auto status = static_cast<Status>(statement.getInt(3));
     auto challengeStatus = statement.getString(4);
-    security::v2::Certificate cert(statement.getBlock(5));
+    security::Certificate cert(statement.getBlock(5));
     auto challengeType = statement.getString(6);
     auto challengeSecrets = statement.getString(7);
     auto challengeTp = statement.getString(8);
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 3cc4aa7..618202c 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -75,7 +75,7 @@
   auto certificateStr = configJson.get(CONFIG_CERTIFICATE, "");
   if (certificateStr != "") {
     std::istringstream ss(certificateStr);
-    m_cert = io::load<security::v2::Certificate>(ss);
+    m_cert = io::load<security::Certificate>(ss);
   }
 }
 
@@ -141,9 +141,9 @@
         BOOST_THROW_EXCEPTION(std::runtime_error("Redirect-to item's ca-prefix or certificate cannot be empty."));
       }
       std::istringstream ss(caCertStr);
-      auto caCert = io::load<security::v2::Certificate>(ss);
+      auto caCert = io::load<security::Certificate>(ss);
       if (!m_redirection) {
-        m_redirection = std::vector<std::shared_ptr<security::v2::Certificate>>();
+        m_redirection = std::vector<std::shared_ptr<security::Certificate>>();
       }
       m_redirection->push_back(caCert);
     }
diff --git a/src/configuration.hpp b/src/configuration.hpp
index 40285e0..44c7df9 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -63,7 +63,7 @@
    * CA's certificate. Only Client side will have m_cert.
    * Default: nullptr.
    */
-  std::shared_ptr<security::v2::Certificate> m_cert;
+  std::shared_ptr<security::Certificate> m_cert;
 
   void
   parse(const JsonSection& configJson);
@@ -126,7 +126,7 @@
    * Used for CA redirection as specified in
    * https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3-PROBE-Extensions#probe-extension-for-redirection
    */
-  boost::optional<std::vector<std::shared_ptr<security::v2::Certificate>>> m_redirection;
+  boost::optional<std::vector<std::shared_ptr<security::Certificate>>> m_redirection;
   /**
    * StatusUpdate Callback function
    */
diff --git a/src/identity-challenge/challenge-credential.cpp b/src/identity-challenge/challenge-credential.cpp
index f6e26c2..0d171e4 100644
--- a/src/identity-challenge/challenge-credential.cpp
+++ b/src/identity-challenge/challenge-credential.cpp
@@ -65,7 +65,7 @@
   auto it = anchorList.begin();
   for (; it != anchorList.end(); it++) {
     std::istringstream ss(it->second.get("certificate", ""));
-    auto cert = io::load<security::v2::Certificate>(ss);
+    auto cert = io::load<security::Certificate>(ss);
     if (cert == nullptr) {
       _LOG_ERROR("Cannot load the certificate from config file");
       continue;
@@ -82,7 +82,7 @@
   if (m_trustAnchors.empty()) {
     parseConfigFile();
   }
-  security::v2::Certificate credential;
+  security::Certificate credential;
   const uint8_t* signature;
   size_t signatureLen;
   const auto& elements = params.elements();
@@ -105,7 +105,7 @@
   }
 
   // verify the credential and the self-signed cert
-  Name signingKeyName = credential.getSignature().getKeyLocator().getName();
+  Name signingKeyName = credential.getSignatureInfo().getKeyLocator().getName();
   security::transform::PublicKey key;
   const auto& pubKeyBuffer = credential.getPublicKey();
   key.loadPkcs8(pubKeyBuffer.data(), pubKeyBuffer.size());
@@ -176,8 +176,8 @@
                                        KeyChain& keyChain, const Name& issuedCertName, const std::string& requestId)
 {
   auto& pib = keyChain.getPib();
-  auto id = pib.getIdentity(security::v2::extractIdentityFromCertName(issuedCertName));
-  auto issuedCert = id.getKey(security::v2::extractKeyNameFromCertName(issuedCertName)).getCertificate(issuedCertName);
+  auto id = pib.getIdentity(security::extractIdentityFromCertName(issuedCertName));
+  auto issuedCert = id.getKey(security::extractKeyNameFromCertName(issuedCertName)).getCertificate(issuedCertName);
   auto issuedCertTlv = issuedCert.wireEncode();
   auto signatureTlv = keyChain.sign((uint8_t*)requestId.c_str(), requestId.length(), security::signingByCertificate(issuedCertName));
   for (auto& item : params) {
diff --git a/src/identity-challenge/challenge-credential.hpp b/src/identity-challenge/challenge-credential.hpp
index 2c0229b..49670f6 100644
--- a/src/identity-challenge/challenge-credential.hpp
+++ b/src/identity-challenge/challenge-credential.hpp
@@ -76,7 +76,7 @@
   parseConfigFile();
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-  std::list<security::v2::Certificate> m_trustAnchors;
+  std::list<security::Certificate> m_trustAnchors;
   std::string m_configFile;
 };
 
diff --git a/src/ndncert-common.hpp b/src/ndncert-common.hpp
index c77cedb..a1077cc 100644
--- a/src/ndncert-common.hpp
+++ b/src/ndncert-common.hpp
@@ -47,7 +47,7 @@
 #include <ndn-cxx/lp/nack.hpp>
 #include <ndn-cxx/name.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/v2/certificate.hpp>
+#include <ndn-cxx/security/certificate.hpp>
 #include <ndn-cxx/util/logger.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/assert.hpp>
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
index 7c0e449..58e8fc3 100644
--- a/src/protocol-detail/info.cpp
+++ b/src/protocol-detail/info.cpp
@@ -24,13 +24,13 @@
 namespace ndncert {
 
 Block
-INFO::encodeDataContent(const CaProfile& caConfig, const security::v2::Certificate& certificate)
+INFO::encodeDataContent(const CaProfile& caConfig, const security::Certificate& certificate)
 {
   auto content = makeEmptyBlock(tlv::Content);
   content.push_back(makeNestedBlock(tlv_ca_prefix, caConfig.m_caPrefix));
   std::string caInfo = "";
   if (caConfig.m_caInfo == "") {
-    caInfo = "Issued by " + certificate.getSignature().getKeyLocator().getName().toUri();
+    caInfo = "Issued by " + certificate.getSignatureInfo().getKeyLocator().getName().toUri();
   }
   else {
     caInfo = caConfig.m_caInfo;
@@ -73,7 +73,7 @@
       break;
     case tlv_ca_certificate:
       item.parse();
-      result.m_cert = std::make_shared<security::v2::Certificate>(item.get(tlv::Data));
+      result.m_cert = std::make_shared<security::Certificate>(item.get(tlv::Data));
       break;
     default:
       continue;
diff --git a/src/protocol-detail/info.hpp b/src/protocol-detail/info.hpp
index 571d120..d34c0a2 100644
--- a/src/protocol-detail/info.hpp
+++ b/src/protocol-detail/info.hpp
@@ -32,7 +32,7 @@
    * Encode CA configuration and its certificate into a TLV block as INFO Data packet content.
    */
   static Block
-  encodeDataContent(const CaProfile& caConfig, const security::v2::Certificate& certificate);
+  encodeDataContent(const CaProfile& caConfig, const security::Certificate& certificate);
 
   /**
    * Decode CA configuration from the TLV block of INFO Data packet content.
diff --git a/src/protocol-detail/new-renew-revoke.cpp b/src/protocol-detail/new-renew-revoke.cpp
index b368c8c..3ce3ac0 100644
--- a/src/protocol-detail/new-renew-revoke.cpp
+++ b/src/protocol-detail/new-renew-revoke.cpp
@@ -31,7 +31,7 @@
 _LOG_INIT(ndncert.encoding.new_renew_revoke);
 
 Block
-NEW_RENEW_REVOKE::encodeApplicationParameters(RequestType requestType, const std::string& ecdhPub, const security::v2::Certificate& certRequest)
+NEW_RENEW_REVOKE::encodeApplicationParameters(RequestType requestType, const std::string& ecdhPub, const security::Certificate& certRequest)
 {
   Block request = makeEmptyBlock(tlv::ApplicationParameters);
   std::stringstream ss;
@@ -57,7 +57,7 @@
 
 void
 NEW_RENEW_REVOKE::decodeApplicationParameters(const Block& payload, RequestType requestType, std::string& ecdhPub,
-                                              shared_ptr<security::v2::Certificate>& clientCert) {
+                                              shared_ptr<security::Certificate>& clientCert) {
   payload.parse();
 
   ecdhPub = readString(payload.get(tlv_ecdh_pub));
@@ -70,8 +70,8 @@
   }
   requestPayload.parse();
 
-  security::v2::Certificate cert = security::v2::Certificate(requestPayload.get(tlv::Data));
-  clientCert = make_shared<security::v2::Certificate>(cert);
+  security::Certificate cert = security::Certificate(requestPayload.get(tlv::Data));
+  clientCert = make_shared<security::Certificate>(cert);
 }
 
 Block
diff --git a/src/protocol-detail/new-renew-revoke.hpp b/src/protocol-detail/new-renew-revoke.hpp
index de5d558..f9710b8 100644
--- a/src/protocol-detail/new-renew-revoke.hpp
+++ b/src/protocol-detail/new-renew-revoke.hpp
@@ -29,10 +29,10 @@
 class NEW_RENEW_REVOKE {
 public:
   static Block
-  encodeApplicationParameters(RequestType requestType, const std::string& ecdhPub, const security::v2::Certificate& certRequest);
+  encodeApplicationParameters(RequestType requestType, const std::string& ecdhPub, const security::Certificate& certRequest);
 
   static void
-  decodeApplicationParameters(const Block& block, RequestType requestType, std::string& ecdhPub, shared_ptr<security::v2::Certificate>& certRequest);
+  decodeApplicationParameters(const Block& block, RequestType requestType, std::string& ecdhPub, shared_ptr<security::Certificate>& certRequest);
 
   static Block
   encodeDataContent(const std::string& ecdhKey, const std::string& salt,
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index d2f9e7e..b0ac75c 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -50,7 +50,7 @@
 
 Block
 PROBE::encodeDataContent(const std::vector<Name>& identifiers, boost::optional<size_t> maxSuffixLength,
-                         boost::optional<std::vector<std::shared_ptr<security::v2::Certificate>>> redirectionItems)
+                         boost::optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems)
 {
   Block content = makeEmptyBlock(tlv::Content);
   for (const auto& name : identifiers) {
diff --git a/src/protocol-detail/probe.hpp b/src/protocol-detail/probe.hpp
index 6e19bab..7d61461 100644
--- a/src/protocol-detail/probe.hpp
+++ b/src/protocol-detail/probe.hpp
@@ -40,7 +40,7 @@
   static Block
   encodeDataContent(const std::vector<Name>& identifiers,
                     boost::optional<size_t> maxSuffixLength = boost::none,
-                    boost::optional<std::vector<std::shared_ptr<security::v2::Certificate>>> redirectionItems = boost::none);
+                    boost::optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems = boost::none);
 
   static std::vector<std::tuple<std::string, std::string>>
   decodeApplicationParameters(const Block& block);
diff --git a/src/requester.cpp b/src/requester.cpp
index 22c9d27..0b5a6c5 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -40,7 +40,7 @@
 
 _LOG_INIT(ndncert.client);
 
-RequesterState::RequesterState(security::v2::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType)
+RequesterState::RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType)
   : m_caItem(caItem)
   , m_keyChain(keyChain)
   , m_type(requestType)
@@ -85,7 +85,7 @@
 {
   auto caItem = INFO::decodeDataContent(reply.getContent());
   auto certBlock = caItem.m_cert->wireEncode();
-  caItem.m_cert = std::make_shared<security::v2::Certificate>(certBlock);
+  caItem.m_cert = std::make_shared<security::Certificate>(certBlock);
   if (caItem.m_cert->getFullName() != caCertFullName) {
     _LOG_ERROR("Ca profile does not match the certificate information offered by the original CA.");
     BOOST_THROW_EXCEPTION(std::runtime_error("Cannot verify replied Data packet signature."));
@@ -156,7 +156,7 @@
   auto& keyName = state.m_keyPair.getName();
 
   // generate certificate request
-  security::v2::Certificate certRequest;
+  security::Certificate certRequest;
   certRequest.setName(Name(keyName).append("cert-request").appendVersion());
   certRequest.setContentType(tlv::ContentType_Key);
   certRequest.setContent(state.m_keyPair.getPublicKey().data(), state.m_keyPair.getPublicKey().size());
@@ -179,7 +179,7 @@
 }
 
 shared_ptr<Interest>
-Requester::genRevokeInterest(RequesterState& state, const security::v2::Certificate& certificate)
+Requester::genRevokeInterest(RequesterState& state, const security::Certificate& certificate)
 {
   if (!state.m_caItem.m_caPrefix.isPrefixOf(certificate.getName())) {
     return nullptr;
@@ -290,11 +290,11 @@
   return interest;
 }
 
-shared_ptr<security::v2::Certificate>
+shared_ptr<security::Certificate>
 Requester::onCertFetchResponse(const Data& reply)
 {
   try {
-    return std::make_shared<security::v2::Certificate>(reply);
+    return std::make_shared<security::Certificate>(reply);
   }
   catch (const std::exception& e) {
     _LOG_ERROR("Cannot parse replied certificate ");
diff --git a/src/requester.hpp b/src/requester.hpp
index c6510b1..1b64d4b 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -34,7 +34,7 @@
 
 struct RequesterState {
   explicit
-  RequesterState(security::v2::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType);
+  RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType);
 
   /**
    * The CA profile for this request.
@@ -43,7 +43,7 @@
   /**
    * The local keychain to generate and install identities, keys and certificates
    */
-  security::v2::KeyChain& m_keyChain;
+  security::KeyChain& m_keyChain;
   /**
    * The type of request. Either NEW, RENEW, or REVOKE.
    */
@@ -181,7 +181,7 @@
    * @return The shared pointer to the encoded interest.
    */
   static shared_ptr<Interest>
-  genRevokeInterest(RequesterState& state, const security::v2::Certificate& certificate);
+  genRevokeInterest(RequesterState& state, const security::Certificate& certificate);
 
   /**
    * Decodes the replied data of NEW, RENEW, or REVOKE interest from the CA.
@@ -236,7 +236,7 @@
    * @param reply, the data replied from the certificate fetch interest.
    * @return The shared pointer to the certificate being fetched.
    */
-  static shared_ptr<security::v2::Certificate>
+  static shared_ptr<security::Certificate>
   onCertFetchResponse(const Data& reply);
 
   /**