blob: 6ca9b198cadfd5e520c88cd0914bdc37a4590bbb [file] [log] [blame]
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento0dc02012021-11-23 22:55:03 -05002/*
Davide Pesavento9510c912024-02-25 17:50:05 -05003 * Copyright (c) 2017-2024, Regents of the University of California.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08004 *
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 Zhang1e418f22020-11-19 19:49:32 -080024#include "detail/ndncert-common.hpp"
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080025
Davide Pesavento9510c912024-02-25 17:50:05 -050026#include <optional>
27
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080028namespace ndncert {
29
30// used in parsing CA configuration file and Client CA profile storage file
31const std::string CONFIG_CA_PREFIX = "ca-prefix";
32const std::string CONFIG_CA_INFO = "ca-info";
33const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
34const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
35const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
36const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
37const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
38const std::string CONFIG_CHALLENGE = "challenge";
39const std::string CONFIG_CERTIFICATE = "certificate";
40const std::string CONFIG_REDIRECTION = "redirect-to";
41const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
Tianyuan Yu13aac732022-03-03 20:59:54 -080042const std::string CONFIG_REDIRECTION_POLICY_TYPE = "policy-type";
43const std::string CONFIG_REDIRECTION_POLICY_PARAM = "policy-param";
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080044
tylerliuf2e6bb52020-12-13 13:23:05 -080045class CaProfile
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080046{
47public:
48 /**
Davide Pesavento9510c912024-02-25 17:50:05 -050049 * Parse the configuration JSON.
50 * @param json the configuration json to parse
tylerliuf2e6bb52020-12-13 13:23:05 -080051 * @return the CaProfile according to this json
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080052 */
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080053 static CaProfile
54 fromJson(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080055
56 /**
57 * @return the JSON representation of this profile.
58 */
59 JsonSection
60 toJson() const;
61
62public:
63 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080064 * @brief CA Name prefix (without /CA suffix).
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080065 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080066 Name caPrefix;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080067 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080068 * @brief CA Information.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080069 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080070 std::string caInfo;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080071 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080072 * @brief A list of parameter-keys for PROBE.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080073 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080074 std::vector<std::string> probeParameterKeys;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080075 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080076 * @brief Maximum allowed validity period of the certificate being requested.
77 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080078 * The value is in the unit of second.
79 * Default: one day (86400 seconds).
80 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080081 time::seconds maxValidityPeriod;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080082 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080083 * @brief Maximum allowed suffix length of requested name.
84 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080085 * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
86 * Default: none.
87 */
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040088 std::optional<size_t> maxSuffixLength;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080089 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080090 * @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080091 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080092 std::vector<std::string> supportedChallenges;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080093 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080094 * @brief CA's certificate. Only Client side will have m_cert.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080095 */
Davide Pesavento0dc02012021-11-23 22:55:03 -050096 std::shared_ptr<Certificate> cert;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080097};
98
99} // namespace ndncert
Zhiyi Zhang3f20f952020-11-19 19:26:43 -0800100
101#endif // NDNCERT_DETAIL_CA_PROFILE_HPP