Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California. |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 4 | * |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 5 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 6 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 7 | * |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 8 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 11 | * |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 12 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 15 | * |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 18 | * |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 19 | * @author Yingdi Yu <yingdi@cs.ucla.edu> |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 22 | #ifndef NDN_TOOLS_PIB_PIB_VALIDATOR_HPP |
| 23 | #define NDN_TOOLS_PIB_PIB_VALIDATOR_HPP |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 24 | |
| 25 | #include "pib-db.hpp" |
| 26 | #include "key-cache.hpp" |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 27 | |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 28 | #include <ndn-cxx/security/validator.hpp> |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace pib { |
| 32 | |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 33 | /* |
| 34 | * @brief The validator to verify the command interests to PIB service |
| 35 | * |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 36 | * @sa https://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 37 | */ |
| 38 | class PibValidator : public Validator |
| 39 | { |
| 40 | struct UserKeyCache; |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 41 | |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 42 | public: |
| 43 | explicit |
| 44 | PibValidator(const PibDb& pibDb, |
| 45 | size_t maxCacheSize = 1000); |
| 46 | |
| 47 | ~PibValidator(); |
| 48 | |
| 49 | protected: |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 50 | void |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 51 | checkPolicy(const Interest& interest, |
| 52 | int nSteps, |
| 53 | const OnInterestValidated& onValidated, |
| 54 | const OnInterestValidationFailed& onValidationFailed, |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 55 | std::vector<shared_ptr<ValidationRequest>>& nextSteps) override; |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 56 | |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 57 | void |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 58 | checkPolicy(const Data& data, |
| 59 | int nSteps, |
| 60 | const OnDataValidated& onValidated, |
| 61 | const OnDataValidationFailed& onValidationFailed, |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 62 | std::vector<shared_ptr<ValidationRequest>>& nextSteps) override; |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 63 | |
| 64 | private: |
Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 65 | const PibDb& m_db; |
| 66 | |
| 67 | bool m_isMgmtReady; |
| 68 | std::string m_owner; |
| 69 | shared_ptr<IdentityCertificate> m_mgmtCert; |
| 70 | |
| 71 | KeyCache m_keyCache; |
| 72 | |
| 73 | util::signal::ScopedConnection m_mgmtChangeConnection; |
| 74 | util::signal::ScopedConnection m_keyDeletedConnection; |
| 75 | }; |
| 76 | |
| 77 | } // namespace pib |
| 78 | } // namespace ndn |
| 79 | |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame] | 80 | #endif // NDN_TOOLS_PIB_PIB_VALIDATOR_HPP |