apply RDR in server command line tool and some format updates

Change-Id: Id59de3e8892e962062151911eb7fadf828ad69c5
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 7b806b7..3560568 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -51,8 +51,8 @@
   m_config.load(configPath);
   m_storage = CaStorage::createCaStorage(storageType, m_config.m_caItem.m_caPrefix, "");
   random::generateSecureBytes(m_requestIdGenKey, 32);
-  if (m_config.m_heuristic.size() == 0) {
-    m_config.m_heuristic.push_back(NameAssignmentFuncFactory::createNameAssignmentFuncFactory("random"));
+  if (m_config.m_nameAssignmentFuncs.size() == 0) {
+    m_config.m_nameAssignmentFuncs.push_back(NameAssignmentFunc::createNameAssignmentFunc("random"));
   }
   registerPrefix();
 }
@@ -103,12 +103,6 @@
 }
 
 void
-CaModule::setNameAssignmentFunction(const NameAssignmentFunc& handler)
-{
-  m_config.m_nameAssignmentFunc = handler;
-}
-
-void
 CaModule::setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback)
 {
   m_config.m_statusUpdateCallback = onUpdateCallback;
@@ -163,7 +157,7 @@
   // process PROBE requests: collect probe parameters
   auto parameters = PROBE::decodeApplicationParameters(request.getApplicationParameters());
   std::vector<PartialName> availableComponents;
-    for (auto& item : m_config.m_heuristic) {
+    for (auto& item : m_config.m_nameAssignmentFuncs) {
       auto names = item->assignName(parameters);
       availableComponents.insert(availableComponents.end(), names.begin(), names.end());
     }
diff --git a/src/ca-module.hpp b/src/ca-module.hpp
index b1bb3a3..4d6bebe 100644
--- a/src/ca-module.hpp
+++ b/src/ca-module.hpp
@@ -49,9 +49,6 @@
   }
 
   void
-  setNameAssignmentFunction(const NameAssignmentFunc& handler);
-
-  void
   setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback);
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
diff --git a/src/ca-storage/ca-storage.cpp b/src/ca-storage/ca-storage.cpp
index dfcced2..657e41e 100644
--- a/src/ca-storage/ca-storage.cpp
+++ b/src/ca-storage/ca-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/ca-storage/ca-storage.hpp b/src/ca-storage/ca-storage.hpp
index 7fbc1ec..99af926 100644
--- a/src/ca-storage/ca-storage.hpp
+++ b/src/ca-storage/ca-storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 0117df7..3cc4aa7 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -149,15 +149,15 @@
     }
   }
   //parse name assignment if appears
-  m_nameAssignmentFunc = nullptr;
+  m_nameAssignmentFuncs.clear();
   auto nameAssignmentItems = configJson.get_child_optional(CONFIG_NAME_ASSIGNMENT);
   if (nameAssignmentItems) {
     for (const auto item : *nameAssignmentItems) {
-      auto func = NameAssignmentFuncFactory::createNameAssignmentFuncFactory(item.first, item.second.data());
+      auto func = NameAssignmentFunc::createNameAssignmentFunc(item.first, item.second.data());
       if (func == nullptr) {
         BOOST_THROW_EXCEPTION(std::runtime_error("Error on creating name assignment function"));
       }
-      m_heuristic.push_back(std::move(func));
+      m_nameAssignmentFuncs.push_back(std::move(func));
     }
   }
 }
diff --git a/src/configuration.hpp b/src/configuration.hpp
index fd4ab93..40285e0 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -128,15 +128,13 @@
    */
   boost::optional<std::vector<std::shared_ptr<security::v2::Certificate>>> m_redirection;
   /**
-   * NameAssignmentFunc Callback function
-   */
-  NameAssignmentFunc m_nameAssignmentFunc;
-  /**
    * StatusUpdate Callback function
    */
   StatusUpdateCallback m_statusUpdateCallback;
