blob: 0bdf3575a3cf69c89267c8f32b2e65999de90ecd [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesaventoc0702702017-08-24 22:04:00 -04003 * Copyright (c) 2014-2017, Regents of the University of California.
Yingdi Yu77627ab2015-07-21 16:13:49 -07004 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07005 * 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 Yu77627ab2015-07-21 16:13:49 -07007 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07008 * 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 Yu77627ab2015-07-21 16:13:49 -070011 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070012 * 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 Yu77627ab2015-07-21 16:13:49 -070015 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070016 * 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 Yu77627ab2015-07-21 16:13:49 -070018 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070019 * @author Yingdi Yu <yingdi@cs.ucla.edu>
Yingdi Yu77627ab2015-07-21 16:13:49 -070020 */
21
Yingdi Yu0a312e52015-07-22 13:14:53 -070022#ifndef NDN_TOOLS_PIB_PIB_VALIDATOR_HPP
23#define NDN_TOOLS_PIB_PIB_VALIDATOR_HPP
Yingdi Yu77627ab2015-07-21 16:13:49 -070024
25#include "pib-db.hpp"
26#include "key-cache.hpp"
Davide Pesaventoc0702702017-08-24 22:04:00 -040027
Yingdi Yu77627ab2015-07-21 16:13:49 -070028#include <ndn-cxx/security/validator.hpp>
Yingdi Yu77627ab2015-07-21 16:13:49 -070029
30namespace ndn {
31namespace pib {
32
Yingdi Yu77627ab2015-07-21 16:13:49 -070033/*
34 * @brief The validator to verify the command interests to PIB service
35 *
Davide Pesaventoc0702702017-08-24 22:04:00 -040036 * @sa https://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base
Yingdi Yu77627ab2015-07-21 16:13:49 -070037 */
38class PibValidator : public Validator
39{
40 struct UserKeyCache;
Davide Pesaventoc0702702017-08-24 22:04:00 -040041
Yingdi Yu77627ab2015-07-21 16:13:49 -070042public:
43 explicit
44 PibValidator(const PibDb& pibDb,
45 size_t maxCacheSize = 1000);
46
47 ~PibValidator();
48
49protected:
Davide Pesaventoc0702702017-08-24 22:04:00 -040050 void
Yingdi Yu77627ab2015-07-21 16:13:49 -070051 checkPolicy(const Interest& interest,
52 int nSteps,
53 const OnInterestValidated& onValidated,
54 const OnInterestValidationFailed& onValidationFailed,
Davide Pesaventoc0702702017-08-24 22:04:00 -040055 std::vector<shared_ptr<ValidationRequest>>& nextSteps) override;
Yingdi Yu77627ab2015-07-21 16:13:49 -070056
Davide Pesaventoc0702702017-08-24 22:04:00 -040057 void
Yingdi Yu77627ab2015-07-21 16:13:49 -070058 checkPolicy(const Data& data,
59 int nSteps,
60 const OnDataValidated& onValidated,
61 const OnDataValidationFailed& onValidationFailed,
Davide Pesaventoc0702702017-08-24 22:04:00 -040062 std::vector<shared_ptr<ValidationRequest>>& nextSteps) override;
Yingdi Yu77627ab2015-07-21 16:13:49 -070063
64private:
Yingdi Yu77627ab2015-07-21 16:13:49 -070065 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 Yu0a312e52015-07-22 13:14:53 -070080#endif // NDN_TOOLS_PIB_PIB_VALIDATOR_HPP