blob: fe3ba8078b6f4842b87d650ace0f08a36f2cb838 [file] [log] [blame]
Zhiyi Zhang19768a52017-01-18 14:44:15 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017, 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_JSON_HELPER_HPP
22#define NDNCERT_JSON_HELPER_HPP
23
24#include "certificate-request.hpp"
25
26namespace ndn {
27namespace ndncert {
28
29const std::string JSON_IDNENTIFIER = "Identifier";
30const std::string JSON_CA_INFO = "CA-Info";
31const std::string JSON_STATUS = "Status";
32const std::string JSON_REQUEST_ID = "Request-ID";
33const std::string JSON_CHALLENGES = "Challenges";
34const std::string JSON_CHALLENGE_TYPE = "Challenge-Type";
35const std::string JSON_CHALLENGE_INSTRUCTION = "Challenge-Instruction";
36const std::string JSON_CHALLENGE_STATUS = "Challenge-Status";
37const std::string JSON_ERROR_INFO = "Error-Info";
38
39typedef boost::property_tree::ptree JsonSection;
40
41/**
42 * @brief Generate JSON file to response PROBE insterest
43 *
44 * Target JSON format:
45 * {
46 * "Identifier": "",
47 * "CA-Info": ""
48 * }
49 */
50const JsonSection
51genResponseProbeJson(const Name& identifier, const Name& CaInformation);
52
53/**
54 * @brief Generate JSON file to response NEW interest
55 *
56 * Target JSON format:
57 * {
58 * "Status": "",
59 * "Request-ID": "",
60 * "Challenges": [
61 * {
62 * "Challenge-Type": "",
63 * "Challenge-Instruction": ""
64 * },
65 * {
66 * "Challenge-Type": "",
67 * "Challenge-Instruction": ""
68 * },
69 * ...
70 * ]
71 * }
72 */
73const JsonSection
74genResponseNewJson(const CertificateRequest& request,
75 const std::list<std::tuple<std::string, std::string>> challenges);
76
77/**
78 * @brief Generate JSON file to response POLL interest
79 *
80 * Target JSON format:
81 * {
82 * "Status": "",
83 * "Challenge-Type": "",
84 * "Challenge-Status": "",
85 * "Challenge-Instruction": ""
86 * }
87 */
88const JsonSection
89genResponsePollJson(const CertificateRequest& request);
90
91/**
92 * @brief Generate JSON file when there is an Error
93 *
94 * Target JSON format:
95 * {
96 * "Status": "",
97 * "Error-Info": ""
98 * }
99 */
100const JsonSection
101genErrorJson(const std::string& errorInfo);
102
103} // namespace ndncert
104} // namespace ndn
105
106#endif // NDNCERT_JSON_HELPER_HPP