Zhiyi Zhang | 19768a5 | 2017-01-18 14:44:15 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 26 | namespace ndn { |
| 27 | namespace ndncert { |
| 28 | |
| 29 | const std::string JSON_IDNENTIFIER = "Identifier"; |
| 30 | const std::string JSON_CA_INFO = "CA-Info"; |
| 31 | const std::string JSON_STATUS = "Status"; |
| 32 | const std::string JSON_REQUEST_ID = "Request-ID"; |
| 33 | const std::string JSON_CHALLENGES = "Challenges"; |
| 34 | const std::string JSON_CHALLENGE_TYPE = "Challenge-Type"; |
| 35 | const std::string JSON_CHALLENGE_INSTRUCTION = "Challenge-Instruction"; |
| 36 | const std::string JSON_CHALLENGE_STATUS = "Challenge-Status"; |
| 37 | const std::string JSON_ERROR_INFO = "Error-Info"; |
| 38 | |
| 39 | typedef 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 | */ |
| 50 | const JsonSection |
| 51 | genResponseProbeJson(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 | */ |
| 73 | const JsonSection |
| 74 | genResponseNewJson(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 | */ |
| 88 | const JsonSection |
| 89 | genResponsePollJson(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 | */ |
| 100 | const JsonSection |
| 101 | genErrorJson(const std::string& errorInfo); |
| 102 | |
| 103 | } // namespace ndncert |
| 104 | } // namespace ndn |
| 105 | |
| 106 | #endif // NDNCERT_JSON_HELPER_HPP |