blob: 09e13032435a045fa95ab8ec464e2577da021c44 [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";
Tianyuan Yu42bc63e2024-10-18 10:18:38 -070040const std::string CONFIG_FORWARDING_HINT = "forwarding-hint";
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080041const std::string CONFIG_REDIRECTION = "redirect-to";
42const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
Tianyuan Yu13aac732022-03-03 20:59:54 -080043const std::string CONFIG_REDIRECTION_POLICY_TYPE = "policy-type";
44const std::string CONFIG_REDIRECTION_POLICY_PARAM = "policy-param";
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080045
tylerliuf2e6bb52020-12-13 13:23:05 -080046class CaProfile
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080047{
48public:
49 /**
Davide Pesavento9510c912024-02-25 17:50:05 -050050 * Parse the configuration JSON.
51 * @param json the configuration json to parse
tylerliuf2e6bb52020-12-13 13:23:05 -080052 * @return the CaProfile according to this json
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080053 */
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080054 static CaProfile
55 fromJson(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080056
57 /**
58 * @return the JSON representation of this profile.
59 */
60 JsonSection
61 toJson() const;
62
63public:
64 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080065 * @brief CA Name prefix (without /CA suffix).
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080066 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080067 Name caPrefix;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080068 /**
Tianyuan Yu42bc63e2024-10-18 10:18:38 -070069 * @brief Forwarding hint for requesters to retrieve issued certificates.
70 */
71 Name forwardingHint;
72 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080073 * @brief CA Information.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080074 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080075 std::string caInfo;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080076 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080077 * @brief A list of parameter-keys for PROBE.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080078 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080079 std::vector<std::string> probeParameterKeys;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080080 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080081 * @brief Maximum allowed validity period of the certificate being requested.
82 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080083 * The value is in the unit of second.
84 * Default: one day (86400 seconds).
85 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080086 time::seconds maxValidityPeriod;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080087 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080088 * @brief Maximum allowed suffix length of requested name.
89 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080090 * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
91 * Default: none.
92 */
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040093 std::optional<size_t> maxSuffixLength;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080094 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080095 * @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080096 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080097 std::vector<std::string> supportedChallenges;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080098 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080099 * @brief CA's certificate. Only Client side will have m_cert.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -0800100 */
Davide Pesavento0dc02012021-11-23 22:55:03 -0500101 std::shared_ptr<Certificate> cert;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -0800102};
103
104} // namespace ndncert
Zhiyi Zhang3f20f952020-11-19 19:26:43 -0800105
106#endif // NDNCERT_DETAIL_CA_PROFILE_HPP