blob: a8c5abcff3503014da7cdc82ff2ad63ea926e3f9 [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#include "validator-config.hpp"
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080023#include "v2/certificate-fetcher-from-network.hpp"
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070024
25namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070026namespace security {
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070027
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080028ValidatorConfig::ValidatorConfig(std::unique_ptr<v2::CertificateFetcher> fetcher, const Options& options)
29 : v2::Validator(make_unique<v2::ValidationPolicyCommandInterest>(make_unique<v2::ValidationPolicyConfig>(),
30 options),
31 std::move(fetcher))
32 , m_policyConfig(static_cast<v2::ValidationPolicyConfig&>(getPolicy().getInnerPolicy()))
Yingdi Yu4e9b0692014-11-04 16:13:56 -080033{
Yingdi Yu4e9b0692014-11-04 16:13:56 -080034}
35
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080036ValidatorConfig::ValidatorConfig(Face& face, const Options& options)
37 : ValidatorConfig(make_unique<v2::CertificateFetcherFromNetwork>(face), options)
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070038{
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070039}
40
41void
42ValidatorConfig::load(const std::string& filename)
43{
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080044 m_policyConfig.load(filename);
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070045}
46
47void
48ValidatorConfig::load(const std::string& input, const std::string& filename)
49{
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080050 m_policyConfig.load(input, filename);
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070051}
52
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070053void
54ValidatorConfig::load(std::istream& input, const std::string& filename)
55{
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080056 m_policyConfig.load(input, filename);
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070057}
58
59void
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080060ValidatorConfig::load(const v2::validator_config::ConfigSection& configSection,
Yingdi Yudfa9d732014-04-09 09:53:01 -070061 const std::string& filename)
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070062{
Alexander Afanasyeve5a19b82017-01-30 22:30:46 -080063 m_policyConfig.load(configSection, filename);
Yingdi Yu4e9b0692014-11-04 16:13:56 -080064}
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070065
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070066} // namespace security
Yingdi Yu48e8c0c2014-03-19 12:01:55 -070067} // namespace ndn