NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
command-validator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #ifndef NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
26 #define NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
27 
28 #include "common.hpp"
29 #include "config-file.hpp"
30 #include <ndn-cxx/util/command-interest-validator.hpp>
31 
32 namespace nfd {
33 
35 {
36 public:
37 
38  class Error : public std::runtime_error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : std::runtime_error(what)
44  {
45 
46  }
47  };
48 
50 
52 
53  void
54  setConfigFile(ConfigFile& configFile);
55 
62  void
63  onConfig(const ConfigSection& section, bool isDryRun, const std::string& filename);
64 
69  void
70  addSupportedPrivilege(const std::string& privilege);
71 
72  void
73  addInterestRule(const std::string& regex,
74  const ndn::IdentityCertificate& certificate);
75 
76  void
77  addInterestRule(const std::string& regex,
78  const Name& keyName,
79  const ndn::PublicKey& publicKey);
80 
81  void
82  validate(const Interest& interest,
83  const ndn::OnInterestValidated& onValidated,
84  const ndn::OnInterestValidationFailed& onValidationFailed);
85 
86 private:
87  ndn::CommandInterestValidator m_validator;
88  std::set<std::string> m_supportedPrivileges;
89 };
90 
91 inline void
92 CommandValidator::addInterestRule(const std::string& regex,
93  const ndn::IdentityCertificate& certificate)
94 {
95  m_validator.addInterestRule(regex, certificate);
96 }
97 
98 inline void
99 CommandValidator::addInterestRule(const std::string& regex,
100  const Name& keyName,
101  const ndn::PublicKey& publicKey)
102 {
103  m_validator.addInterestRule(regex, keyName, publicKey);
104 }
105 
106 inline void
107 CommandValidator::validate(const Interest& interest,
108  const ndn::OnInterestValidated& onValidated,
109  const ndn::OnInterestValidationFailed& onValidationFailed)
110 {
111  m_validator.validate(interest, onValidated, onValidationFailed);
112 }
113 
114 } // namespace nfd
115 
116 #endif // NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
void addInterestRule(const std::string &regex, const ndn::IdentityCertificate &certificate)
void setConfigFile(ConfigFile &configFile)
void onConfig(const ConfigSection &section, bool isDryRun, const std::string &filename)
Error(const std::string &what)
boost::property_tree::ptree ConfigSection
void validate(const Interest &interest, const ndn::OnInterestValidated &onValidated, const ndn::OnInterestValidationFailed &onValidationFailed)
void addSupportedPrivilege(const std::string &privilege)