blob: 8234c01fbba3e53b97e2e09ef5407f3a741aeacd [file] [log] [blame]
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -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_CLIENT_CONFIG_HPP
22#define NDNCERT_CLIENT_CONFIG_HPP
23
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080024#include "certificate-request.hpp"
25#include <ndn-cxx/security/v2/certificate.hpp>
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080026
27namespace ndn {
28namespace ndncert {
29
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080030class ClientCaItem
31{
32public:
33 Name m_caName;
34 std::string m_caInfo;
35 std::string m_probe;
36 std::list<std::string> m_supportedChallenges;
37 security::v2::Certificate m_anchor;
38};
39
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080040class ClientConfig
41{
42public:
43 class Error : public std::runtime_error
44 {
45 public:
46 using std::runtime_error::runtime_error;
47 };
48
49public:
50 void
51 load(const std::string& fileName);
52
53 void
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080054 addNewCaItem(const ClientCaItem& item);
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080055
56 void
57 removeCaItem(const Name& caName);
58
59PUBLIC_WITH_TESTS_ELSE_PRIVATE:
60 void
61 parse();
62
63 std::list<std::string>
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080064 parseChallengeList(const JsonSection& section);
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080065
66public:
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080067 std::list<ClientCaItem> m_caItems;
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080068
69PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Zhiyi Zhang5ebeb692017-03-10 14:13:01 -080070 JsonSection m_config;
Zhiyi Zhang32dbb9f2017-02-16 15:15:10 -080071};
72
73} // namespace ndncert
74} // namespace ndn
75
76#endif // NDNCERT_CLIENT_CONFIG_HPP