blob: 8b303f585edaf80b37177c93fe579cc4633006a1 [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yingdi Yu0a312e52015-07-22 13:14:53 -07003 * Copyright (c) 2014-2015, 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"
27#include <ndn-cxx/security/validator.hpp>
28#include <unordered_map>
29
30namespace ndn {
31namespace 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 */
39class PibValidator : public Validator
40{
41 struct UserKeyCache;
42public:
43 explicit
44 PibValidator(const PibDb& pibDb,
45 size_t maxCacheSize = 1000);
46
47 ~PibValidator();
48
49protected:
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
64private:
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 Yu0a312e52015-07-22 13:14:53 -070081#endif // NDN_TOOLS_PIB_PIB_VALIDATOR_HPP