blob: 791fc1261c846c8e29a40a60baad0415db09b266 [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
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080029const 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_ERROR_INFO = "error-info";
36const std::string JSON_CERTIFICATE = "certificate";
Zhiyi Zhang19768a52017-01-18 14:44:15 -080037
38/**
39 * @brief Generate JSON file to response PROBE insterest
40 *
41 * Target JSON format:
42 * {
Zhiyi Zhang0fd71cc2017-03-01 10:18:58 -080043 * "identifier": "@p identifier",
44 * "ca-info": "@p caInformation"
Zhiyi Zhang19768a52017-01-18 14:44:15 -080045 * }
46 */
47const JsonSection
Zhiyi Zhang0fd71cc2017-03-01 10:18:58 -080048genResponseProbeJson(const Name& identifier, const Name& caInformation);
Zhiyi Zhang19768a52017-01-18 14:44:15 -080049
50/**
51 * @brief Generate JSON file to response NEW interest
52 *
53 * Target JSON format:
54 * {
Zhiyi Zhang0fd71cc2017-03-01 10:18:58 -080055 * "request-id": "@p requestId",
56 * "status": "@p status",
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080057 * "challenges": [
Zhiyi Zhang19768a52017-01-18 14:44:15 -080058 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080059 * "challenge-type": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -080060 * },
61 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080062 * "challenge-type": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -080063 * },
64 * ...
65 * ]
66 * }
67 */
68const JsonSection
Zhiyi Zhang0fd71cc2017-03-01 10:18:58 -080069genResponseNewJson(const std::string& requestId, const std::string& status,
70 const std::list<std::string>& challenges);
Zhiyi Zhang19768a52017-01-18 14:44:15 -080071
72/**
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080073 * @brief Generate JSON file to response _SELECT, _VALIDATE, and _STATUS interest
74 *
75 * if certificate name is not present:
Zhiyi Zhang19768a52017-01-18 14:44:15 -080076 *
77 * Target JSON format:
78 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080079 * "request-id": "@p requestId",
80 * "challenge-type": "@p challengeType",
81 * "status": "@p status"
82 * }
83 *
84 * if certificate name is present:
85 *
86 * Target JSON format:
87 * {
88 * "request-id": "@p requestId",
89 * "challenge-type": "@p challengeType",
90 * "status": "@p status",
91 * "certificate":"@p name"
Zhiyi Zhang19768a52017-01-18 14:44:15 -080092 * }
93 */
94const JsonSection
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080095genResponseChallengeJson(const std::string& requestId, const std::string& challengeType,
96 const std::string& status, const Name& name = Name());
Zhiyi Zhang19768a52017-01-18 14:44:15 -080097
98/**
99 * @brief Generate JSON file when there is an Error
100 *
101 * Target JSON format:
102 * {
Zhiyi Zhang0fd71cc2017-03-01 10:18:58 -0800103 * "status": "error",
104 * "error-info": "@p errorInfo"
Zhiyi Zhang19768a52017-01-18 14:44:15 -0800105 * }
106 */
107const JsonSection
108genErrorJson(const std::string& errorInfo);
109
110} // namespace ndncert
111} // namespace ndn
112
113#endif // NDNCERT_JSON_HELPER_HPP