blob: a6024974602031e8b97c2b088067ab6ccfc73cc1 [file] [log] [blame]
alvy297f4162015-03-03 17:15:33 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, The University of Memphis,
alvy297f4162015-03-03 17:15:33 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
6 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 **/
21
dmcoomese689dd62017-03-29 11:05:12 -050022#ifndef NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP
23#define NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP
alvy297f4162015-03-03 17:15:33 -060024
Laqin Fan54a43f02017-03-08 12:31:30 -060025#include "manager-base.hpp"
26#include "prefix-update-commands.hpp"
alvy297f4162015-03-03 17:15:33 -060027#include "test-access-control.hpp"
alvy297f4162015-03-03 17:15:33 -060028
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050029#include <ndn-cxx/util/io.hpp>
alvy297f4162015-03-03 17:15:33 -060030#include <ndn-cxx/security/key-chain.hpp>
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050031#include <ndn-cxx/security/v2/certificate-storage.hpp>
32#include <ndn-cxx/util/io.hpp>
alvy297f4162015-03-03 17:15:33 -060033
alvy297f4162015-03-03 17:15:33 -060034#include <boost/property_tree/ptree.hpp>
Laqin Fan54a43f02017-03-08 12:31:30 -060035#include <memory>
alvy297f4162015-03-03 17:15:33 -060036
37namespace nlsr {
38
Vince Lehmanc2acdcb2015-04-29 11:14:35 -050039namespace security {
40 class CertificateStore;
Nick G97e34942016-07-11 14:46:27 -050041} // namespace security
Vince Lehmanc2acdcb2015-04-29 11:14:35 -050042
alvy297f4162015-03-03 17:15:33 -060043namespace update {
44
45typedef boost::property_tree::ptree ConfigSection;
46
Laqin Fan54a43f02017-03-08 12:31:30 -060047class PrefixUpdateProcessor : public CommandManagerBase
alvy297f4162015-03-03 17:15:33 -060048{
49public:
Laqin Fan54a43f02017-03-08 12:31:30 -060050 PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher,
51 ndn::Face& face,
alvy297f4162015-03-03 17:15:33 -060052 NamePrefixList& namePrefixList,
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050053 Lsdb& lsdb);
Nick Gordond0a7df32017-05-30 16:44:34 -050054
55 /*! \brief Load the validator's configuration from a section of a
56 * configuration file.
57 * \sa ConfFileProcessor::processConfFile
58 * \sa ConfFileProcessor::processConfSectionSecurity
59 *
60 * Loads the state of the validator for prefix update commands by
61 * reading a section from a configuration file. This function is
62 * expecting the section to be from a Boost property tree object.
63 *
64 * \throws PrefixUpdateProcessor::Error If configuration fails to load successfully
65 */
alvy297f4162015-03-03 17:15:33 -060066 void
67 loadValidator(ConfigSection section, const std::string& filename);
68
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050069 ndn::security::ValidatorConfig&
alvy297f4162015-03-03 17:15:33 -060070 getValidator()
71 {
72 return m_validator;
73 }
74
75private:
Laqin Fan54a43f02017-03-08 12:31:30 -060076 /*! \brief an authorization function for prefix-update module and verb(advertise/withdraw)
77 * accept if the verb is advertise/withdraw
78 * reject if the verb is not advertise/withdraw
79 \retval an Authorization function
80 \sa Nlsr::getDispatcher()
81 */
82 ndn::mgmt::Authorization
83 makeAuthorization();
84
85private:
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -050086 ndn::security::ValidatorConfig m_validator;
alvy297f4162015-03-03 17:15:33 -060087};
88
89} // namespace update
90} // namespace nlsr
91
dmcoomese689dd62017-03-29 11:05:12 -050092#endif // NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP