Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2019, Regents of the University of California. |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 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 | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 30 | /** |
| 31 | * @brief The configuration for a trusted CA from a requester's perspective |
| 32 | */ |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 33 | class ClientCaItem |
| 34 | { |
| 35 | public: |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 36 | // The identity name of the CA. Extracted from config field "ca-prefix" |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 37 | Name m_caName; |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 38 | |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 39 | // A brief introduction to the CA. Extracted from config field "ca-info" |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 40 | std::string m_caInfo; |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 41 | // An instruction for requesters to use _PROBE. Extracted from config field "probe" |
Yufeng Zhang | 424d036 | 2019-06-12 16:48:27 -0700 | [diff] [blame] | 42 | std::string m_probe; // "email::uid::name" |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 43 | |
| 44 | // CA's certificate |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 45 | security::v2::Certificate m_anchor; |
| 46 | }; |
| 47 | |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 48 | /** |
| 49 | * @brief Represents Client configuration |
| 50 | * |
| 51 | * For Client configuration format, please refer to: |
| 52 | * https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample |
| 53 | */ |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 54 | class ClientConfig |
| 55 | { |
| 56 | public: |
| 57 | class Error : public std::runtime_error |
| 58 | { |
| 59 | public: |
| 60 | using std::runtime_error::runtime_error; |
| 61 | }; |
| 62 | |
| 63 | public: |
| 64 | void |
| 65 | load(const std::string& fileName); |
| 66 | |
| 67 | void |
Zhiyi Zhang | e4ee822 | 2017-12-08 22:43:04 -0800 | [diff] [blame] | 68 | load(const JsonSection& configSection); |
| 69 | |
| 70 | void |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 71 | addNewCaItem(const ClientCaItem& item); |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 72 | |
| 73 | void |
| 74 | removeCaItem(const Name& caName); |
| 75 | |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 76 | static ClientCaItem |
| 77 | extractCaItem(const JsonSection& configSection); |
| 78 | |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 79 | public: |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame] | 80 | std::list<ClientCaItem> m_caItems; |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 81 | std::string m_localNdncertAnchor; |
Zhiyi Zhang | 32dbb9f | 2017-02-16 15:15:10 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } // namespace ndncert |
| 85 | } // namespace ndn |
| 86 | |
| 87 | #endif // NDNCERT_CLIENT_CONFIG_HPP |