Yingdi Yu | 77627ab | 2015-07-21 16:13:49 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2014-2015, 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" |
| 27 | #include <ndn-cxx/security/validator.hpp> |
| 28 | #include <unordered_map> |
| 29 | |
| 30 | namespace ndn { |
| 31 | namespace pib { |
| 32 | |
| 33 | |
| 34 | /* |
| 35 | * @brief The validator to verify the command interests to PIB service |
| 36 | * |
| 37 | * @sa http://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base |
| 38 | */ |
| 39 | class PibValidator : public Validator |
| 40 | { |
| 41 | struct UserKeyCache; |
| 42 | public: |
| 43 | explicit |
| 44 | PibValidator(const PibDb& pibDb, |
| 45 | size_t maxCacheSize = 1000); |
| 46 | |
| 47 | ~PibValidator(); |
| 48 | |
| 49 | protected: |
| 50 | virtual void |
| 51 | checkPolicy(const Interest& interest, |
| 52 | int nSteps, |
| 53 | const OnInterestValidated& onValidated, |
| 54 | const OnInterestValidationFailed& onValidationFailed, |
| 55 | std::vector<shared_ptr<ValidationRequest>>& nextSteps); |
| 56 | |
| 57 | virtual void |
| 58 | checkPolicy(const Data& data, |
| 59 | int nSteps, |
| 60 | const OnDataValidated& onValidated, |
| 61 | const OnDataValidationFailed& onValidationFailed, |
| 62 | std::vector<shared_ptr<ValidationRequest>>& nextSteps); |
| 63 | |
| 64 | private: |
| 65 | |
| 66 | const PibDb& m_db; |
| 67 | |
| 68 | bool m_isMgmtReady; |
| 69 | std::string m_owner; |
| 70 | shared_ptr<IdentityCertificate> m_mgmtCert; |
| 71 | |
| 72 | KeyCache m_keyCache; |
| 73 | |
| 74 | util::signal::ScopedConnection m_mgmtChangeConnection; |
| 75 | util::signal::ScopedConnection m_keyDeletedConnection; |
| 76 | }; |
| 77 | |
| 78 | } // namespace pib |
| 79 | } // namespace ndn |
| 80 | |
Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame^] | 81 | #endif // NDN_TOOLS_PIB_PIB_VALIDATOR_HPP |