-
-  std::vector<std::unique_ptr<NameAssignmentFuncFactory>> m_heuristic;
+  /**
+   * Name Assignment Functions
+   */
+  std::vector<std::unique_ptr<NameAssignmentFunc>> m_nameAssignmentFuncs;
 };
 
 /**
diff --git a/src/identity-challenge/challenge-credential.hpp b/src/identity-challenge/challenge-credential.hpp
index 0ecfdb2..2c0229b 100644
--- a/src/identity-challenge/challenge-credential.hpp
+++ b/src/identity-challenge/challenge-credential.hpp
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-email.cpp b/src/identity-challenge/challenge-email.cpp
index 2775d9e..a439807 100644
--- a/src/identity-challenge/challenge-email.cpp
+++ b/src/identity-challenge/challenge-email.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-email.hpp b/src/identity-challenge/challenge-email.hpp
index 5cab3cb..79c3db3 100644
--- a/src/identity-challenge/challenge-email.hpp
+++ b/src/identity-challenge/challenge-email.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-module.cpp b/src/identity-challenge/challenge-module.cpp
index 812a85d..0570ed5 100644
--- a/src/identity-challenge/challenge-module.cpp
+++ b/src/identity-challenge/challenge-module.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-module.hpp b/src/identity-challenge/challenge-module.hpp
index 4349762..deed763 100644
--- a/src/identity-challenge/challenge-module.hpp
+++ b/src/identity-challenge/challenge-module.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-pin.cpp b/src/identity-challenge/challenge-pin.cpp
index a5d5580..8886b67 100644
--- a/src/identity-challenge/challenge-pin.cpp
+++ b/src/identity-challenge/challenge-pin.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/identity-challenge/challenge-pin.hpp b/src/identity-challenge/challenge-pin.hpp
index 53f7a10..b942c4d 100644
--- a/src/identity-challenge/challenge-pin.hpp
+++ b/src/identity-challenge/challenge-pin.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/src/name-assignments/assignment-funcs.cpp b/src/name-assignments/assignment-funcs.cpp
index 50c8df1..cba9c65 100644
--- a/src/name-assignments/assignment-funcs.cpp
+++ b/src/name-assignments/assignment-funcs.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -24,7 +24,7 @@
 namespace ndn {
 namespace ndncert {
 
-NameAssignmentFuncFactory::NameAssignmentFuncFactory(const std::string& factoryType, const std::string& format)
+NameAssignmentFunc::NameAssignmentFunc(const std::string& factoryType, const std::string& format)
   : FACTORY_TYPE(factoryType)
 {
   size_t index = 0, startIndex = 0;
@@ -40,18 +40,18 @@
   }
 }
 
-unique_ptr<NameAssignmentFuncFactory>
-NameAssignmentFuncFactory::createNameAssignmentFuncFactory(const std::string& challengeType, const std::string& format)
+unique_ptr<NameAssignmentFunc>
+NameAssignmentFunc::createNameAssignmentFunc(const std::string& challengeType, const std::string& format)
 {
   FuncFactoryFactory& factory = getFactory();
   auto i = factory.find(challengeType);
   return i == factory.end() ? nullptr : i->second(format);
 }
 
-NameAssignmentFuncFactory::FuncFactoryFactory&
-NameAssignmentFuncFactory::getFactory()
+NameAssignmentFunc::FuncFactoryFactory&
+NameAssignmentFunc::getFactory()
 {
-  static NameAssignmentFuncFactory::FuncFactoryFactory factory;
+  static NameAssignmentFunc::FuncFactoryFactory factory;
   return factory;
 }
 
diff --git a/src/name-assignments/assignment-funcs.hpp b/src/name-assignments/assignment-funcs.hpp
index b8c2dd1..39e1261 100644
--- a/src/name-assignments/assignment-funcs.hpp
+++ b/src/name-assignments/assignment-funcs.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -26,58 +26,55 @@
 namespace ndn {
 namespace ndncert {
 
-/**
- * @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
- * 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 NameAssignmentFunc = function<std::vector<PartialName>(const std::vector<std::tuple<std::string, std::string>>&)>;
-
-class NameAssignmentFuncFactory : noncopyable {
+class NameAssignmentFunc : noncopyable {
 public:
-  explicit
-  NameAssignmentFuncFactory(const std::string& factoryType, const std::string& format = "");
+  explicit NameAssignmentFunc(const std::string& factoryType, const std::string& format = "");
 
-  virtual ~NameAssignmentFuncFactory() = default;
+  virtual ~NameAssignmentFunc() = default;
 
+  /**
+   * @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
+   * 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.
+   */
+  virtual std::vector<PartialName>
+  assignName(const std::vector<std::tuple<std::string, std::string>>& params) = 0;
+
+  const std::string FACTORY_TYPE;
+  std::vector<std::string> m_nameFormat;
+
+public:
   template <class ChallengeType>
   static void
-  registerNameAssignmentFuncFactories(const std::string& typeName)
+  registerNameAssignmentFunc(const std::string& typeName)
   {
     FuncFactoryFactory& factory = getFactory();
     BOOST_ASSERT(factory.count(typeName) == 0);
     factory[typeName] = [](const std::string& format) { return make_unique<ChallengeType>(format); };
   }
 
