add name assignment config

Change-Id: I7a67759c50ed9986a8bcf6db814c372a0ee418d5
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index fed30aa..b41efac 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -31,6 +31,7 @@
 #include <ndn-cxx/security/verification-helpers.hpp>
 #include <ndn-cxx/util/io.hpp>
 #include <ndn-cxx/util/random.hpp>
+#include <name-assignments/assignment-funcs.hpp>
 
 namespace ndn {
 namespace ndncert {
@@ -50,6 +51,10 @@
   m_storage = CaStorage::createCaStorage(storageType, m_config.m_caItem.m_caPrefix, "");
   random::generateSecureBytes(m_requestIdGenKey, 32);
   registerPrefix();
+  if (!m_config.m_nameAssignmentFunc) {
+      m_config.m_nameAssignmentFunc =
+              NameAssignmentFuncFactory::createNameAssignmentFuncFactory("random")->getFunction("");
+  }
 }
 
 CaModule::~CaModule()
@@ -186,20 +191,14 @@
   // process PROBE requests: collect probe parameters
   auto parameters = PROBE::decodeApplicationParameters(request.getApplicationParameters());
   std::vector<PartialName> availableComponents;
-  if (m_config.m_nameAssignmentFunc) {
-    try {
-      availableComponents = m_config.m_nameAssignmentFunc(parameters);
-    }
-    catch (const std::exception& e) {
-      _LOG_TRACE("Cannot parse probe parameters: " << e.what());
-      m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
-                                         "Cannot parse probe parameters: " + std::string(e.what())));
-      return;
-    }
+  try {
+    availableComponents = m_config.m_nameAssignmentFunc(parameters);
   }
-  else {
-    // if there is no app-specified name lookup, use a random name id
-    availableComponents.push_back(std::to_string(random::generateSecureWord64()));
+  catch (const std::exception& e) {
+    _LOG_TRACE("Cannot parse probe parameters: " << e.what());
+    m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
+            "Cannot parse probe parameters: " + std::string(e.what())));
+    return;
   }
   std::vector<Name> availableNames;
   for (const auto& component : availableComponents) {