blob: bc42e527474183b8a0c9a6aee8b976c43b35a626 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -08002/*
Zhiyi Zhang48becde2017-01-05 16:41:38 -08003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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.
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070020 */
21
22#ifndef NDN_SECURITY_VALIDATOR_CONFIG_HPP
23#define NDN_SECURITY_VALIDATOR_CONFIG_HPP
24
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080025#include "v2/validator.hpp"
26#include "v2/validation-policy-command-interest.hpp"
27#include "v2/validation-policy-config.hpp"
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070028
29namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070030namespace security {
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070031
Zhiyi Zhang7ba99e12016-11-10 14:26:16 -080032/**
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080033 * @brief Helper for validator that uses CommandInterest + Config policy and NetworkFetcher
Zhiyi Zhang7ba99e12016-11-10 14:26:16 -080034 */
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080035class ValidatorConfig : public v2::Validator
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070036{
37public:
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080038 using v2::Validator::Validator;
39 using Options = v2::ValidationPolicyCommandInterest::Options;
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070040
Yingdi Yu4e9b0692014-11-04 16:13:56 -080041 explicit
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080042 ValidatorConfig(std::unique_ptr<v2::CertificateFetcher> fetcher, const Options& options = Options());
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070043
Yingdi Yu96e64062014-04-15 19:57:33 -070044 explicit
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080045 ValidatorConfig(Face& face, const Options& options = Options());
Yingdi Yu96e64062014-04-15 19:57:33 -070046
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080047public: // helpers for ValidationPolicyConfig
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070048 void
49 load(const std::string& filename);
50
51 void
52 load(const std::string& input, const std::string& filename);
53
54 void
55 load(std::istream& input, const std::string& filename);
56
Yingdi Yudfa9d732014-04-09 09:53:01 -070057 void
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080058 load(const v2::validator_config::ConfigSection& configSection,
Yingdi Yudfa9d732014-04-09 09:53:01 -070059 const std::string& filename);
60
Zhiyi Zhang044bb7e2016-06-10 00:02:37 -070061NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080062 v2::ValidationPolicyConfig& m_policyConfig;
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070063};
64
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070065} // namespace security
66
67using security::ValidatorConfig;
68
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070069} // namespace ndn
70
71#endif // NDN_SECURITY_VALIDATOR_CONFIG_HPP