Slim down `ndncert-common.hpp`

Change-Id: Ifba0966d3787c5cbf770963b82cba054ee1fe791
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 12fff93..7f51eba 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2023, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -32,6 +32,7 @@
 #include <ndn-cxx/security/signing-helpers.hpp>
 #include <ndn-cxx/security/verification-helpers.hpp>
 #include <ndn-cxx/util/io.hpp>
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/random.hpp>
 #include <ndn-cxx/util/string-helper.hpp>
 
diff --git a/src/challenge/challenge-email.cpp b/src/challenge/challenge-email.cpp
index 01bb7ba..c4de9ce 100644
--- a/src/challenge/challenge-email.cpp
+++ b/src/challenge/challenge-email.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -19,6 +19,9 @@
  */
 
 #include "challenge-email.hpp"
+
+#include <ndn-cxx/util/logger.hpp>
+
 #include <regex>
 #include <boost/process.hpp>
 
diff --git a/src/challenge/challenge-module.hpp b/src/challenge/challenge-module.hpp
index a0c7b60..b3baefb 100644
--- a/src/challenge/challenge-module.hpp
+++ b/src/challenge/challenge-module.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -24,6 +24,7 @@
 #include "detail/ca-request-state.hpp"
 
 #include <map>
+#include <tuple>
 
 namespace ndncert {
 
diff --git a/src/challenge/challenge-pin.cpp b/src/challenge/challenge-pin.cpp
index 46f65fd..2662055 100644
--- a/src/challenge/challenge-pin.cpp
+++ b/src/challenge/challenge-pin.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,6 +20,7 @@
 
 #include "challenge-pin.hpp"
 
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/random.hpp>
 
 namespace ndncert {
diff --git a/src/challenge/challenge-possession.cpp b/src/challenge/challenge-possession.cpp
index 20b0127..2473f29 100644
--- a/src/challenge/challenge-possession.cpp
+++ b/src/challenge/challenge-possession.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2023, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -23,6 +23,7 @@
 #include <ndn-cxx/security/transform/public-key.hpp>
 #include <ndn-cxx/security/verification-helpers.hpp>
 #include <ndn-cxx/util/io.hpp>
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/random.hpp>
 
 #include <boost/property_tree/json_parser.hpp>
diff --git a/src/detail/ca-profile.cpp b/src/detail/ca-profile.cpp
index f1d8c3f..86d5be4 100644
--- a/src/detail/ca-profile.cpp
+++ b/src/detail/ca-profile.cpp
@@ -21,6 +21,7 @@
 #include "detail/ca-profile.hpp"
 #include "challenge/challenge-module.hpp"
 
+#include <boost/algorithm/string/case_conv.hpp>
 #include <ndn-cxx/util/io.hpp>
 
 namespace ndncert {
diff --git a/src/detail/ca-profile.hpp b/src/detail/ca-profile.hpp
index 620f49b..6ca9b19 100644
--- a/src/detail/ca-profile.hpp
+++ b/src/detail/ca-profile.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -23,6 +23,8 @@
 
 #include "detail/ndncert-common.hpp"
 
+#include <optional>
+
 namespace ndncert {
 
 // used in parsing CA configuration file and Client CA profile storage file
@@ -44,8 +46,8 @@
 {
 public:
   /**
-   * Parse the configuration json.
-   * @param configJson the configuration json to parse
+   * Parse the configuration JSON.
+   * @param json the configuration json to parse
    * @return the CaProfile according to this json
    */
   static CaProfile
diff --git a/src/detail/ca-request-state.hpp b/src/detail/ca-request-state.hpp
index a11caf0..49fa583 100644
--- a/src/detail/ca-request-state.hpp
+++ b/src/detail/ca-request-state.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2023, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -24,6 +24,7 @@
 #include "detail/ndncert-common.hpp"
 
 #include <array>
+#include <optional>
 
 namespace ndncert {
 
diff --git a/src/detail/error-encoder.cpp b/src/detail/error-encoder.cpp
index 09197c9..db2b1ca 100644
--- a/src/detail/error-encoder.cpp
+++ b/src/detail/error-encoder.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2023, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,10 +20,12 @@
 
 #include "detail/error-encoder.hpp"
 
-NDN_LOG_INIT(ndncert.encode.error);
+#include <ndn-cxx/util/logger.hpp>
 
 namespace ndncert::errortlv {
 
+NDN_LOG_INIT(ndncert.encode.error);
+
 Block
 encodeDataContent(ErrorCode errorCode, const std::string& description)
 {
diff --git a/src/detail/error-encoder.hpp b/src/detail/error-encoder.hpp
index 57fdf92..d41e6f6 100644
--- a/src/detail/error-encoder.hpp
+++ b/src/detail/error-encoder.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -21,7 +21,9 @@
 #ifndef NDNCERT_DETAIL_ERROR_ENCODER_HPP
 #define NDNCERT_DETAIL_ERROR_ENCODER_HPP
 
-#include "detail/ca-profile.hpp"
+#include "detail/ndncert-common.hpp"
+
+#include <tuple>
 
 namespace ndncert::errortlv {
 
diff --git a/src/detail/info-encoder.cpp b/src/detail/info-encoder.cpp
index 2a9df67..4c260b4 100644
--- a/src/detail/info-encoder.cpp
+++ b/src/detail/info-encoder.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,10 +20,12 @@
 
 #include "detail/info-encoder.hpp"
 
-NDN_LOG_INIT(ndncert.encode.info);
+#include <ndn-cxx/util/logger.hpp>
 
 namespace ndncert::infotlv {
 
+NDN_LOG_INIT(ndncert.encode.info);
+
 Block
 encodeDataContent(const CaProfile& caConfig, const Certificate& certificate)
 {
diff --git a/src/detail/ndncert-common.cpp b/src/detail/ndncert-common.cpp
index 5e22afb..eb308e9 100644
--- a/src/detail/ndncert-common.cpp
+++ b/src/detail/ndncert-common.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,38 +20,38 @@
 
 #include "detail/ndncert-common.hpp"
 
+#include <ndn-cxx/util/backports.hpp>
+
 namespace ndncert {
 
 std::ostream&
 operator<<(std::ostream& out, ErrorCode code)
 {
   switch (code) {
-    case ErrorCode::NO_ERROR: out << "NO_ERROR"; break;
-    case ErrorCode::BAD_INTEREST_FORMAT: out << "BAD_INTEREST_FORMAT"; break;
-    case ErrorCode::BAD_PARAMETER_FORMAT: out << "BAD_PARAMETER_FORMAT"; break;
-    case ErrorCode::BAD_SIGNATURE: out << "BAD_SIGNATURE"; break;
-    case ErrorCode::INVALID_PARAMETER: out << "INVALID_PARAMETER"; break;
-    case ErrorCode::NAME_NOT_ALLOWED: out << "NAME_NOT_ALLOWED"; break;
-    case ErrorCode::BAD_VALIDITY_PERIOD: out << "BAD_VALIDITY_PERIOD"; break;
-    case ErrorCode::OUT_OF_TRIES: out << "OUT_OF_TRIES"; break;
-    case ErrorCode::OUT_OF_TIME: out << "OUT_OF_TIME"; break;
-    case ErrorCode::NO_AVAILABLE_NAMES: out << "NO_AVAILABLE_NAMES"; break;
-    default: out << "UNKNOWN_ERROR"; break;
+    case ErrorCode::NO_ERROR: return out << "NO_ERROR";
+    case ErrorCode::BAD_INTEREST_FORMAT: return out << "BAD_INTEREST_FORMAT";
+    case ErrorCode::BAD_PARAMETER_FORMAT: return out << "BAD_PARAMETER_FORMAT";
+    case ErrorCode::BAD_SIGNATURE: return out << "BAD_SIGNATURE";
+    case ErrorCode::INVALID_PARAMETER: return out << "INVALID_PARAMETER";
+    case ErrorCode::NAME_NOT_ALLOWED: return out << "NAME_NOT_ALLOWED";
+    case ErrorCode::BAD_VALIDITY_PERIOD: return out << "BAD_VALIDITY_PERIOD";
+    case ErrorCode::OUT_OF_TRIES: return out << "OUT_OF_TRIES";
+    case ErrorCode::OUT_OF_TIME: return out << "OUT_OF_TIME";
+    case ErrorCode::NO_AVAILABLE_NAMES: return out << "NO_AVAILABLE_NAMES";
   }
-  return out;
+  return out << "<Unknown Error " << ndn::to_underlying(code) << ">";
 }
 
 std::ostream&
 operator<<(std::ostream& out, RequestType type)
 {
   switch (type) {
-    case RequestType::NEW: out << "New"; break;
-    case RequestType::RENEW: out << "Renew"; break;
-    case RequestType::REVOKE: out << "Revoke"; break;
-    case RequestType::NOTINITIALIZED: out << "Not Initialized"; break;
-    default: out << "UNKNOWN_REQUEST_TYPE"; break;
+    case RequestType::NOTINITIALIZED: return out << "Not Initialized";
+    case RequestType::NEW: return out << "New";
+    case RequestType::RENEW: return out << "Renew";
+    case RequestType::REVOKE: return out << "Revoke";
   }
-  return out;
+  return out << "<Unknown Request Type " << ndn::to_underlying(type) << ">";
 }
 
 } // namespace ndncert
diff --git a/src/detail/ndncert-common.hpp b/src/detail/ndncert-common.hpp
index 5549550..94d9273 100644
--- a/src/detail/ndncert-common.hpp
+++ b/src/detail/ndncert-common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -23,7 +23,7 @@
 
 #include "detail/ndncert-config.hpp"
 
-#ifdef NDNCERT_HAVE_TESTS
+#ifdef NDNCERT_WITH_TESTS
 #define NDNCERT_VIRTUAL_WITH_TESTS virtual
 #define NDNCERT_PUBLIC_WITH_TESTS_ELSE_PROTECTED public
 #define NDNCERT_PUBLIC_WITH_TESTS_ELSE_PRIVATE public
@@ -38,9 +38,8 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
-#include <optional>
+#include <stdexcept>
 #include <string>
-#include <tuple>
 #include <vector>
 
 #include <ndn-cxx/data.hpp>
@@ -50,12 +49,10 @@
 #include <ndn-cxx/name.hpp>
 #include <ndn-cxx/security/certificate.hpp>
 #include <ndn-cxx/util/exception.hpp>
-#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/time.hpp>
 
-#include <boost/algorithm/string.hpp>
 #include <boost/assert.hpp>
-#include <boost/noncopyable.hpp>
+#include <boost/core/noncopyable.hpp>
 #include <boost/property_tree/ptree.hpp>
 
 namespace ndncert {
@@ -99,7 +96,7 @@
   ErrorInfo = 173,
   AuthenticationTag = 175,
   CertToRevoke = 177,
-  ProbeRedirect = 179
+  ProbeRedirect = 179,
 };
 
 } // namespace tlv
@@ -117,7 +114,7 @@
   BAD_VALIDITY_PERIOD = 6,
   OUT_OF_TRIES = 7,
   OUT_OF_TIME = 8,
-  NO_AVAILABLE_NAMES = 9
+  NO_AVAILABLE_NAMES = 9,
 };
 
 // Convert error code to string
@@ -129,7 +126,7 @@
   NOTINITIALIZED = 0,
   NEW = 1,
   RENEW = 2,
-  REVOKE = 3
+  REVOKE = 3,
 };
 
 // Convert request type to string
diff --git a/src/detail/probe-encoder.hpp b/src/detail/probe-encoder.hpp
index bd15463..815a840 100644
--- a/src/detail/probe-encoder.hpp
+++ b/src/detail/probe-encoder.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -23,6 +23,8 @@
 
 #include "detail/ndncert-common.hpp"
 
+#include <optional>
+
 namespace ndncert::probetlv {
 
 // For Client use
diff --git a/src/redirection/redirection-email.cpp b/src/redirection/redirection-email.cpp
index c13ad91..17e03d5 100644
--- a/src/redirection/redirection-email.cpp
+++ b/src/redirection/redirection-email.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,8 +20,6 @@
 
 #include "redirection-email.hpp"
 
-#include <boost/algorithm/string.hpp>
-
 namespace ndncert {
 
 NDNCERT_REGISTER_REDIRECTION_POLICY(RedirectionEmail, "email");
diff --git a/src/redirection/redirection-param.cpp b/src/redirection/redirection-param.cpp
index 1ce9517..263d547 100644
--- a/src/redirection/redirection-param.cpp
+++ b/src/redirection/redirection-param.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,7 +20,8 @@
 
 #include "redirection-param.hpp"
 
-#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
 
 namespace ndncert {
 
@@ -33,7 +34,7 @@
   }
 
   std::vector<std::string> strs;
-  boost::split(strs,format,boost::is_any_of("&"));
+  boost::split(strs, format, boost::is_any_of("&"));
   for (const auto& s : strs) {
     auto i = s.find('=');
     if (i == std::string::npos) {
diff --git a/src/requester-request.cpp b/src/requester-request.cpp
index 277a7e7..3523d77 100644
--- a/src/requester-request.cpp
+++ b/src/requester-request.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2023, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -35,6 +35,7 @@
 #include <ndn-cxx/security/transform/stream-sink.hpp>
 #include <ndn-cxx/security/verification-helpers.hpp>
 #include <ndn-cxx/util/io.hpp>
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/random.hpp>
 
 #include <boost/lexical_cast.hpp>