blob: 69adf43d15054b01ef7c59901128a842615bc544 [file] [log] [blame]
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017-2020, Regents of the University of California.
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 Zhang1e418f22020-11-19 19:49:32 -080024#include "detail/ndncert-common.hpp"
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080025
26namespace ndn {
27namespace ndncert {
28
29// used in parsing CA configuration file and Client CA profile storage file
30const std::string CONFIG_CA_PREFIX = "ca-prefix";
31const std::string CONFIG_CA_INFO = "ca-info";
32const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
33const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
34const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
35const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
36const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
37const std::string CONFIG_CHALLENGE = "challenge";
38const std::string CONFIG_CERTIFICATE = "certificate";
39const std::string CONFIG_REDIRECTION = "redirect-to";
40const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
41
tylerliuf2e6bb52020-12-13 13:23:05 -080042class CaProfile
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080043{
44public:
45 /**
tylerliuf2e6bb52020-12-13 13:23:05 -080046 * Parse the configuration json.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080047 * @param configJson the configuration json to parse
tylerliuf2e6bb52020-12-13 13:23:05 -080048 * @return the CaProfile according to this json
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080049 */
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080050 static CaProfile
51 fromJson(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080052
53 /**
54 * @return the JSON representation of this profile.
55 */
56 JsonSection
57 toJson() const;
58
59public:
60 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080061 * @brief CA Name prefix (without /CA suffix).
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080062 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080063 Name caPrefix;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080064 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080065 * @brief CA Information.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080066 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080067 std::string caInfo;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080068 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080069 * @brief A list of parameter-keys for PROBE.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080070 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080071 std::vector<std::string> probeParameterKeys;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080072 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080073 * @brief Maximum allowed validity period of the certificate being requested.
74 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080075 * The value is in the unit of second.
76 * Default: one day (86400 seconds).
77 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080078 time::seconds maxValidityPeriod;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080079 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080080 * @brief Maximum allowed suffix length of requested name.
81 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080082 * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
83 * Default: none.
84 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080085 optional<size_t> maxSuffixLength = nullopt;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080086 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080087 * @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080088 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080089 std::vector<std::string> supportedChallenges;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080090 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080091 * @brief CA's certificate. Only Client side will have m_cert.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080092 */
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080093 std::shared_ptr<security::Certificate> cert;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080094};
95
96} // namespace ndncert
97} // namespace ndn
98
99#endif // NDNCERT_DETAIL_CA_PROFILE_HPP