-  static unique_ptr<NameAssignmentFuncFactory>
-  createNameAssignmentFuncFactory(const std::string& challengeType, const std::string& format = "");
-
-  virtual std::vector<PartialName>
-  assignName(const std::vector<std::tuple<std::string, std::string>>& params) = 0;
-
-public:
-  const std::string FACTORY_TYPE;
-  std::vector<std::string> m_nameFormat;
+  static unique_ptr<NameAssignmentFunc>
+  createNameAssignmentFunc(const std::string& challengeType, const std::string& format = "");
 
 private:
-  typedef function<unique_ptr<NameAssignmentFuncFactory>(const std::string&)> FactoryCreateFunc;
+  typedef function<unique_ptr<NameAssignmentFunc>(const std::string&)> FactoryCreateFunc;
   typedef std::map<std::string, FactoryCreateFunc> FuncFactoryFactory;
 
   static FuncFactoryFactory&
   getFactory();
 };
 
-#define NDNCERT_REGISTER_FUNCFACTORY(C, T)                               \
-  static class NdnCert##C##FuncFactoryRegistrationClass {                \
-  public:                                                                \
-    NdnCert##C##FuncFactoryRegistrationClass()                           \
-    {                                                                    \
-      ::ndn::ndncert::NameAssignmentFuncFactory::registerNameAssignmentFuncFactories<C>(T); \
-    }                                                                    \
+#define NDNCERT_REGISTER_FUNCFACTORY(C, T)                                        \
+  static class NdnCert##C##FuncFactoryRegistrationClass {                         \
+  public:                                                                         \
+    NdnCert##C##FuncFactoryRegistrationClass()                                    \
+    {                                                                             \
+      ::ndn::ndncert::NameAssignmentFunc::registerNameAssignmentFunc<C>(T);       \
+    }                                                                             \
   } g_NdnCert##C##ChallengeRegistrationVariable
 
 }  // namespace ndncert
diff --git a/src/name-assignments/assignment-hash.cpp b/src/name-assignments/assignment-hash.cpp
index c71b369..7af3bf8 100644
--- a/src/name-assignments/assignment-hash.cpp
+++ b/src/name-assignments/assignment-hash.cpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #include "assignment-hash.hpp"
 #include <ndn-cxx/util/sha256.hpp>
@@ -11,7 +27,7 @@
 NDNCERT_REGISTER_FUNCFACTORY(AssignmentHash, "hash");
 
 AssignmentHash::AssignmentHash(const std::string& format)
-  : NameAssignmentFuncFactory("hash", format)
+  : NameAssignmentFunc("hash", format)
 {}
 
 std::vector<PartialName>
diff --git a/src/name-assignments/assignment-hash.hpp b/src/name-assignments/assignment-hash.hpp
index 9054bb7..b0cf417 100644
--- a/src/name-assignments/assignment-hash.hpp
+++ b/src/name-assignments/assignment-hash.hpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #ifndef NDNCERT_ASSIGNMENT_HASH_HPP
 #define NDNCERT_ASSIGNMENT_HASH_HPP
@@ -13,7 +29,7 @@
 /**
  * assign names base on client probe parameter
  */
