blob: 9bde1f9b3079bd213581194a8bb540eb35960876 [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
32/**
33 * @brief Represents a CA configuration instance
34 */
35class CaConfig
36{
37public:
38 /**
39 * @brief Error that can be thrown from CaConfig
40 */
41 class Error : public std::runtime_error
42 {
43 public:
44 explicit
45 Error(const std::string& what)
46 : std::runtime_error(what)
47 {
48 }
49 };
50
51public:
52 CaConfig();
53
54 explicit
55 CaConfig(const std::string& fileName);
56
57PUBLIC_WITH_TESTS_ELSE_PRIVATE:
58 void
59 open();
60
61 void
62 load();
63
64 void
65 parseCertificateInfo(const ConfigSection& configSection);
66
67 void
68 parseCaAnchor(const ConfigSection& configSection);
69
70 void
71 parseChallengeList(const ConfigSection& configSection);
72
73public:
74 Name m_caName;
75 uint64_t m_freshPeriod;
76 shared_ptr<security::v2::Certificate> m_anchor;
77 std::list<std::string> m_availableChallenges;
78 ConfigSection m_validatorConfig;
79
80PUBLIC_WITH_TESTS_ELSE_PRIVATE:
81 ConfigSection m_config;
82 std::string m_fileName;
83};
84
85} // namespace ndncert
86} // namespace ndn
87
88#endif // NDNCERT_CA_CONFIG_HPP