blob: 0592be5008420bc5af993b559a712fa8a340b9ce [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/*
3 * Copyright (c) 2017-2021, 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
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080026namespace ndncert {
27
28// used in parsing CA configuration file and Client CA profile storage file
29const std::string CONFIG_CA_PREFIX = "ca-prefix";
30const std::string CONFIG_CA_INFO = "ca-info";
31const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
32const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
33const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
34const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
35const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
36const std::string CONFIG_CHALLENGE = "challenge";
37const std::string CONFIG_CERTIFICATE = "certificate";
38const std::string CONFIG_REDIRECTION = "redirect-to";
39const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
40
tylerliuf2e6bb52020-12-13 13:23:05 -080041class CaProfile
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080042{
43public:
44 /**
tylerliuf2e6bb52020-12-13 13:23:05 -080045 * Parse the configuration json.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080046 * @param configJson the configuration json to parse
tylerliuf2e6bb52020-12-13 13:23:05 -080047 * @return the CaProfile according to this json
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080048 */
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080049 static CaProfile
50 fromJson(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080051
52 /**
53 * @return the JSON representation of this profile.
54 */
55 JsonSection
56 toJson() const;
57
58public:
59 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080060 * @brief CA Name prefix (without /CA suffix).
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080061 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080062 Name caPrefix;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080063 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080064 * @brief CA Information.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080065 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080066 std::string caInfo;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080067 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080068 * @brief A list of parameter-keys for PROBE.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080069 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080070 std::vector<std::string> probeParameterKeys;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080071 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080072 * @brief Maximum allowed validity period of the certificate being requested.
73 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080074 * The value is in the unit of second.
75 * Default: one day (86400 seconds).
76 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080077 time::seconds maxValidityPeriod;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080078 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080079 * @brief Maximum allowed suffix length of requested name.
80 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080081 * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
82 * Default: none.
83 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080084 optional<size_t> maxSuffixLength = nullopt;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080085 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080086 * @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080087 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080088 std::vector<std::string> supportedChallenges;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080089 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080090 * @brief CA's certificate. Only Client side will have m_cert.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080091 */
Davide Pesavento0dc02012021-11-23 22:55:03 -050092 std::shared_ptr<Certificate> cert;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080093};
94
95} // namespace ndncert
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080096
97#endif // NDNCERT_DETAIL_CA_PROFILE_HPP