Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 1 | /* -*- 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 Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 24 | #include "certificate-request.hpp" |
| 25 | #include <ndn-cxx/security/v2/certificate.hpp> |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 26 | |
| 27 | namespace ndn { |
| 28 | namespace ndncert { |
| 29 | |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 30 | class ClientCaItem |
| 31 | { |
| 32 | public: |
| 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 Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 40 | class ClientConfig |
| 41 | { |
| 42 | public: |
| 43 | class Error : public std::runtime_error |
| 44 | { |
| 45 | public: |
| 46 | using std::runtime_error::runtime_error; |
| 47 | }; |
| 48 | |
| 49 | public: |
| 50 | void |
| 51 | load(const std::string& fileName); |
| 52 | |
| 53 | void |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 54 | addNewCaItem(const ClientCaItem& item); |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 55 | |
| 56 | void |
| 57 | removeCaItem(const Name& caName); |
| 58 | |
| 59 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 60 | void |
| 61 | parse(); |
| 62 | |
| 63 | std::list<std::string> |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 64 | parseChallengeList(const JsonSection& section); |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 65 | |
| 66 | public: |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 67 | std::list<ClientCaItem> m_caItems; |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 68 | |
| 69 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 70 | JsonSection m_config; |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace ndncert |
| 74 | } // namespace ndn |
| 75 | |
| 76 | #endif // NDNCERT_CLIENT_CONFIG_HPP |