list func: update client config format

Change-Id: I147444d4b57dc360d6994ca9fe4f844139db777c
diff --git a/client.conf.sample b/client.conf.sample
index 3c5513a..f9135ee 100644
--- a/client.conf.sample
+++ b/client.conf.sample
@@ -2,14 +2,11 @@
   "ca-list":
   [
     {
-        "ca-prefix": "/example/CA",
-        "ca-info": "example",
-        "probe": "example",
-        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F",
-        "supported-challenges":
-        [
-            { "type": "PIN" }
-        ]
+        "ca-prefix": "/ndn/CA",
+        "ca-info": "NDN Testbed CA",
+        "probe": "Use the university/organization name as input",
+        "target-list": "Use your email address (edu preferred) as input",
+        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
     }
   ]
 }
\ No newline at end of file
diff --git a/src/client-config.cpp b/src/client-config.cpp
index 7fd5280..116e1d8 100644
--- a/src/client-config.cpp
+++ b/src/client-config.cpp
@@ -27,54 +27,42 @@
 void
 ClientConfig::load(const std::string& fileName)
 {
+  JsonSection config;
   try {
-    boost::property_tree::read_json(fileName, m_config);
+    boost::property_tree::read_json(fileName, config);
   }
   catch (const boost::property_tree::info_parser_error& error) {
     BOOST_THROW_EXCEPTION(Error("Failed to parse configuration file " + fileName +
                                 " " + error.message() + " line " + std::to_string(error.line())));
   }
 
-  if (m_config.begin() == m_config.end()) {
+  if (config.begin() == config.end()) {
     BOOST_THROW_EXCEPTION(Error("Error processing configuration file: " + fileName + " no data"));
   }
 
-  parse();
+  load(config);
 }
 
 void
-ClientConfig::parse()
+ClientConfig::load(const JsonSection& configSection)
 {
   m_caItems.clear();
-  auto caList = m_config.get_child("ca-list");
+  auto caList = configSection.get_child("ca-list");
   auto it = caList.begin();
   for (; it != caList.end(); it++) {
     ClientCaItem item;
     item.m_caName = Name(it->second.get<std::string>("ca-prefix"));
     item.m_caInfo = it->second.get<std::string>("ca-info");
     item.m_probe = it->second.get("probe", "");
+    item.m_targetedList = it->second.get("target-list", "");
 
     std::istringstream ss(it->second.get<std::string>("certificate"));
     item.m_anchor = *(io::load<security::v2::Certificate>(ss));
 
-    auto challengeList = it->second.get_child("supported-challenges");
-    item.m_supportedChallenges = parseChallengeList(challengeList);
-
     m_caItems.push_back(item);
   }
 }
 
-std::list<std::string>
-ClientConfig::parseChallengeList(const JsonSection& section)
-{
-  std::list<std::string> result;
-  auto it = section.begin();
-  for (; it != section.end(); it++) {
-    result.push_back(it->second.get<std::string>("type"));
-  }
-  return result;
-}
-
 void
 ClientConfig::addNewCaItem(const ClientCaItem& item)
 {
diff --git a/src/client-config.hpp b/src/client-config.hpp
index 8234c01..e32eab3 100644
--- a/src/client-config.hpp
+++ b/src/client-config.hpp
@@ -27,16 +27,33 @@
 namespace ndn {
 namespace ndncert {
 
+/**
+ * @brief The configuration for a trusted CA from a requester's perspective
+ */
 class ClientCaItem
 {
 public:
+  // The identity name of the CA. Extracted from config field "ca-prefix"
   Name m_caName;
+
+  // TODO: remove the caInfo, probe, and targetedList. Put them into the cert
+  // A brief introduction to the CA. Extracted from config field "ca-info"
   std::string m_caInfo;
+  // An instruction for requesters to use _PROBE. Extracted from config field "probe"
   std::string m_probe;
-  std::list<std::string> m_supportedChallenges;
+  // An instruction for requesters to get a recommended CA. Extracted from config field "target-list"
+  std::string m_targetedList;
+
+  // CA's certificate
   security::v2::Certificate m_anchor;
 };
 
+/**
+ * @brief Represents Client configuration
+ *
+ * For Client configuration format, please refer to:
+ *   https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
+ */
 class ClientConfig
 {
 public:
@@ -51,18 +68,14 @@
   load(const std::string& fileName);
 
   void
+  load(const JsonSection& configSection);
+
+  void
   addNewCaItem(const ClientCaItem& item);
 
   void
   removeCaItem(const Name& caName);
 
-PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-  void
-  parse();
-
-  std::list<std::string>
-  parseChallengeList(const JsonSection& section);
-
 public:
   std::list<ClientCaItem> m_caItems;
 
diff --git a/tests/unit-tests/client-config.t.cpp b/tests/unit-tests/client-config.t.cpp
index e1ad082..9e03da0 100644
--- a/tests/unit-tests/client-config.t.cpp
+++ b/tests/unit-tests/client-config.t.cpp
@@ -18,9 +18,10 @@
  * See AUTHORS.md for complete list of ndncert authors and contributors.
  */
 
-#include "boost-test.hpp"
 #include "client-config.hpp"
 
+#include "boost-test.hpp"
+
 namespace ndn {
 namespace ndncert {
 namespace tests {
@@ -37,8 +38,7 @@
   BOOST_CHECK_EQUAL(item.m_caName.toUri(), "/ndn/edu/ucla/CA");
   BOOST_CHECK_EQUAL(item.m_caInfo, "UCLA's ceritificate authority, located in BH4805.");
   BOOST_CHECK_EQUAL(item.m_probe, "Please use your email address to apply a namespace first. UCLA email is preferred.");
-  BOOST_CHECK_EQUAL(item.m_supportedChallenges.size(), 2);
-  BOOST_CHECK_EQUAL(item.m_supportedChallenges.front(), "PIN");
+  BOOST_CHECK_EQUAL(item.m_targetedList, "Use your email address (edu preferred) as input");
   BOOST_CHECK_EQUAL(item.m_anchor.getName().toUri(),
                     "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
 }
@@ -52,9 +52,6 @@
   item.m_caName = Name("/test");
   item.m_caInfo = "test";
   item.m_probe = "test";
-  std::list<std::string> list;
-  list.push_back("TEST");
-  item.m_supportedChallenges = list;
 
   config.addNewCaItem(item);
   BOOST_CHECK_EQUAL(config.m_caItems.size(), 3);
diff --git a/tests/unit-tests/client.conf.test b/tests/unit-tests/client.conf.test
index 7c2dbf1..222d6c5 100644
--- a/tests/unit-tests/client.conf.test
+++ b/tests/unit-tests/client.conf.test
@@ -4,22 +4,14 @@
     {
         "ca-prefix": "/ndn/edu/ucla/CA",
         "ca-info": "UCLA's ceritificate authority, located in BH4805.",
+        "target-list": "Use your email address (edu preferred) as input",
         "probe": "Please use your email address to apply a namespace first. UCLA email is preferred.",
-        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F",
-        "supported-challenges":
-        [
-            { "type": "PIN" },
-            { "type": "EMAIL" }
-        ]
+        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
     },
     {
         "ca-prefix": "/ndn/edu/ucla/zhiyi/CA",
         "ca-info": "Zhiyi's own ceritificate authority",
-        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F",
-        "supported-challenges":
-        [
-            { "type": "PIN" }
-        ]
+        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
     }
   ]
 }
\ No newline at end of file