tools: delete nfdId from 'nfdc status' output

refs #4089

Change-Id: I95f8a4346b2c4601acdc63daac20259b076a1d7e
diff --git a/tools/nfdc/forwarder-general-module.cpp b/tools/nfdc/forwarder-general-module.cpp
index ee3e0af..e490892 100644
--- a/tools/nfdc/forwarder-general-module.cpp
+++ b/tools/nfdc/forwarder-general-module.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,
@@ -30,11 +30,6 @@
 namespace tools {
 namespace nfdc {
 
-ForwarderGeneralModule::ForwarderGeneralModule()
-  : m_nfdIdCollector(nullptr)
-{
-}
-
 void
 ForwarderGeneralModule::fetchStatus(Controller& controller,
                                     const function<void()>& onSuccess,
@@ -55,30 +50,17 @@
   return status.getCurrentTimestamp() - status.getStartTimestamp();
 }
 
-const Name&
-ForwarderGeneralModule::getNfdId() const
-{
-  if (m_nfdIdCollector != nullptr && m_nfdIdCollector->hasNfdId()) {
-    return m_nfdIdCollector->getNfdId();
-  }
-
-  static Name unavailable("/nfdId-unavailable");
-  return unavailable;
-}
-
 void
 ForwarderGeneralModule::formatStatusXml(std::ostream& os) const
 {
-  this->formatItemXml(os, m_status, this->getNfdId());
+  this->formatItemXml(os, m_status);
 }
 
 void
-ForwarderGeneralModule::formatItemXml(std::ostream& os, const ForwarderStatus& item,
-                                      const Name& nfdId) const
+ForwarderGeneralModule::formatItemXml(std::ostream& os, const ForwarderStatus& item) const
 {
   os << "<generalStatus>";
 
-  os << "<nfdId>" << nfdId << "</nfdId>";
   os << "<version>" << xml::Text{item.getNfdVersion()} << "</version>";
   os << "<startTime>" << xml::formatTimestamp(item.getStartTimestamp()) << "</startTime>";
   os << "<currentTime>" << xml::formatTimestamp(item.getCurrentTimestamp()) << "</currentTime>";
@@ -110,14 +92,12 @@
 ForwarderGeneralModule::formatStatusText(std::ostream& os) const
 {
   os << "General NFD status:\n";
-  this->formatItemText(os, m_status, this->getNfdId());
+  this->formatItemText(os, m_status);
 }
 
 void
-ForwarderGeneralModule::formatItemText(std::ostream& os, const ForwarderStatus& item,
-                                       const Name& nfdId) const
+ForwarderGeneralModule::formatItemText(std::ostream& os, const ForwarderStatus& item) const
 {
-  os << "                 nfdId=" << nfdId << "\n";
   os << "               version=" << item.getNfdVersion() << "\n";
   os << "             startTime=" << text::formatTimestamp(item.getStartTimestamp()) << "\n";
   os << "           currentTime=" << text::formatTimestamp(item.getCurrentTimestamp()) << "\n";
@@ -137,54 +117,6 @@
   os << "             nOutNacks=" << item.getNOutNacks() << "\n";
 }
 
-NfdIdCollector::NfdIdCollector(unique_ptr<ndn::Validator> inner)
-  : m_inner(std::move(inner))
-  , m_hasNfdId(false)
-{
-  BOOST_ASSERT(m_inner != nullptr);
-}
-
-const Name&
-NfdIdCollector::getNfdId() const
-{
-  if (!m_hasNfdId) {
-    BOOST_THROW_EXCEPTION(std::runtime_error("NfdId is unavailable"));
-  }
-
-  return m_nfdId;
-}
-
-void
-NfdIdCollector::checkPolicy(const Data& data, int nSteps,
-                            const ndn::OnDataValidated& accept,
-                            const ndn::OnDataValidationFailed& reject,
-                            std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps)
-{
-  ndn::OnDataValidated accepted = [this, accept] (const shared_ptr<const Data>& data) {
-    accept(data); // pass the Data to Validator user's validated callback
-
-    if (m_hasNfdId) {
-      return;
-    }
-
-    const ndn::Signature& sig = data->getSignature();
-    if (!sig.hasKeyLocator()) {
-      return;
-    }
-
-    const ndn::KeyLocator& kl = sig.getKeyLocator();
-    if (kl.getType() != ndn::KeyLocator::KeyLocator_Name) {
-      return;
-    }
-
-    m_nfdId = kl.getName();
-    m_hasNfdId = true;
-  };
-
-  BOOST_ASSERT(nSteps == 0);
-  m_inner->validate(data, accepted, reject);
-}
-
 } // namespace nfdc
 } // namespace tools
 } // namespace nfd
