Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2017-2021, Regents of the University of California. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -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_DETAIL_CA_PROFILE_HPP |
| 22 | #define NDNCERT_DETAIL_CA_PROFILE_HPP |
| 23 | |
Zhiyi Zhang | 1e418f2 | 2020-11-19 19:49:32 -0800 | [diff] [blame] | 24 | #include "detail/ndncert-common.hpp" |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 25 | |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 26 | namespace ndncert { |
| 27 | |
| 28 | // used in parsing CA configuration file and Client CA profile storage file |
| 29 | const std::string CONFIG_CA_PREFIX = "ca-prefix"; |
| 30 | const std::string CONFIG_CA_INFO = "ca-info"; |
| 31 | const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period"; |
| 32 | const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length"; |
| 33 | const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters"; |
| 34 | const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key"; |
| 35 | const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges"; |
| 36 | const std::string CONFIG_CHALLENGE = "challenge"; |
| 37 | const std::string CONFIG_CERTIFICATE = "certificate"; |
| 38 | const std::string CONFIG_REDIRECTION = "redirect-to"; |
| 39 | const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment"; |
| 40 | |
tylerliu | f2e6bb5 | 2020-12-13 13:23:05 -0800 | [diff] [blame] | 41 | class CaProfile |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 42 | { |
| 43 | public: |
| 44 | /** |
tylerliu | f2e6bb5 | 2020-12-13 13:23:05 -0800 | [diff] [blame] | 45 | * Parse the configuration json. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 46 | * @param configJson the configuration json to parse |
tylerliu | f2e6bb5 | 2020-12-13 13:23:05 -0800 | [diff] [blame] | 47 | * @return the CaProfile according to this json |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 48 | */ |
Zhiyi Zhang | 1e418f2 | 2020-11-19 19:49:32 -0800 | [diff] [blame] | 49 | static CaProfile |
| 50 | fromJson(const JsonSection& json); |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @return the JSON representation of this profile. |
| 54 | */ |
| 55 | JsonSection |
| 56 | toJson() const; |
| 57 | |
| 58 | public: |
| 59 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 60 | * @brief CA Name prefix (without /CA suffix). |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 61 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 62 | Name caPrefix; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 63 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 64 | * @brief CA Information. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 65 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 66 | std::string caInfo; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 67 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 68 | * @brief A list of parameter-keys for PROBE. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 69 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 70 | std::vector<std::string> probeParameterKeys; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 71 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 72 | * @brief Maximum allowed validity period of the certificate being requested. |
| 73 | * |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 74 | * The value is in the unit of second. |
| 75 | * Default: one day (86400 seconds). |
| 76 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 77 | time::seconds maxValidityPeriod; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 78 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 79 | * @brief Maximum allowed suffix length of requested name. |
| 80 | * |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 81 | * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix. |
| 82 | * Default: none. |
| 83 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 84 | optional<size_t> maxSuffixLength = nullopt; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 85 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 86 | * @brief A list of supported challenges. Only CA side will have m_supportedChallenges. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 87 | */ |
Zhiyi Zhang | 44c6a35 | 2020-12-14 10:57:17 -0800 | [diff] [blame] | 88 | std::vector<std::string> supportedChallenges; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 89 | /** |
Zhiyi Zhang | 84e1184 | 2020-11-19 20:03:23 -0800 | [diff] [blame] | 90 | * @brief CA's certificate. Only Client side will have m_cert. |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 91 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame^] | 92 | std::shared_ptr<Certificate> cert; |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | } // namespace ndncert |
Zhiyi Zhang | 3f20f95 | 2020-11-19 19:26:43 -0800 | [diff] [blame] | 96 | |
| 97 | #endif // NDNCERT_DETAIL_CA_PROFILE_HPP |