tools: switch to v2::Validator in nfdc
"nfdid" field in 'nfdc status show' command is temporarily unavailable
because NfdIdCollector relies on v1 Validator. It will be re-implemented
in a future commit.
refs #4089
Change-Id: I21feae43055a17438d8bd3c0439ae4e0a2d5d14c
diff --git a/tests/tools/nfdc/forwarder-general-module.t.cpp b/tests/tools/nfdc/forwarder-general-module.t.cpp
index d7ac0a3..f97d36d 100644
--- a/tests/tools/nfdc/forwarder-general-module.t.cpp
+++ b/tests/tools/nfdc/forwarder-general-module.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -36,23 +36,22 @@
BOOST_AUTO_TEST_SUITE(Nfdc)
BOOST_FIXTURE_TEST_SUITE(TestForwarderGeneralModule, StatusFixture<ForwarderGeneralModule>)
-class MakeNfdIdCollector
-{
-public:
- unique_ptr<NfdIdCollector>
- operator()(Face&, KeyChain&) const
- {
- return make_unique<NfdIdCollector>(make_unique<ValidatorNull>());
- };
-};
+// class MakeNfdIdCollector
+// {
+// public:
+// unique_ptr<NfdIdCollector>
+// operator()(Face&, KeyChain&) const
+// {
+// return make_unique<NfdIdCollector>(make_unique<ValidatorNull>());
+// };
+// };
-class ForwarderGeneralStatusFixture : public StatusFixture<ForwarderGeneralModule,
- MakeNfdIdCollector>
+class ForwarderGeneralStatusFixture : public StatusFixture<ForwarderGeneralModule>
{
protected:
ForwarderGeneralStatusFixture()
{
- module.setNfdIdCollector(*validator);
+ // module.setNfdIdCollector(*validator);
BOOST_REQUIRE(this->addIdentity("/nfd-status/test-nfdid",
ndn::EcKeyParams(name::Component("KEYID"))));
@@ -68,7 +67,7 @@
const std::string STATUS_XML = stripXmlSpaces(R"XML(
<generalStatus>
- <nfdId>/nfd-status/test-nfdid/KEY/KEYID</nfdId>
+ <nfdId>/nfdId-unavailable</nfdId>
<version>0.4.1-1-g704430c</version>
<startTime>2016-06-24T15:13:46.856000</startTime>
<currentTime>2016-07-17T17:55:54.109000</currentTime>
@@ -95,7 +94,7 @@
const std::string STATUS_TEXT = std::string(R"TEXT(
General NFD status:
- nfdId=/nfd-status/test-nfdid/KEY/KEYID
+ nfdId=/nfdId-unavailable
version=0.4.1-1-g704430c
startTime=20160624T151346.856000
currentTime=20160717T175554.109000
diff --git a/tests/tools/nfdc/status-fixture.hpp b/tests/tools/nfdc/status-fixture.hpp
index 2d33d37..b955f7a 100644
--- a/tests/tools/nfdc/status-fixture.hpp
+++ b/tests/tools/nfdc/status-fixture.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -37,8 +37,8 @@
using ndn::Face;
using ndn::KeyChain;
-using ndn::Validator;
-using ndn::ValidatorNull;
+using ndn::security::v2::Validator;
+using ndn::security::v2::ValidatorNull;
using boost::test_tools::output_test_stream;
class MakeValidatorNull
diff --git a/tools/nfdc/face-id-fetcher.cpp b/tools/nfdc/face-id-fetcher.cpp
index 458b9bb..f0bf841 100644
--- a/tools/nfdc/face-id-fetcher.cpp
+++ b/tools/nfdc/face-id-fetcher.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -30,6 +30,7 @@
#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
+#include <ndn-cxx/security/validator-null.hpp>
#include <ndn-cxx/util/segment-fetcher.hpp>
namespace nfd {
@@ -114,7 +115,7 @@
auto interest = std::make_shared<ndn::Interest>(interestPacket);
ndn::util::SegmentFetcher::fetch(
- m_face, *interest, m_validator,
+ m_face, *interest, ndn::security::v2::getAcceptAllValidator(),
bind(&FaceIdFetcher::onQuerySuccess, this, _1, canonicalUri),
bind(&FaceIdFetcher::onQueryFailure, this, _1, canonicalUri));
}
diff --git a/tools/nfdc/face-id-fetcher.hpp b/tools/nfdc/face-id-fetcher.hpp
index 7c9a40f..5e45b7b 100644
--- a/tools/nfdc/face-id-fetcher.hpp
+++ b/tools/nfdc/face-id-fetcher.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -29,7 +29,6 @@
#include "core/common.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
-#include <ndn-cxx/security/validator-null.hpp>
namespace nfd {
namespace tools {
@@ -100,7 +99,6 @@
bool m_allowCreate;
SuccessCallback m_onSucceed;
FailureCallback m_onFail;
- ndn::ValidatorNull m_validator;
};
} // namespace nfdc
diff --git a/tools/nfdc/forwarder-general-module.hpp b/tools/nfdc/forwarder-general-module.hpp
index f8c30d8..9fc6a68 100644
--- a/tools/nfdc/forwarder-general-module.hpp
+++ b/tools/nfdc/forwarder-general-module.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,7 +45,7 @@
public:
ForwarderGeneralModule();
- virtual void
+ void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
const Controller::DatasetFailCallback& onFailure,
@@ -57,7 +57,7 @@
m_nfdIdCollector = &nfdIdCollector;
}
- virtual void
+ void
formatStatusXml(std::ostream& os) const override;
/** \brief format a single status item as XML
@@ -68,7 +68,7 @@
void
formatItemXml(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
- virtual void
+ void
formatStatusText(std::ostream& os) const override;
/** \brief format a single status item as text
@@ -94,6 +94,8 @@
* This validator redirects all validation requests to an inner validator.
* For the first Data packet accepted by the inner validator that has a Name in KeyLocator,
* this Name is collected as NFD's signing certificate name.
+ *
+ * \todo #4089 re-implement as v2 ValidationPolicy
*/
class NfdIdCollector : public ndn::Validator
{
@@ -111,7 +113,7 @@
getNfdId() const;
protected:
- virtual void
+ void
checkPolicy(const Interest& interest, int nSteps,
const ndn::OnInterestValidated& accept,
const ndn::OnInterestValidationFailed& reject,
@@ -121,7 +123,7 @@
m_inner->validate(interest, accept, reject);
}
- virtual void
+ void
checkPolicy(const Data& data, int nSteps,
const ndn::OnDataValidated& accept,
const ndn::OnDataValidationFailed& reject,
diff --git a/tools/nfdc/module.hpp b/tools/nfdc/module.hpp
index 553c14f..765e39b 100644
--- a/tools/nfdc/module.hpp
+++ b/tools/nfdc/module.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,14 +27,15 @@
#define NFD_TOOLS_NFDC_MODULE_HPP
#include "core/common.hpp"
+#include <ndn-cxx/mgmt/nfd/command-options.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
namespace nfd {
namespace tools {
namespace nfdc {
-using ndn::nfd::Controller;
using ndn::nfd::CommandOptions;
+using ndn::nfd::Controller;
/** \brief provides access to an NFD management module
* \note This type is an interface. It should not have member fields.
diff --git a/tools/nfdc/status-report.hpp b/tools/nfdc/status-report.hpp
index 153751a..1658852 100644
--- a/tools/nfdc/status-report.hpp
+++ b/tools/nfdc/status-report.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -27,6 +27,9 @@
#define NFD_TOOLS_NFDC_STATUS_REPORT_HPP
#include "module.hpp"
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/v2/validator.hpp>
namespace nfd {
namespace tools {
@@ -34,7 +37,7 @@
using ndn::Face;
using ndn::KeyChain;
-using ndn::Validator;
+using ndn::security::v2::Validator;
enum class ReportFormat {
XML = 1,
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index f87cd8b..529ee82 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -40,17 +40,17 @@
void
reportStatus(ExecuteContext& ctx, const StatusReportOptions& options)
{
- unique_ptr<Validator> validator = make_unique<ndn::ValidatorNull>();
+ unique_ptr<ndn::security::v2::Validator> validator = make_unique<ndn::security::v2::ValidatorNull>();
CommandOptions ctrlOptions;
StatusReport report;
if (options.wantForwarderGeneral) {
- auto nfdIdCollector = make_unique<NfdIdCollector>(std::move(validator));
+ // auto nfdIdCollector = make_unique<NfdIdCollector>(std::move(validator));
auto forwarderGeneralModule = make_unique<ForwarderGeneralModule>();
- forwarderGeneralModule->setNfdIdCollector(*nfdIdCollector);
+ // forwarderGeneralModule->setNfdIdCollector(*nfdIdCollector);
report.sections.push_back(std::move(forwarderGeneralModule));
- validator = std::move(nfdIdCollector);
+ // validator = std::move(nfdIdCollector);
}
if (options.wantChannels) {