diff --git a/tools/nfdc/forwarder-general-module.hpp b/tools/nfdc/forwarder-general-module.hpp
index 9fc6a68..4d65c83 100644
--- a/tools/nfdc/forwarder-general-module.hpp
+++ b/tools/nfdc/forwarder-general-module.hpp
@@ -27,7 +27,6 @@
 #define NFD_TOOLS_NFDC_FORWARDER_GENERAL_MODULE_HPP
 
 #include "module.hpp"
-#include <ndn-cxx/security/validator.hpp>
 
 namespace nfd {
 namespace tools {
@@ -35,16 +34,12 @@
 
 using ndn::nfd::ForwarderStatus;
 
-class NfdIdCollector;
-
 /** \brief provides access to NFD forwarder general status
  *  \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
  */
 class ForwarderGeneralModule : public Module, noncopyable
 {
 public:
-  ForwarderGeneralModule();
-
   void
   fetchStatus(Controller& controller,
               const function<void()>& onSuccess,
@@ -52,21 +47,14 @@
               const CommandOptions& options) override;
 
   void
-  setNfdIdCollector(const NfdIdCollector& nfdIdCollector)
-  {
-    m_nfdIdCollector = &nfdIdCollector;
-  }
-
-  void
   formatStatusXml(std::ostream& os) const override;
 
   /** \brief format a single status item as XML
    *  \param os output stream
    *  \param item status item
-   *  \param nfdId NFD's signing certificate name
    */
   void
-  formatItemXml(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
+  formatItemXml(std::ostream& os, const ForwarderStatus& item) const;
 
   void
   formatStatusText(std::ostream& os) const override;
@@ -74,67 +62,14 @@
   /** \brief format a single status item as text
    *  \param os output stream
    *  \param item status item
-   *  \param nfdId NFD's signing certificate name
    */
   void
-  formatItemText(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
+  formatItemText(std::ostream& os, const ForwarderStatus& item) const;
 
 private:
-  const Name&
-  getNfdId() const;
-
-private:
-  const NfdIdCollector* m_nfdIdCollector;
   ForwarderStatus m_status;
 };
 
-
-/** \brief a validator that can collect NFD's signing certificate name
- *
- *  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
-{
-public:
-  explicit
-  NfdIdCollector(unique_ptr<ndn::Validator> inner);
-
-  bool
-  hasNfdId() const
-  {
-    return m_hasNfdId;
-  }
-
-  const Name&
-  getNfdId() const;
-
-protected:
-  void
-  checkPolicy(const Interest& interest, int nSteps,
-              const ndn::OnInterestValidated& accept,
-              const ndn::OnInterestValidationFailed& reject,
-              std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override
-  {
-    BOOST_ASSERT(nSteps == 0);
-    m_inner->validate(interest, accept, reject);
-  }
-
-  void
-  checkPolicy(const Data& data, int nSteps,
-              const ndn::OnDataValidated& accept,
-              const ndn::OnDataValidationFailed& reject,
-              std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override;
-
-private:
-  unique_ptr<ndn::Validator> m_inner;
-  bool m_hasNfdId;
-  Name m_nfdId;
-};
-
 } // namespace nfdc
 } // namespace tools
 } // namespace nfd
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index 529ee82..01222c8 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.cpp
@@ -40,17 +40,10 @@
 void
 reportStatus(ExecuteContext& ctx, const StatusReportOptions& options)
 {
-  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 forwarderGeneralModule = make_unique<ForwarderGeneralModule>();
-    // forwarderGeneralModule->setNfdIdCollector(*nfdIdCollector);
-    report.sections.push_back(std::move(forwarderGeneralModule));
-    // validator = std::move(nfdIdCollector);
+    report.sections.push_back(make_unique<ForwarderGeneralModule>());
   }
 
   if (options.wantChannels) {
@@ -73,7 +66,9 @@
     report.sections.push_back(make_unique<StrategyChoiceModule>());
   }
 
-  uint32_t code = report.collect(ctx.face, ctx.keyChain, *validator, ctrlOptions);
+  uint32_t code = report.collect(ctx.face, ctx.keyChain,
+                                 ndn::security::v2::getAcceptAllValidator(),
+                                 CommandOptions());
   if (code != 0) {
     ctx.exitCode = 1;
     // Give a simple error code for end user.