nail down CA info (will broke some unit tests for now. Test failures will be fixed when PROBE is finished.)

Change-Id: Ie503b42d302da5d426701a36b3212d4ed063dfd5
diff --git a/src/ca-config.hpp b/src/ca-config.hpp
index 5cba37f..4855aca 100644
--- a/src/ca-config.hpp
+++ b/src/ca-config.hpp
@@ -32,13 +32,13 @@
 /**
  * @brief The name assignment function provided by the CA operator to generate available
  * namecomponents.
- * The function does not guarantee that all the returned names are available. Therefore the 
+ * The function does not guarantee that all the returned names are available. Therefore the
  * CA should further check the availability of each returned name and remove unavailable results.
  *
  * @p vector, input, a list of parameter key-value pair used for name assignment.
  * @return a vector containing the possible namespaces derived from the parameters.
  */
-using ProbeHandler = function<std::string /*identity name*/ (const Block& tlv /*requester input*/)>;
+// using ProbeHandler = function<std::string /*identity name*/ (const Block& tlv /*requester input*/)>;
 using NameAssignmentFunc = function<std::vector<std::string>(const std::vector<std::tuple<std::string, std::string>>)>;
 
 /**
@@ -99,10 +99,10 @@
   /**
    * Set the NameAssignmentFunction.
    */
-  void
-  setNameAssignmentFunc(const NameAssignmentFunc& nameAssignmentFunc) {
-    m_nameAssignmentFunc = nameAssignmentFunc;
-  }
+  // void
+  // setNameAssignmentFunc(const NameAssignmentFunc& nameAssignmentFunc) {
+  //   m_nameAssignmentFunc = nameAssignmentFunc;
+  // }
 
   /**
    * Set the StatusUpdateCallback.
@@ -152,21 +152,6 @@
    * StatusUpdate Callback function
    */
   StatusUpdateCallback m_statusUpdateCallback;
-
-  //====================old
-
-  // basic info
-  Name m_caName;
-
-  // essential config
-  time::seconds m_freshnessPeriod;
-  time::days m_validityPeriod;
-
-  // optional parameters
-  std::string m_probe;
-
-  // callbacks
-  ProbeHandler m_probeHandler;
 };
 
 }  // namespace ndncert
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 9e9bf61..47ab755 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -111,11 +111,10 @@
   m_registeredPrefixHandles.push_back(prefixId);
 }
 
-bool
-CaModule::setProbeHandler(const ProbeHandler& handler)
+void
+CaModule::setNameAssignmentFunction(const NameAssignmentFunc& handler)
 {
-  m_config.m_probeHandler = handler;
-  return false;
+  m_config.m_nameAssignmentFunc = handler;
 }
 
 bool
@@ -187,40 +186,40 @@
   _LOG_TRACE("Received PROBE request");
 
   // process PROBE requests: find an available name
-  std::string availableId;
+  std::string availableId = "";
   const auto& parameterTLV = request.getApplicationParameters();
   parameterTLV.parse();
   if (!parameterTLV.hasValue()) {
     _LOG_ERROR("Empty TLV obtained from the Interest parameter.");
     return;
   }
-  //std::string probeInfoStr = parameterJson.get(JSON_CLIENT_PROBE_INFO, "");
-  if (m_config.m_probeHandler) {
-    try {
-      availableId = m_config.m_probeHandler(parameterTLV);
-    }
-    catch (const std::exception& e) {
-      _LOG_TRACE("Cannot find PROBE input from PROBE parameters: " << e.what());
-      return;
-    }
-  }
-  else {
-    // if there is no app-specified name lookup, use a random name id
-    availableId = std::to_string(random::generateSecureWord64());
-  }
-  Name newIdentityName = m_config.m_caPrefix;
-  newIdentityName.append(availableId);
-  _LOG_TRACE("Handle PROBE: generate an identity " << newIdentityName);
 
-  Block contentTLV = PROBE::encodeDataContent(newIdentityName.toUri(), m_config.m_probe, parameterTLV);
+  // if (m_config.m_nameAssignmentFunc) {
+  //   try {
+  //     availableId = m_config.m_nameAssignmentFunc(parameterTLV);
+  //   }
+  //   catch (const std::exception& e) {
+  //     _LOG_TRACE("Cannot find PROBE input from PROBE parameters: " << e.what());
+  //     return;
+  //   }
+  // }
+  // else {
+  //   // if there is no app-specified name lookup, use a random name id
+  //   availableId = std::to_string(random::generateSecureWord64());
+  // }
+  // Name newIdentityName = m_config.m_caPrefix;
+  // newIdentityName.append(availableId);
+  // _LOG_TRACE("Handle PROBE: generate an identity " << newIdentityName);
 
-  Data result;
-  result.setName(request.getName());
-  result.setContent(contentTLV);
-  result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
-  m_keyChain.sign(result, signingByIdentity(m_config.m_caPrefix));
-  m_face.put(result);
-  _LOG_TRACE("Handle PROBE: send out the PROBE response");
+  // Block contentTLV = PROBE::encodeDataContent(newIdentityName.toUri(), m_config.m_probe, parameterTLV);
+
+  // Data result;
+  // result.setName(request.getName());
+  // result.setContent(contentTLV);
+  // result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
+  // m_keyChain.sign(result, signingByIdentity(m_config.m_caPrefix));
+  // m_face.put(result);
+  // _LOG_TRACE("Handle PROBE: send out the PROBE response");
 }
 
 void
@@ -302,7 +301,7 @@
     // verify the self-signed certificate, the request, and the token
     if (!m_config.m_caPrefix.isPrefixOf(clientCert->getName()) // under ca prefix
         || !security::v2::Certificate::isValidName(clientCert->getName()) // is valid cert name
-        || clientCert->getName().size() < m_config.m_caName.size() + IS_SUBNAME_MIN_OFFSET) {
+        || clientCert->getName().size() < m_config.m_caPrefix.size() + IS_SUBNAME_MIN_OFFSET) {
       _LOG_ERROR("Invalid self-signed certificate name " << clientCert->getName());
       return;
     }
@@ -329,13 +328,13 @@
     }
 
     // verify the certificate
-    if (!m_config.m_caName.isPrefixOf(clientCert->getName()) // under ca prefix
+    if (!m_config.m_caPrefix.isPrefixOf(clientCert->getName()) // under ca prefix
         || !security::v2::Certificate::isValidName(clientCert->getName()) // is valid cert name
-        || clientCert->getName().size() < m_config.m_caName.size() + IS_SUBNAME_MIN_OFFSET) {
+        || clientCert->getName().size() < m_config.m_caPrefix.size() + IS_SUBNAME_MIN_OFFSET) {
       _LOG_ERROR("Invalid certificate name " << clientCert->getName());
       return;
     }
-    const auto& cert = m_keyChain.getPib().getIdentity(m_config.m_caName).getDefaultKey().getDefaultCertificate();
+    const auto& cert = m_keyChain.getPib().getIdentity(m_config.m_caPrefix).getDefaultKey().getDefaultCertificate();
     if (!security::verifySignature(*clientCert, cert)) {
       _LOG_ERROR("Cert request with bad signature.");
       return;
diff --git a/src/ca-module.hpp b/src/ca-module.hpp
index 1e17e2b..b370132 100644
--- a/src/ca-module.hpp
+++ b/src/ca-module.hpp
@@ -58,8 +58,8 @@
     return m_storage;
   }
 
-  bool
-  setProbeHandler(const ProbeHandler& handler);
+  void
+  setNameAssignmentFunction(const NameAssignmentFunc& handler);
 
   bool
   setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback);