blob: 9eb9a2ec206272e3b218d53bdea8e1debe0031ce [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/*
3 * Copyright (c) 2014-2017, 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 "logger.hpp"
22#include "config.hpp"
Shock Jiang0b165f42014-10-24 09:08:09 -070023
Yumin Xia2c509c22017-02-09 14:37:36 -080024#include <ndn-cxx/security/v2/validation-policy-config.hpp>
25#include <ndn-cxx/security/v2/certificate-fetcher-from-network.hpp>
Shock Jiang0b165f42014-10-24 09:08:09 -070026
27namespace ndn {
28namespace ndns {
Alexander Afanasyevc7c99002015-10-09 17:27:30 -070029
30NDNS_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>
35NdnsValidatorBuilder::create(Face& face, const std::string& confFile)
Shock Jiang0b165f42014-10-24 09:08:09 -070036{
Yumin Xia2c509c22017-02-09 14:37:36 -080037 auto validator = make_unique<security::v2::Validator>(make_unique<security::v2::ValidationPolicyConfig>(),
38 make_unique<security::v2::CertificateFetcherFromNetwork>(face));
39 security::v2::ValidationPolicyConfig& policy = dynamic_cast<security::v2::ValidationPolicyConfig&>(validator->getPolicy());
40 policy.load(confFile);
41 NDNS_LOG_TRACE("Validator loads configuration: " << confFile);
Shock Jiang0b165f42014-10-24 09:08:09 -070042
Yumin Xia2c509c22017-02-09 14:37:36 -080043 return validator;
Shock Jiang0b165f42014-10-24 09:08:09 -070044}
45
46} // namespace ndns
47} // namespace ndn