move more things out of common.hpp
Change-Id: If9136ebd299937a6daa044c3d959ee1e4ab69473
diff --git a/src/ca-state.cpp b/src/ca-state.cpp
index 3b05e03..185fbdd 100644
--- a/src/ca-state.cpp
+++ b/src/ca-state.cpp
@@ -103,7 +103,9 @@
os << "Challenge remaining tries:" << request.m_challengeState->m_remainingTries << " times\n";
os << "Challenge remaining time: " << request.m_challengeState->m_remainingTime.count() << " seconds\n";
os << "Challenge last update: " << time::toIsoString(request.m_challengeState->m_timestamp) << "\n";
- os << "Challenge secret:\n" << convertJson2String(request.m_challengeState->m_secrets) << "\n";
+ std::stringstream ss;
+ boost::property_tree::write_json(ss, request.m_challengeState->m_secrets);
+ os << "Challenge secret:\n" << ss.str() << "\n";
}
os << "Certificate:\n";
util::IndentedStream os2(os, " ");
diff --git a/src/ca-storage/ca-sqlite.cpp b/src/ca-storage/ca-sqlite.cpp
index a74445b..b0d6af5 100644
--- a/src/ca-storage/ca-sqlite.cpp
+++ b/src/ca-storage/ca-sqlite.cpp
@@ -29,11 +29,27 @@
namespace ndn {
namespace ndncert {
+using namespace ndn::util;
const std::string CaSqlite::STORAGE_TYPE = "ca-storage-sqlite3";
NDNCERT_REGISTER_CA_STORAGE(CaSqlite);
-using namespace ndn::util;
+std::string
+convertJson2String(const JsonSection& json)
+{
+ std::stringstream ss;
+ boost::property_tree::write_json(ss, json);
+ return ss.str();
+}
+
+JsonSection
+convertString2Json(const std::string& jsonContent)
+{
+ std::istringstream ss(jsonContent);
+ JsonSection json;
+ boost::property_tree::json_parser::read_json(ss, json);
+ return json;
+}
static const std::string INITIALIZATION = R"_DBTEXT_(
CREATE TABLE IF NOT EXISTS
diff --git a/src/configuration.cpp b/src/configuration.cpp
index c9b1694..d5ae255 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -27,6 +27,19 @@
namespace ndn {
namespace ndncert {
+// Parse CA Configuration file
+const std::string CONFIG_CA_PREFIX = "ca-prefix";
+const std::string CONFIG_CA_INFO = "ca-info";
+const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
+const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
+const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
+const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
+const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
+const std::string CONFIG_CHALLENGE = "challenge";
+const std::string CONFIG_CERTIFICATE = "certificate";
+const std::string CONFIG_REDIRECTION = "redirect-to";
+const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
+
void
CaProfile::parse(const JsonSection& configJson)
{
diff --git a/src/ndncert-common.cpp b/src/ndncert-common.cpp
index 7874635..5f3adbe 100644
--- a/src/ndncert-common.cpp
+++ b/src/ndncert-common.cpp
@@ -23,23 +23,6 @@
namespace ndn {
namespace ndncert {
-std::string
-convertJson2String(const JsonSection& json)
-{
- std::stringstream ss;
- boost::property_tree::write_json(ss, json);
- return ss.str();
-}
-
-JsonSection
-convertString2Json(const std::string& jsonContent)
-{
- std::istringstream ss(jsonContent);
- JsonSection json;
- boost::property_tree::json_parser::read_json(ss, json);
- return json;
-}
-
std::map<ErrorCode, std::string> errorCodeText = {
{ErrorCode::NO_ERROR, "NO_ERROR"},
{ErrorCode::BAD_INTEREST_FORMAT, "BAD_INTEREST_FORMAT"},
diff --git a/src/ndncert-common.hpp b/src/ndncert-common.hpp
index 2a38778..cb8cd5b 100644
--- a/src/ndncert-common.hpp
+++ b/src/ndncert-common.hpp
@@ -61,6 +61,7 @@
namespace ndncert {
using boost::noncopyable;
+typedef boost::property_tree::ptree JsonSection;
enum : uint32_t {
tlv_ca_prefix = 129,
@@ -91,27 +92,6 @@
tlv_probe_redirect = 179
};
-// Parse CA Configuration file
-const std::string CONFIG_CA_PREFIX = "ca-prefix";
-const std::string CONFIG_CA_INFO = "ca-info";
-const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
-const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
-const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
-const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
-const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
-const std::string CONFIG_CHALLENGE = "challenge";
-const std::string CONFIG_CERTIFICATE = "certificate";
-const std::string CONFIG_REDIRECTION = "redirect-to";
-const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
-typedef boost::property_tree::ptree JsonSection;
-
-// JSON and string translation for Config file parsing
-std::string
-convertJson2String(const JsonSection& json);
-
-JsonSection
-convertString2Json(const std::string& jsonContent);
-
// NDNCERT error code
enum class ErrorCode : uint16_t {
NO_ERROR = 0,