blob: 6c6e53af2f4ebdb9dc8a03d0cf27b0def489ece1 [file] [log] [blame]
Shock Jiang0b165f42014-10-24 09:08:09 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Yumin Xia2c509c22017-02-09 14:37:36 -08002/*
Alexander Afanasyev08d18742018-03-15 16:31:28 -04003 * Copyright (c) 2014-2018, Regents of the University of California.
Shock Jiang0b165f42014-10-24 09:08:09 -07004 *
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 Xia2c509c22017-02-09 14:37:36 -080020#include "validator.hpp"
Shock Jiang0b165f42014-10-24 09:08:09 -070021#include "config.hpp"
Yumin Xiafa2bce72017-04-09 16:20:25 -070022#include "certificate-fetcher-ndns-cert.hpp"
23#include "logger.hpp"
Shock Jiang0b165f42014-10-24 09:08:09 -070024
Yumin Xia2c509c22017-02-09 14:37:36 -080025#include <ndn-cxx/security/v2/validation-policy-config.hpp>
Shock Jiang0b165f42014-10-24 09:08:09 -070026
27namespace ndn {
28namespace ndns {
Alexander Afanasyevc7c99002015-10-09 17:27:30 -070029
Alexander Afanasyev08d18742018-03-15 16:31:28 -040030NDNS_LOG_INIT(Validator);
Shock Jiang0b165f42014-10-24 09:08:09 -070031
Yumin Xia2c509c22017-02-09 14:37:36 -080032std::string NdnsValidatorBuilder::VALIDATOR_CONF_FILE = DEFAULT_CONFIG_PATH "/" "validator.conf";
Shock Jiang0b165f42014-10-24 09:08:09 -070033
Yumin Xia2c509c22017-02-09 14:37:36 -080034unique_ptr<security::v2::Validator>
Yumin Xiafa2bce72017-04-09 16:20:25 -070035NdnsValidatorBuilder::create(Face& face,
36 size_t nsCacheSize,
37 size_t startComponentIndex,
38 const std::string& confFile)
Shock Jiang0b165f42014-10-24 09:08:09 -070039{
Yumin Xia2c509c22017-02-09 14:37:36 -080040 auto validator = make_unique<security::v2::Validator>(make_unique<security::v2::ValidationPolicyConfig>(),
Yumin Xiafa2bce72017-04-09 16:20:25 -070041 make_unique<CertificateFetcherNdnsCert>(face,
42 nsCacheSize,
43 startComponentIndex));
Yumin Xia2c509c22017-02-09 14:37:36 -080044 security::v2::ValidationPolicyConfig& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
45 policy.load(confFile);
46 NDNS_LOG_TRACE("Validator loads configuration: " << confFile);
Shock Jiang0b165f42014-10-24 09:08:09 -070047
Yumin Xia2c509c22017-02-09 14:37:36 -080048 return validator;
Shock Jiang0b165f42014-10-24 09:08:09 -070049}
50
51} // namespace ndns
52} // namespace ndn