code review fix
Change-Id: Ie616543094aaa31d596980ba7a3cef05de4351fc
diff --git a/src/detail/ca-configuration.cpp b/src/detail/ca-configuration.cpp
index 857c6a8..d44b36b 100644
--- a/src/detail/ca-configuration.cpp
+++ b/src/detail/ca-configuration.cpp
@@ -39,12 +39,12 @@
if (configJson.begin() == configJson.end()) {
NDN_THROW(std::runtime_error("No JSON configuration found in file: " + fileName));
}
- m_caProfile = CaProfile::fromJson(configJson);
- if (m_caProfile.m_supportedChallenges.size() == 0) {
+ caProfile = CaProfile::fromJson(configJson);
+ if (caProfile.m_supportedChallenges.size() == 0) {
NDN_THROW(std::runtime_error("At least one challenge should be specified."));
}
// parse redirection section if appears
- m_redirection.clear();
+ redirection.clear();
auto redirectionItems = configJson.get_child_optional(CONFIG_REDIRECTION);
if (redirectionItems) {
for (const auto& item : *redirectionItems) {
@@ -55,11 +55,11 @@
}
std::istringstream ss(caCertStr);
auto caCert = io::load<security::Certificate>(ss);
- m_redirection.push_back(caCert);
+ redirection.push_back(caCert);
}
}
// parse name assignment if appears
- m_nameAssignmentFuncs.clear();
+ nameAssignmentFuncs.clear();
auto nameAssignmentItems = configJson.get_child_optional(CONFIG_NAME_ASSIGNMENT);
if (nameAssignmentItems) {
for (const auto& item : *nameAssignmentItems) {
@@ -67,7 +67,7 @@
if (func == nullptr) {
NDN_THROW(std::runtime_error("Error on creating name assignment function"));
}
- m_nameAssignmentFuncs.push_back(std::move(func));
+ nameAssignmentFuncs.push_back(std::move(func));
}
}
}
diff --git a/src/detail/ca-configuration.hpp b/src/detail/ca-configuration.hpp
index 9623464..ba3de47 100644
--- a/src/detail/ca-configuration.hpp
+++ b/src/detail/ca-configuration.hpp
@@ -63,15 +63,15 @@
/**
* @brief the CA's profile
*/
- CaProfile m_caProfile;
+ CaProfile caProfile;
/**
* @brief Used for CA redirection
*/
- std::vector<std::shared_ptr<security::Certificate>> m_redirection;
+ std::vector<std::shared_ptr<security::Certificate>> redirection;
/**
* @brief Name Assignment Functions
*/
- std::vector<std::unique_ptr<NameAssignmentFunc>> m_nameAssignmentFuncs;
+ std::vector<std::unique_ptr<NameAssignmentFunc>> nameAssignmentFuncs;
};
} // namespace ca
diff --git a/src/detail/ca-profile.hpp b/src/detail/ca-profile.hpp
index 3fe0180..b3e31be 100644
--- a/src/detail/ca-profile.hpp
+++ b/src/detail/ca-profile.hpp
@@ -39,12 +39,13 @@
const std::string CONFIG_REDIRECTION = "redirect-to";
const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
-struct CaProfile
+class CaProfile
{
public:
/**
- * Parse the configuration json and modify current struct to the result.
+ * Parse the configuration json.
* @param configJson the configuration json to parse
+ * @return the CaProfile according to this json
*/
static CaProfile
fromJson(const JsonSection& json);
@@ -67,7 +68,7 @@
/**
* @brief A list of parameter-keys for PROBE.
*/
- std::list<std::string> m_probeParameterKeys;
+ std::vector<std::string> m_probeParameterKeys;
/**
* @brief Maximum allowed validity period of the certificate being requested.
*
@@ -85,7 +86,7 @@
/**
* @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
*/
- std::list<std::string> m_supportedChallenges;
+ std::vector<std::string> m_supportedChallenges;
/**
* @brief CA's certificate. Only Client side will have m_cert.
*/
diff --git a/src/detail/challenge-encoder.cpp b/src/detail/challenge-encoder.cpp
index 12eb7cf..023b2c1 100644
--- a/src/detail/challenge-encoder.cpp
+++ b/src/detail/challenge-encoder.cpp
@@ -47,23 +47,23 @@
void
challengetlv::decodeDataContent(const Block& contentBlock, requester::RequestState& state)
{
- auto result = decodeBlockWithAesGcm128(contentBlock, state.m_aesKey.data(),
- state.m_requestId.data(), state.m_requestId.size());
+ auto result = decodeBlockWithAesGcm128(contentBlock, state.aesKey.data(),
+ state.requestId.data(), state.requestId.size());
auto data = makeBinaryBlock(tlv::EncryptedPayload, result.data(), result.size());
data.parse();
- state.m_status = statusFromBlock(data.get(tlv::Status));
+ state.status = statusFromBlock(data.get(tlv::Status));
if (data.find(tlv::ChallengeStatus) != data.elements_end()) {
- state.m_challengeStatus = readString(data.get(tlv::ChallengeStatus));
+ state.challengeStatus = readString(data.get(tlv::ChallengeStatus));
}
if (data.find(tlv::RemainingTries) != data.elements_end()) {
- state.m_remainingTries = readNonNegativeInteger(data.get(tlv::RemainingTries));
+ state.remainingTries = readNonNegativeInteger(data.get(tlv::RemainingTries));
}
if (data.find(tlv::RemainingTime) != data.elements_end()) {
- state.m_freshBefore = time::system_clock::now() + time::seconds(readNonNegativeInteger(data.get(tlv::RemainingTime)));
+ state.freshBefore = time::system_clock::now() + time::seconds(readNonNegativeInteger(data.get(tlv::RemainingTime)));
}
if (data.find(tlv::IssuedCertName) != data.elements_end()) {
Block issuedCertNameBlock = data.get(tlv::IssuedCertName);
- state.m_issuedCertName = Name(issuedCertNameBlock.blockFromValue());
+ state.issuedCertName = Name(issuedCertNameBlock.blockFromValue());
}
}
diff --git a/src/detail/new-renew-revoke-encoder.cpp b/src/detail/new-renew-revoke-encoder.cpp
index fa4626c..a2645e9 100644
--- a/src/detail/new-renew-revoke-encoder.cpp
+++ b/src/detail/new-renew-revoke-encoder.cpp
@@ -82,7 +82,7 @@
Block
requesttlv::encodeDataContent(const std::vector<uint8_t>& ecdhKey, const std::array<uint8_t, 32>& salt,
const RequestId& requestId, const Status& status,
- const std::list<std::string>& challenges)
+ const std::vector<std::string>& challenges)
{
Block response(ndn::tlv::Content);
response.push_back(makeBinaryBlock(tlv::EcdhPub, ecdhKey.data(), ecdhKey.size()));
diff --git a/src/detail/new-renew-revoke-encoder.hpp b/src/detail/new-renew-revoke-encoder.hpp
index 563e562..2b8e0e2 100644
--- a/src/detail/new-renew-revoke-encoder.hpp
+++ b/src/detail/new-renew-revoke-encoder.hpp
@@ -38,7 +38,7 @@
Block
encodeDataContent(const std::vector<uint8_t>& ecdhKey, const std::array<uint8_t, 32>& salt,
const RequestId& requestId, const Status& status,
- const std::list<std::string>& challenges);
+ const std::vector<std::string>& challenges);
std::list<std::string>
decodeDataContent(const Block& content, std::vector<uint8_t>& ecdhKey,
diff --git a/src/detail/probe-encoder.cpp b/src/detail/probe-encoder.cpp
index d671aef..24471a7 100644
--- a/src/detail/probe-encoder.cpp
+++ b/src/detail/probe-encoder.cpp
@@ -51,7 +51,7 @@
Block
probetlv::encodeDataContent(const std::vector<Name>& identifiers, optional<size_t> maxSuffixLength,
- optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems)
+ std::vector<std::shared_ptr<security::Certificate>> redirectionItems)
{
Block content(ndn::tlv::Content);
for (const auto& name : identifiers) {
@@ -62,10 +62,8 @@
}
content.push_back(item);
}
- if (redirectionItems) {
- for (const auto& item : *redirectionItems) {
- content.push_back(makeNestedBlock(tlv::ProbeRedirect, item->getFullName()));
- }
+ for (const auto& item : redirectionItems) {
+ content.push_back(makeNestedBlock(tlv::ProbeRedirect, item->getFullName()));
}
content.encode();
return content;
@@ -83,18 +81,18 @@
Name elementName;
int maxSuffixLength = 0;
for (const auto& subBlock : item.elements()) {
- if (subBlock.type() == ndn::tlv::Name) {
- if (!elementName.empty()) {
- NDN_THROW(std::runtime_error("Invalid probe format"));
- }
- elementName.wireDecode(subBlock);
+ if (subBlock.type() == ndn::tlv::Name) {
+ if (!elementName.empty()) {
+ NDN_THROW(std::runtime_error("Invalid probe format"));
}
- else if (subBlock.type() == tlv::MaxSuffixLength) {
- maxSuffixLength = readNonNegativeInteger(subBlock);
- }
+ elementName.wireDecode(subBlock);
+ }
+ else if (subBlock.type() == tlv::MaxSuffixLength) {
+ maxSuffixLength = readNonNegativeInteger(subBlock);
+ }
}
if (elementName.empty()) {
- NDN_THROW(std::runtime_error("Invalid probe format"));
+ NDN_THROW(std::runtime_error("Invalid probe format"));
}
availableNames.emplace_back(elementName, maxSuffixLength);
}
diff --git a/src/detail/probe-encoder.hpp b/src/detail/probe-encoder.hpp
index bde8a87..58bcb44 100644
--- a/src/detail/probe-encoder.hpp
+++ b/src/detail/probe-encoder.hpp
@@ -39,7 +39,8 @@
Block
encodeDataContent(const std::vector<Name>& identifiers,
optional<size_t> maxSuffixLength = nullopt,
- optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems = nullopt);
+ std::vector<std::shared_ptr<security::Certificate>> redirectionItems =
+ std::vector<std::shared_ptr<security::Certificate>>());
std::multimap<std::string, std::string>
decodeApplicationParameters(const Block& block);