blob: 9d7a3e1530b177da1e1767e5c95a6e424f45582c [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2015 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#ifndef NDN_PIB_PIB_VALIDATOR_HPP
23#define NDN_PIB_PIB_VALIDATOR_HPP
24
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
81#endif // NDN_PIB_PIB_VALIDATOR_HPP