security: don't throw when loading an empty validation policy
Refs: #5049
Change-Id: I44feff5f4c83995e7d9f848c3c0cd71825920606
diff --git a/ndn-cxx/security/v2/validation-policy-config.cpp b/ndn-cxx/security/v2/validation-policy-config.cpp
index 29d6f8c..d723b94 100644
--- a/ndn-cxx/security/v2/validation-policy-config.cpp
+++ b/ndn-cxx/security/v2/validation-policy-config.cpp
@@ -35,12 +35,6 @@
namespace v2 {
namespace validator_config {
-ValidationPolicyConfig::ValidationPolicyConfig()
- : m_shouldBypass(false)
- , m_isConfigured(false)
-{
-}
-
void
ValidationPolicyConfig::load(const std::string& filename)
{
@@ -75,6 +69,8 @@
void
ValidationPolicyConfig::load(const ConfigSection& configSection, const std::string& filename)
{
+ BOOST_ASSERT(!filename.empty());
+
if (m_validator == nullptr) {
NDN_THROW(Error("Validator instance not assigned on the policy"));
}
@@ -87,12 +83,6 @@
}
m_isConfigured = true;
- BOOST_ASSERT(!filename.empty());
-
- if (configSection.begin() == configSection.end()) {
- NDN_THROW(Error("Error processing configuration file " + filename + ": no data"));
- }
-
for (const auto& subSection : configSection) {
const std::string& sectionName = subSection.first;
const ConfigSection& section = subSection.second;
diff --git a/ndn-cxx/security/v2/validation-policy-config.hpp b/ndn-cxx/security/v2/validation-policy-config.hpp
index 978fdaa..e94ccec 100644
--- a/ndn-cxx/security/v2/validation-policy-config.hpp
+++ b/ndn-cxx/security/v2/validation-policy-config.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,7 +24,6 @@
#include "ndn-cxx/security/v2/validation-policy.hpp"
#include "ndn-cxx/security/v2/validator-config/rule.hpp"
-#include "ndn-cxx/security/v2/validator-config/common.hpp"
namespace ndn {
namespace security {
@@ -32,7 +31,7 @@
namespace validator_config {
/**
- * @brief The validator which can be set up via a configuration file.
+ * @brief A validator that can be set up via a configuration file.
*
* @note For command Interest validation, this policy must be combined with
* @p ValidationPolicyCommandInterest, in order to guard against replay attacks.
@@ -42,8 +41,6 @@
class ValidationPolicyConfig : public ValidationPolicy
{
public:
- ValidationPolicyConfig();
-
/**
* @brief Load policy from file @p filename
* @throw Error Validator instance not assigned to the policy (m_validator == nullptr)
@@ -92,13 +89,13 @@
getDefaultRefreshPeriod();
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
- /** @brief whether to always bypass validation
+ /** @brief Whether to always bypass validation.
*
* This is set to true when 'any' is specified as a trust anchor.
* It causes all packets to bypass validation.
*/
- bool m_shouldBypass;
- bool m_isConfigured;
+ bool m_shouldBypass = false;
+ bool m_isConfigured = false;
std::vector<unique_ptr<Rule>> m_dataRules;
std::vector<unique_ptr<Rule>> m_interestRules;