Probe: make probe a token for better security

Change-Id: I079d70146b3e5c22e789d2ed754018fe562ddd6c
diff --git a/src/client-module.cpp b/src/client-module.cpp
index 5b03a23..29898bc 100644
--- a/src/client-module.cpp
+++ b/src/client-module.cpp
@@ -89,7 +89,7 @@
   auto interest = make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
   interest->setCanBePrefix(false);
-  auto paramJson = genProbeRequestJson(probeInfo);
+  auto paramJson = genProbeRequestJson(ca, probeInfo);
   interest->setApplicationParameters(paramFromJson(paramJson));
 
   // update local state
@@ -305,10 +305,38 @@
 }
 
 const JsonSection
-ClientModule::genProbeRequestJson(const std::string& probeInfo)
+ClientModule::genProbeRequestJson(const ClientCaItem& ca, const std::string& probeInfo)
 {
+  std::string delimiter = ":";
+  size_t last = 0;
+  size_t next = 0;
+
   JsonSection root;
-  root.put(JSON_CLIENT_PROBE_INFO, probeInfo);
+
+  std::vector<std::string> fields;
+  while ((next = ca.m_probe.find(delimiter, last)) != std::string::npos) {
+    fields.push_back(ca.m_probe.substr(last, next - last));
+    last = next + 1;
+  }
+  fields.push_back(ca.m_probe.substr(last));
+
+  std::vector<std::string> arguments;
+  last = 0;
+  next = 0;
+  while ((next = probeInfo.find(delimiter, last)) != std::string::npos) {
+    arguments.push_back(probeInfo.substr(last, next - last));
+    last = next + 1;
+  }
+  arguments.push_back(probeInfo.substr(last));
+
+  if (arguments.size() != fields.size()) {
+    BOOST_THROW_EXCEPTION(Error("Error in genProbeRequestJson: argument list does not match field list in the config file."));
+  }
+
+  for (size_t i = 0; i < fields.size(); ++i) {
+      root.put(fields.at(i), arguments.at(i));
+  }
+
   return root;
 }