Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 2 | /* |
Davide Pesavento | d01c1a4 | 2019-01-21 21:42:45 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2014-2019, Regents of the University of California. |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS 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. |
| 11 | * |
| 12 | * NDNS 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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 20 | #include "validator.hpp" |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 21 | #include "config.hpp" |
Yumin Xia | fa2bce7 | 2017-04-09 16:20:25 -0700 | [diff] [blame] | 22 | #include "certificate-fetcher-ndns-cert.hpp" |
| 23 | #include "logger.hpp" |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 24 | |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 25 | #include <ndn-cxx/security/v2/validation-policy-config.hpp> |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 26 | |
| 27 | namespace ndn { |
| 28 | namespace ndns { |
Alexander Afanasyev | c7c9900 | 2015-10-09 17:27:30 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | 08d1874 | 2018-03-15 16:31:28 -0400 | [diff] [blame] | 30 | NDNS_LOG_INIT(Validator); |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 31 | |
Davide Pesavento | d01c1a4 | 2019-01-21 21:42:45 -0500 | [diff] [blame^] | 32 | std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE(NDNS_CONFDIR "/validator.conf"); |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 33 | |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 34 | unique_ptr<security::v2::Validator> |
Yumin Xia | fa2bce7 | 2017-04-09 16:20:25 -0700 | [diff] [blame] | 35 | NdnsValidatorBuilder::create(Face& face, |
| 36 | size_t nsCacheSize, |
| 37 | size_t startComponentIndex, |
| 38 | const std::string& confFile) |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 39 | { |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 40 | auto validator = make_unique<security::v2::Validator>(make_unique<security::v2::ValidationPolicyConfig>(), |
Yumin Xia | fa2bce7 | 2017-04-09 16:20:25 -0700 | [diff] [blame] | 41 | make_unique<CertificateFetcherNdnsCert>(face, |
| 42 | nsCacheSize, |
| 43 | startComponentIndex)); |
Davide Pesavento | d01c1a4 | 2019-01-21 21:42:45 -0500 | [diff] [blame^] | 44 | auto& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy()); |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 45 | policy.load(confFile); |
| 46 | NDNS_LOG_TRACE("Validator loads configuration: " << confFile); |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 47 | |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 48 | return validator; |
Shock Jiang | 0b165f4 | 2014-10-24 09:08:09 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } // namespace ndns |
| 52 | } // namespace ndn |