blob: ed95cb22a8f241c254e46fe8325edfed299f796f [file] [log] [blame]
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017, Regents of the University of California.
4 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert 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 General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
21#ifndef NDNCERT_CA_CONFIG_HPP
22#define NDNCERT_CA_CONFIG_HPP
23
24#include "ndncert-common.hpp"
25#include <ndn-cxx/security/v2/certificate.hpp>
26
27namespace ndn {
28namespace ndncert {
29
30typedef boost::property_tree::ptree ConfigSection;
31
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080032class CaItem
33{
34public:
35 Name m_caName;
36 std::string m_caInfo;
37 std::string m_probe;
38 time::seconds m_freshnessPeriod;
39 time::days m_validityPeriod;
40 std::list<std::string> m_supportedChallenges;
41 Name m_anchor;
42};
43
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080044/**
45 * @brief Represents a CA configuration instance
46 */
47class CaConfig
48{
49public:
50 /**
51 * @brief Error that can be thrown from CaConfig
52 */
53 class Error : public std::runtime_error
54 {
55 public:
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080056 using std::runtime_error::runtime_error;
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080057 };
58
59public:
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080060 void
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080061 load(const std::string& fileName);
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080062
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080063private:
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080064 void
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080065 parse();
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080066
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080067 std::list<std::string>
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080068 parseChallengeList(const ConfigSection& configSection);
69
70public:
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080071 std::list<CaItem> m_caItems;
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080072
73PUBLIC_WITH_TESTS_ELSE_PRIVATE:
74 ConfigSection m_config;
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080075};
76
77} // namespace ndncert
78} // namespace ndn
79
80#endif // NDNCERT_CA_CONFIG_HPP