blob: c67f5dc89d0f0618e1a42faef821b76a7dfa8414 [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
24#include "name-assignment/assignment-func.hpp"
25
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
42struct CaProfile
43{
44public:
45 /**
46 * Parse the configuration json and modify current struct to the result.
47 * @param configJson the configuration json to parse
48 */
49 void
50 parse(const JsonSection& configJson);
51
52 /**
53 * @return the JSON representation of this profile.
54 */
55 JsonSection
56 toJson() const;
57
58public:
59 /**
60 * CA Name prefix (without /CA suffix).
61 */
62 Name m_caPrefix;
63 /**
64 * CA Information.
65 * Default: "".
66 */
67 std::string m_caInfo;
68 /**
69 * A list of parameter-keys for PROBE.
70 * Default: empty list.
71 */
72 std::list<std::string> m_probeParameterKeys;
73 /**
74 * Maximum allowed validity period of the certificate being requested.
75 * The value is in the unit of second.
76 * Default: one day (86400 seconds).
77 */
78 time::seconds m_maxValidityPeriod;
79 /**
80 * Maximum allowed suffix length of requested name.
81 * E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
82 * Default: none.
83 */
84 optional<size_t> m_maxSuffixLength = nullopt;
85 /**
86 * A list of supported challenges. Only CA side will have m_supportedChallenges.
87 * Default: empty list.
88 */
89 std::list<std::string> m_supportedChallenges;
90 /**
91 * CA's certificate. Only Client side will have m_cert.
92 * Default: nullptr.
93 */
94 std::shared_ptr<security::Certificate> m_cert;
95};
96
97} // namespace ndncert
98} // namespace ndn
99
100#endif // NDNCERT_DETAIL_CA_PROFILE_HPP