add namespace for requester

Change-Id: I3de037dffd702edff9f87a87e8e684161db3d329
diff --git a/src/configuration.cpp b/src/configuration.cpp
index b400a2f..5b01efc 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -185,6 +185,8 @@
 
 } // namespace ca
 
+namespace requester {
+
 void
 RequesterCaCache::load(const std::string& fileName)
 {
@@ -249,5 +251,6 @@
   m_caItems.push_back(profile);
 }
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
diff --git a/src/configuration.hpp b/src/configuration.hpp
index d13397c..3671e20 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -142,6 +142,8 @@
 
 } // namespace ca
 
+namespace requester {
+
 /**
  * @brief Represents Client configuration
  *
@@ -178,6 +180,7 @@
   std::list<CaProfile> m_caItems;
 };
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
 
diff --git a/src/detail/challenge-encoder.cpp b/src/detail/challenge-encoder.cpp
index f3ebb5a..fed4110 100644
--- a/src/detail/challenge-encoder.cpp
+++ b/src/detail/challenge-encoder.cpp
@@ -40,7 +40,7 @@
 }
 
 void
-ChallengeEncoder::decodeDataContent(const Block& data, RequesterState& state)
+ChallengeEncoder::decodeDataContent(const Block& data, requester::RequesterState& state)
 {
   data.parse();
   state.m_status = static_cast<Status>(readNonNegativeInteger(data.get(tlv::Status)));
diff --git a/src/detail/challenge-encoder.hpp b/src/detail/challenge-encoder.hpp
index b47938e..541ad60 100644
--- a/src/detail/challenge-encoder.hpp
+++ b/src/detail/challenge-encoder.hpp
@@ -34,7 +34,7 @@
   encodeDataContent(const ca::RequestState& request);
 
   static void
-  decodeDataContent(const Block& data, RequesterState& state);
+  decodeDataContent(const Block& data, requester::RequesterState& state);
 };
 
 } // namespace ndncert
diff --git a/src/requester-state.cpp b/src/requester-state.cpp
index 4cb448b..0c4755d 100644
--- a/src/requester-state.cpp
+++ b/src/requester-state.cpp
@@ -22,6 +22,7 @@
 
 namespace ndn {
 namespace ndncert {
+namespace requester {
 
 RequesterState::RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType)
   : m_caItem(caItem)
@@ -30,5 +31,6 @@
 {
 }
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
\ No newline at end of file
diff --git a/src/requester-state.hpp b/src/requester-state.hpp
index fed7743..a6f1028 100644
--- a/src/requester-state.hpp
+++ b/src/requester-state.hpp
@@ -27,6 +27,7 @@
 
 namespace ndn {
 namespace ndncert {
+namespace requester {
 
 struct RequesterState {
   explicit
@@ -99,6 +100,7 @@
   bool m_isNewlyCreatedKey = false;
 };
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
 
diff --git a/src/requester.cpp b/src/requester.cpp
index af3f6c4..b0f65d5 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -38,6 +38,7 @@
 
 namespace ndn {
 namespace ndncert {
+namespace requester {
 
 NDN_LOG_INIT(ndncert.client);
 
@@ -73,7 +74,6 @@
   return caItem;
 }
 
-
 optional<CaProfile>
 Requester::onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName)
 {
@@ -324,5 +324,6 @@
                                " and Error Info: " + std::get<1>(errorInfo)));
 }
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
diff --git a/src/requester.hpp b/src/requester.hpp
index cb3d10d..fddd35b 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -25,10 +25,7 @@
 
 namespace ndn {
 namespace ndncert {
-
-// TODO
-// For each RequesterState, create a validator instance and initialize it with CA's cert
-// The validator instance should be in CaProfile
+namespace requester {
 
 class Requester : noncopyable
 {
@@ -206,6 +203,7 @@
   processIfError(const Data& data);
 };
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
 
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 9dcab39..5e48bc8 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -103,8 +103,8 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
-  auto newInterest = Requester::genNewInterest(state, Name("/ndn/alice"),
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
+  auto newInterest = requester::Requester::genNewInterest(state, Name("/ndn/alice"),
                                                time::system_clock::now(),
                                                time::system_clock::now() + time::days(1));
 
@@ -119,40 +119,40 @@
   face.onSendData.connect([&](const Data& response) {
     if (Name("/ndn/CA/NEW").isPrefixOf(response.getName())) {
       // std::cout << "NEW Data Size: " << response.wireEncode().size() << std::endl;
-      auto challengeList = Requester::onNewRenewRevokeResponse(state, response);
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
-      challengeInterest = Requester::genChallengeInterest(state, std::move(paramList));
+      auto challengeList = requester::Requester::onNewRenewRevokeResponse(state, response);
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
+      challengeInterest = requester::Requester::genChallengeInterest(state, std::move(paramList));
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 0) {
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
 
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::CHALLENGE);
       BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::NEED_CODE);
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
-      challengeInterest2 = Requester::genChallengeInterest(state, std::move(paramList));
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
+      challengeInterest2 = requester::Requester::genChallengeInterest(state, std::move(paramList));
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 1) {
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
 
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::CHALLENGE);
       BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::WRONG_CODE);
 
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
       auto request = ca.getCertificateRequest(*challengeInterest2);
       auto secret = request->m_challengeState->m_secrets.get(ChallengePin::PARAMETER_KEY_CODE, "");
       std::get<1>(paramList[0]) = secret;
-      challengeInterest3 = Requester::genChallengeInterest(state, std::move(paramList));
+      challengeInterest3 = requester::Requester::genChallengeInterest(state, std::move(paramList));
       // std::cout << "CHALLENGE Interest Size: " << challengeInterest3->wireEncode().size() << std::endl;
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
       // std::cout << "CHALLENGE Data Size: " << response.wireEncode().size() << std::endl;
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::SUCCESS);
     }
   });
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 69d87d5..ab8f440 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -231,8 +231,8 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
-  auto interest = Requester::genNewInterest(state, Name("/ndn/zhiyi"),
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
+  auto interest = requester::Requester::genNewInterest(state, Name("/ndn/zhiyi"),
                                             time::system_clock::now(),
                                             time::system_clock::now() + time::days(1));
 
@@ -256,7 +256,7 @@
 
     BOOST_CHECK(challengeBlockCount != 0);
 
-    auto challengeList = Requester::onNewRenewRevokeResponse(state, response);
+    auto challengeList = requester::Requester::onNewRenewRevokeResponse(state, response);
     RequestID requestId;
     std::memcpy(requestId.data(), contentBlock.get(tlv::RequestId).value(), contentBlock.get(tlv::RequestId).value_size());
     auto ca_encryption_key = ca.getCaStorage()->getRequest(requestId).m_encryptionKey;
@@ -282,11 +282,11 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
   auto current_tp = time::system_clock::now();
-  auto interest1 = Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp, current_tp - time::hours(1));
-  auto interest2 = Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp, current_tp + time::days(361));
-  auto interest3 = Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp - time::hours(1), current_tp + time::hours(2));
+  auto interest1 = requester::Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp, current_tp - time::hours(1));
+  auto interest2 = requester::Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp, current_tp + time::days(361));
+  auto interest3 = requester::Requester::genNewInterest(state, Name("/ndn/zhiyi"), current_tp - time::hours(1), current_tp + time::hours(2));
   face.onSendData.connect([&](const Data& response) {
     auto contentTlv = response.getContent();
     contentTlv.parse();
@@ -313,13 +313,13 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
 
-  auto interest1 = Requester::genNewInterest(state, Name("/ndn/a"), time::system_clock::now(),
+  auto interest1 = requester::Requester::genNewInterest(state, Name("/ndn/a"), time::system_clock::now(),
                                               time::system_clock::now() + time::days(1));
-  auto interest2 = Requester::genNewInterest(state, Name("/ndn/a/b"), time::system_clock::now(),
+  auto interest2 = requester::Requester::genNewInterest(state, Name("/ndn/a/b"), time::system_clock::now(),
                                               time::system_clock::now() + time::days(1));
-  auto interest3 = Requester::genNewInterest(state, Name("/ndn/a/b/c/d"), time::system_clock::now(),
+  auto interest3 = requester::Requester::genNewInterest(state, Name("/ndn/a/b/c/d"), time::system_clock::now(),
                                               time::system_clock::now() + time::days(1));
 
   face.onSendData.connect([&](const Data& response) {
@@ -354,11 +354,11 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
 
   auto current_tp = time::system_clock::now();
-  auto interest1 = Requester::genNewInterest(state, Name("/ndn"), current_tp, current_tp + time::days(1));
-  auto interest2 = Requester::genNewInterest(state, Name("/ndn/a/b/c/d"), current_tp, current_tp + time::days(1));
+  auto interest1 = requester::Requester::genNewInterest(state, Name("/ndn"), current_tp, current_tp + time::days(1));
+  auto interest2 = requester::Requester::genNewInterest(state, Name("/ndn/a/b/c/d"), current_tp, current_tp + time::days(1));
   face.onSendData.connect([&](const Data& response) {
     auto contentTlv = response.getContent();
     contentTlv.parse();
@@ -385,9 +385,9 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
 
-  auto newInterest = Requester::genNewInterest(state, Name("/ndn/zhiyi"), time::system_clock::now(),
+  auto newInterest = requester::Requester::genNewInterest(state, Name("/ndn/zhiyi"), time::system_clock::now(),
                                                 time::system_clock::now() + time::days(1));
 
   // generate CHALLENGE Interest
@@ -398,38 +398,38 @@
   int count = 0;
   face.onSendData.connect([&](const Data& response) {
     if (Name("/ndn/CA/NEW").isPrefixOf(response.getName())) {
-      auto challengeList = Requester::onNewRenewRevokeResponse(state, response);
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
-      challengeInterest = Requester::genChallengeInterest(state, std::move(paramList));
+      auto challengeList = requester::Requester::onNewRenewRevokeResponse(state, response);
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
+      challengeInterest = requester::Requester::genChallengeInterest(state, std::move(paramList));
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 0) {
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
 
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::CHALLENGE);
       BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::NEED_CODE);
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
-      challengeInterest2 = Requester::genChallengeInterest(state, std::move(paramList));
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
+      challengeInterest2 = requester::Requester::genChallengeInterest(state, std::move(paramList));
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 1) {
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
 
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::CHALLENGE);
       BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::WRONG_CODE);
 
-      auto paramList = Requester::selectOrContinueChallenge(state, "pin");
+      auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
       auto request = ca.getCertificateRequest(*challengeInterest2);
       auto secret = request->m_challengeState->m_secrets.get(ChallengePin::PARAMETER_KEY_CODE, "");
       std::get<1>(paramList[0]) = secret;
-      challengeInterest3 = Requester::genChallengeInterest(state, std::move(paramList));
+      challengeInterest3 = requester::Requester::genChallengeInterest(state, std::move(paramList));
     }
     else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
       count++;
       BOOST_CHECK(security::verifySignature(response, cert));
-      Requester::onChallengeResponse(state, response);
+      requester::Requester::onChallengeResponse(state, response);
       BOOST_CHECK(state.m_status == Status::SUCCESS);
     }
   });
@@ -474,9 +474,9 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::REVOKE);
+  requester::RequesterState state(m_keyChain, item, RequestType::REVOKE);
 
-  auto interest = Requester::genRevokeInterest(state, issuedCert);
+  auto interest = requester::Requester::genRevokeInterest(state, issuedCert);
 
   int count = 0;
   face.onSendData.connect([&](const Data& response) {
@@ -498,7 +498,7 @@
 
     BOOST_CHECK(challengeBlockCount != 0);
 
-    auto challengeList = Requester::onNewRenewRevokeResponse(state, response);
+    auto challengeList = requester::Requester::onNewRenewRevokeResponse(state, response);
     RequestID requestId;
     std::memcpy(requestId.data(), contentBlock.get(tlv::RequestId).value(), contentBlock.get(tlv::RequestId).value_size());
     auto ca_encryption_key = ca.getCaStorage()->getRequest(requestId).m_encryptionKey;
@@ -537,9 +537,9 @@
   CaProfile item;
   item.m_caPrefix = Name("/ndn");
   item.m_cert = std::make_shared<security::Certificate>(cert);
-  RequesterState state(m_keyChain, item, RequestType::NEW);
+  requester::RequesterState state(m_keyChain, item, RequestType::NEW);
 
-  auto interest = Requester::genRevokeInterest(state, clientCert);
+  auto interest = requester::Requester::genRevokeInterest(state, clientCert);
 
   bool receiveData = false;
   face.onSendData.connect([&](const Data& response) {
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 1957338..f3540fd 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -91,7 +91,7 @@
 
 BOOST_AUTO_TEST_CASE(RequesterCaCacheFile)
 {
-  RequesterCaCache config;
+  requester::RequesterCaCache config;
   config.load("tests/unit-tests/config-files/config-client-1");
   BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
 
@@ -117,7 +117,7 @@
 
 BOOST_AUTO_TEST_CASE(RequesterCaCacheFileWithErrors)
 {
-  RequesterCaCache config;
+  requester::RequesterCaCache config;
   // nonexistent file
   BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/Nonexist"), std::runtime_error);
   // missing certificate
@@ -128,7 +128,7 @@
 
 BOOST_AUTO_TEST_CASE(RequesterCaCacheFileAddAndremoveCaProfile)
 {
-  RequesterCaCache config;
+  requester::RequesterCaCache config;
   config.load("tests/unit-tests/config-files/config-client-1");
 
   CaProfile item;
diff --git a/tests/unit-tests/requester.t.cpp b/tests/unit-tests/requester.t.cpp
index c67b8fe..16197b4 100644
--- a/tests/unit-tests/requester.t.cpp
+++ b/tests/unit-tests/requester.t.cpp
@@ -29,6 +29,8 @@
 namespace ndncert {
 namespace tests {
 
+using namespace requester;
+
 BOOST_FIXTURE_TEST_SUITE(TestRequester, IdentityManagementTimeFixture)
 
 /* PROBE */
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 0807edc..18520c8 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -29,6 +29,7 @@
 
 namespace ndn {
 namespace ndncert {
+namespace requester {
 
 static void
 selectCaProfile(std::string configFilePath);
@@ -479,11 +480,12 @@
   return 0;
 }
 
+} // namespace requester
 } // namespace ndncert
 } // namespace ndn
 
 int
 main(int argc, char* argv[])
 {
-  return ndn::ndncert::main(argc, argv);
+  return ndn::ndncert::requester::main(argc, argv);
 }