-class AssignmentHash: public NameAssignmentFuncFactory {
+class AssignmentHash: public NameAssignmentFunc {
 public:
   AssignmentHash(const std::string& format = "");
 
diff --git a/src/name-assignments/assignment-param.cpp b/src/name-assignments/assignment-param.cpp
index 890af34..cf54951 100644
--- a/src/name-assignments/assignment-param.cpp
+++ b/src/name-assignments/assignment-param.cpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #include "assignment-param.hpp"
 
@@ -10,7 +26,7 @@
 NDNCERT_REGISTER_FUNCFACTORY(AssignmentParam, "param");
 
 AssignmentParam::AssignmentParam(const std::string& format)
-  : NameAssignmentFuncFactory("param", format)
+  : NameAssignmentFunc("param", format)
 {}
 
 std::vector<PartialName>
diff --git a/src/name-assignments/assignment-param.hpp b/src/name-assignments/assignment-param.hpp
index 9633a57..6b705df 100644
--- a/src/name-assignments/assignment-param.hpp
+++ b/src/name-assignments/assignment-param.hpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #ifndef NDNCERT_ASSIGNMENT_PARAM_HPP
 #define NDNCERT_ASSIGNMENT_PARAM_HPP
@@ -13,7 +29,7 @@
 /**
  * assign names base on client probe parameter
  */
-class AssignmentParam: public NameAssignmentFuncFactory{
+class AssignmentParam: public NameAssignmentFunc{
 public:
   AssignmentParam(const std::string& format = "");
 
diff --git a/src/name-assignments/assignment-random.cpp b/src/name-assignments/assignment-random.cpp
index 88e9a91..7b24481 100644
--- a/src/name-assignments/assignment-random.cpp
+++ b/src/name-assignments/assignment-random.cpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #include "assignment-random.hpp"
 #include <ndn-cxx/util/random.hpp>
@@ -11,7 +27,7 @@
 NDNCERT_REGISTER_FUNCFACTORY(AssignmentRandom, "random");
 
 AssignmentRandom::AssignmentRandom(const std::string& format)
-  : NameAssignmentFuncFactory("random", format)
+  : NameAssignmentFunc("random", format)
 {}
 
 std::vector<PartialName>
diff --git a/src/name-assignments/assignment-random.hpp b/src/name-assignments/assignment-random.hpp
index c35c143..a3e30dd 100644
--- a/src/name-assignments/assignment-random.hpp
+++ b/src/name-assignments/assignment-random.hpp
@@ -1,6 +1,22 @@
-//
-// Created by Tyler on 10/6/20.
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
 
 #ifndef NDNCERT_ASSIGNMENT_RANDOM_HPP
 #define NDNCERT_ASSIGNMENT_RANDOM_HPP
@@ -13,7 +29,7 @@
 /**
  * assign names base on client probe parameter
  */
-class AssignmentRandom: public NameAssignmentFuncFactory {
+class AssignmentRandom: public NameAssignmentFunc {
 public:
   AssignmentRandom(const std::string& format = "");
 
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index bf319ae..c768035 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 4374a86..9484196 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -108,11 +108,6 @@
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
-  ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<PartialName> {
-    std::vector<PartialName> result;
-    result.push_back(Name("/example"));
-    return result;
-  });
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
@@ -189,11 +184,6 @@
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
-  ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<PartialName> {
-    std::vector<PartialName> result;
-    result.push_back(Name("/example"));
-    return result;
-  });
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 5d4a7dd..c3fdacf 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -54,18 +54,18 @@
   config.load("tests/unit-tests/config-files/config-ca-5");
   BOOST_CHECK_EQUAL(config.m_redirection->at(0)->getName(),
                     "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
-  BOOST_CHECK_EQUAL(config.m_heuristic.size(), 3);
-  BOOST_CHECK_EQUAL(config.m_heuristic[0]->FACTORY_TYPE, "param");
-  BOOST_CHECK_EQUAL(config.m_heuristic[1]->FACTORY_TYPE, "param");
-  BOOST_CHECK_EQUAL(config.m_heuristic[2]->FACTORY_TYPE, "random");
-  BOOST_CHECK_EQUAL(config.m_heuristic[0]->m_nameFormat[0], "group");
-  BOOST_CHECK_EQUAL(config.m_heuristic[0]->m_nameFormat[1], "email");
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs.size(), 3);
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->FACTORY_TYPE, "param");
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[1]->FACTORY_TYPE, "param");
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[2]->FACTORY_TYPE, "random");
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->m_nameFormat[0], "group");
+  BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->m_nameFormat[1], "email");
   std::vector<std::tuple<std::string, std::string>> params;
   params.emplace_back("email", "1@1.edu");
   params.emplace_back("group", "irl");
   params.emplace_back("name", "ndncert");
   std::vector<Name> names;
