alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 4 | * 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 | |
dmcoomes | e689dd6 | 2017-03-29 11:05:12 -0500 | [diff] [blame] | 22 | #ifndef NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP |
| 23 | #define NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 24 | |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 25 | #include "manager-base.hpp" |
| 26 | #include "prefix-update-commands.hpp" |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 27 | #include "test-access-control.hpp" |
| 28 | #include "validator.hpp" |
| 29 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 30 | #include <ndn-cxx/security/certificate-cache-ttl.hpp> |
| 31 | #include <ndn-cxx/security/key-chain.hpp> |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 32 | #include <ndn-cxx/security/v2/validator.hpp> |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 33 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 34 | #include <boost/property_tree/ptree.hpp> |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 35 | #include <memory> |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 36 | |
| 37 | namespace nlsr { |
| 38 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 39 | namespace security { |
| 40 | class CertificateStore; |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 41 | } // namespace security |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 42 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 43 | namespace update { |
| 44 | |
| 45 | typedef boost::property_tree::ptree ConfigSection; |
| 46 | |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 47 | class PrefixUpdateProcessor : public CommandManagerBase |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 48 | { |
| 49 | public: |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 50 | PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher, |
| 51 | ndn::Face& face, |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 52 | NamePrefixList& namePrefixList, |
| 53 | Lsdb& lsdb, |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 54 | const ndn::Name broadcastPrefix, |
| 55 | ndn::KeyChain& keyChain, |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 56 | std::shared_ptr<ndn::CertificateCacheTtl> certificateCache, |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 57 | security::CertificateStore& certStore); |
Nick Gordon | d0a7df3 | 2017-05-30 16:44:34 -0500 | [diff] [blame^] | 58 | |
| 59 | /*! \brief Load the validator's configuration from a section of a |
| 60 | * configuration file. |
| 61 | * \sa ConfFileProcessor::processConfFile |
| 62 | * \sa ConfFileProcessor::processConfSectionSecurity |
| 63 | * |
| 64 | * Loads the state of the validator for prefix update commands by |
| 65 | * reading a section from a configuration file. This function is |
| 66 | * expecting the section to be from a Boost property tree object. |
| 67 | * |
| 68 | * \throws PrefixUpdateProcessor::Error If configuration fails to load successfully |
| 69 | */ |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 70 | void |
| 71 | loadValidator(ConfigSection section, const std::string& filename); |
| 72 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 73 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 74 | Validator& |
| 75 | getValidator() |
| 76 | { |
| 77 | return m_validator; |
| 78 | } |
| 79 | |
| 80 | private: |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame] | 81 | /*! \brief an authorization function for prefix-update module and verb(advertise/withdraw) |
| 82 | * accept if the verb is advertise/withdraw |
| 83 | * reject if the verb is not advertise/withdraw |
| 84 | \retval an Authorization function |
| 85 | \sa Nlsr::getDispatcher() |
| 86 | */ |
| 87 | ndn::mgmt::Authorization |
| 88 | makeAuthorization(); |
| 89 | |
| 90 | private: |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 91 | Validator m_validator; |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | } // namespace update |
| 95 | } // namespace nlsr |
| 96 | |
dmcoomes | e689dd6 | 2017-03-29 11:05:12 -0500 | [diff] [blame] | 97 | #endif // NLSR_UPDATE_PREFIX_UPDATE_PROCESSOR_HPP |