blob: c34c631b8061726dade25ad8a9ced47dc7c5d16c [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 Zhang3b267e62017-02-09 17:59:34 -080043 * "identifier": "",
44 * "ca-info": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -080045 * }
46 */
47const JsonSection
48genResponseProbeJson(const Name& identifier, const Name& CaInformation);
49
50/**
51 * @brief Generate JSON file to response NEW interest
52 *
53 * Target JSON format:
54 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080055 * "request-id": "",
56 * "challenges": [
Zhiyi Zhang19768a52017-01-18 14:44:15 -080057 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080058 * "challenge-type": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -080059 * },
60 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080061 * "challenge-type": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -080062 * },
63 * ...
64 * ]
65 * }
66 */
67const JsonSection
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080068genResponseNewJson(const std::string& requestId, const std::list<std::string>& challenges);
Zhiyi Zhang19768a52017-01-18 14:44:15 -080069
70/**
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080071 * @brief Generate JSON file to response _SELECT, _VALIDATE, and _STATUS interest
72 *
73 * if certificate name is not present:
Zhiyi Zhang19768a52017-01-18 14:44:15 -080074 *
75 * Target JSON format:
76 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080077 * "request-id": "@p requestId",
78 * "challenge-type": "@p challengeType",
79 * "status": "@p status"
80 * }
81 *
82 * if certificate name is present:
83 *
84 * Target JSON format:
85 * {
86 * "request-id": "@p requestId",
87 * "challenge-type": "@p challengeType",
88 * "status": "@p status",
89 * "certificate":"@p name"
Zhiyi Zhang19768a52017-01-18 14:44:15 -080090 * }
91 */
92const JsonSection
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080093genResponseChallengeJson(const std::string& requestId, const std::string& challengeType,
94 const std::string& status, const Name& name = Name());
Zhiyi Zhang19768a52017-01-18 14:44:15 -080095
96/**
97 * @brief Generate JSON file when there is an Error
98 *
99 * Target JSON format:
100 * {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -0800101 * "status": "",
102 * "error-info": ""
Zhiyi Zhang19768a52017-01-18 14:44:15 -0800103 * }
104 */
105const JsonSection
106genErrorJson(const std::string& errorInfo);
107
108} // namespace ndncert
109} // namespace ndn
110
111#endif // NDNCERT_JSON_HELPER_HPP