-  for (auto& assignment : config.m_heuristic) {
+  for (auto& assignment : config.m_nameAssignmentFuncs) {
     auto results = assignment->assignName(params);
     BOOST_CHECK_EQUAL(results.size(), 1);
     names.insert(names.end(), results.begin(), results.end());
diff --git a/tools/ndncert-ca-server.cpp b/tools/ndncert-ca-server.cpp
index 57493e9..a331e7e 100644
--- a/tools/ndncert-ca-server.cpp
+++ b/tools/ndncert-ca-server.cpp
@@ -20,20 +20,37 @@
 
 #include "ca-module.hpp"
 #include "identity-challenge/challenge-module.hpp"
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
 #include <boost/asio.hpp>
 #include <boost/asio/ip/tcp.hpp>
 #include <boost/program_options/options_description.hpp>
 #include <boost/program_options/parsers.hpp>
 #include <boost/program_options/variables_map.hpp>
 #include <iostream>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
 
 namespace ndn {
 namespace ndncert {
 
 Face face;
 security::v2::KeyChain keyChain;
+std::string repoHost = "localhost";
+std::string repoPort = "7376";
+
+static bool
+writeDataToRepo(const Data& data) {
+  boost::asio::ip::tcp::iostream requestStream;
+  requestStream.expires_after(std::chrono::seconds(3));
+  requestStream.connect(repoHost, repoPort);
+  if (!requestStream) {
+    std::cerr << "ERROR: Cannot publish certificate to repo-ng"
+              << " (" << requestStream.error().message() << ")" << std::endl;
+    return false;
+  }
+  requestStream.write(reinterpret_cast<const char*>(data.wireEncode().wire()),
+                      data.wireEncode().size());
+  return true;
+}
 
 static void
 handleSignal(const boost::system::error_code& error, int signalNum)
@@ -63,20 +80,16 @@
   terminateSignals.async_wait(handleSignal);
 
   std::string configFilePath(SYSCONFDIR "/ndncert/ca.conf");
-  std::string repoHost("localhost");
-  std::string repoPort("7376");
   bool wantRepoOut = false;
 
   namespace po = boost::program_options;
   po::options_description optsDesc("Options");
   optsDesc.add_options()
-    ("help,h",        "print this help message and exit")
-    ("config-file,c", po::value<std::string>(&configFilePath)->default_value(configFilePath),
-                      "path to configuration file")
-    ("repo-output,r", po::bool_switch(&wantRepoOut),
-                      "when enabled, all issued certificates will be published to repo-ng")
-    ("repo-host,H",   po::value<std::string>(&repoHost)->default_value(repoHost), "repo-ng host")
-    ("repo-port,P",   po::value<std::string>(&repoPort)->default_value(repoPort), "repo-ng port");
+  ("help,h", "print this help message and exit")
+  ("config-file,c", po::value<std::string>(&configFilePath)->default_value(configFilePath), "path to configuration file")
+  ("repo-output,r", po::bool_switch(&wantRepoOut), "when enabled, all issued certificates will be published to repo-ng")
+  ("repo-host,H", po::value<std::string>(&repoHost)->default_value(repoHost), "repo-ng host")
+  ("repo-port,P", po::value<std::string>(&repoPort)->default_value(repoPort), "repo-ng port");
 
   po::variables_map vm;
   try {
@@ -100,24 +113,18 @@
   }
 
   CaModule ca(face, keyChain, configFilePath);
-  std::map<Name, security::v2::Certificate> cachedCertificates;
+  std::map<Name, Data> cachedCertificates;
+  auto profileMetaData = ca.generateCaProfileMetaData();
+  auto profileData = ca.generateCaProfileData();
 
   if (wantRepoOut) {
-      ca.setStatusUpdateCallback([&] (const CaState& request) {
-          if (request.m_status == Status::SUCCESS) {
-            auto issuedCert = request.m_cert;
-            boost::asio::ip::tcp::iostream requestStream;
-            requestStream.expires_after(std::chrono::seconds(3));
-            requestStream.connect(repoHost, repoPort);
-            if (!requestStream) {
-              std::cerr << "ERROR: Cannot publish certificate to repo-ng"
-                        << " (" << requestStream.error().message() << ")" << std::endl;
-              return;
-            }
-            requestStream.write(reinterpret_cast<const char*>(issuedCert.wireEncode().wire()),
-                                issuedCert.wireEncode().size());
-          }
-      });
+    writeDataToRepo(*profileMetaData);
+    writeDataToRepo(*profileData);
+    ca.setStatusUpdateCallback([&](const CaState& request) {
+      if (request.m_status == Status::SUCCESS) {
+        writeDataToRepo(request.m_cert);
+      }
+    });
   }
   else {
     ca.setStatusUpdateCallback([&](const CaState& request) {
@@ -125,6 +132,8 @@
         cachedCertificates[request.m_cert.getName()] = request.m_cert;
       }
     });
+    cachedCertificates[profileMetaData->getName()] = *profileMetaData;
+    cachedCertificates[profileData->getName()] = *profileData;
     face.setInterestFilter(
         InterestFilter(ca.getCaConf().m_caItem.m_caPrefix),
         [&](const InterestFilter&, const Interest& interest) {
@@ -142,8 +151,8 @@
   return 0;
 }
 
-} // namespace ndncert
-} // namespace ndn
+}  // namespace ndncert
+}  // namespace ndn
 
 int
 main(int argc, char* argv[])