Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 7838cfd | 2020-06-03 14:16:43 -0400 | [diff] [blame] | 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 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 | |
Zhiyi Zhang | 00a4a00 | 2017-03-01 10:17:36 -0800 | [diff] [blame] | 21 | #ifndef NDNCERT_CERTIFICATE_REQUEST_HPP |
| 22 | #define NDNCERT_CERTIFICATE_REQUEST_HPP |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 23 | |
| 24 | #include "ndncert-common.hpp" |
Zhiyi Zhang | 0453dbb | 2020-04-28 22:39:17 -0700 | [diff] [blame] | 25 | #include <ndn-cxx/security/v2/certificate.hpp> |
| 26 | #include <boost/property_tree/info_parser.hpp> |
| 27 | #include <boost/property_tree/json_parser.hpp> |
| 28 | #include <boost/property_tree/ptree.hpp> |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace ndncert { |
| 32 | |
Zhiyi Zhang | 3b267e6 | 2017-02-09 17:59:34 -0800 | [diff] [blame] | 33 | typedef boost::property_tree::ptree JsonSection; |
| 34 | |
tylerliu | 182bc53 | 2020-09-25 01:54:45 -0700 | [diff] [blame] | 35 | //Request Type Enum |
| 36 | enum { |
| 37 | REQUEST_TYPE_NEW = 0, |
| 38 | REQUEST_TYPE_REVOKE = 1 |
| 39 | }; |
| 40 | |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 41 | /** |
| 42 | * @brief Represents a certificate request instance. |
| 43 | * |
| 44 | * ChallengeModule should take use of m_challengeStatus, m_challengeInstruction and |
| 45 | * m_challengeDefinedField to finish verification. |
| 46 | * |
| 47 | */ |
| 48 | class CertificateRequest |
| 49 | { |
| 50 | public: |
Zhiyi Zhang | 00a4a00 | 2017-03-01 10:17:36 -0800 | [diff] [blame] | 51 | CertificateRequest(); |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 52 | CertificateRequest(const Name& caName, const std::string& requestId, int requestType, Status status, |
tylerliu | 182bc53 | 2020-09-25 01:54:45 -0700 | [diff] [blame] | 53 | const security::v2::Certificate& cert); |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 54 | CertificateRequest(const Name& caName, const std::string& requestId, int requestType, Status status, |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 55 | const std::string& challengeStatus, const std::string& challengeType, |
| 56 | const std::string& challengeTp, int remainingTime, int remainingTries, |
| 57 | const JsonSection& challengeSecrets, const security::v2::Certificate& cert); |
Zhiyi Zhang | 5f749a2 | 2019-06-12 17:02:33 -0700 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | setProbeToken(const std::shared_ptr<Data>& probeToken); |
| 61 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 62 | public: |
Suyong Won | 256c906 | 2020-05-11 02:45:56 -0700 | [diff] [blame] | 63 | Name m_caPrefix; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 64 | std::string m_requestId = ""; |
tylerliu | 182bc53 | 2020-09-25 01:54:45 -0700 | [diff] [blame] | 65 | int m_requestType = -1; |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 66 | Status m_status = Status::NOT_STARTED; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 67 | security::v2::Certificate m_cert; |
Zhiyi Zhang | 5f749a2 | 2019-06-12 17:02:33 -0700 | [diff] [blame] | 68 | std::shared_ptr<Data> m_probeToken = nullptr; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 69 | |
| 70 | std::string m_challengeStatus = ""; |
| 71 | std::string m_challengeType = ""; |
| 72 | std::string m_challengeTp = ""; |
| 73 | int m_remainingTime = 0; |
| 74 | int m_remainingTries = 0; |
| 75 | JsonSection m_challengeSecrets; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | std::ostream& |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 79 | operator<<(std::ostream& os, const CertificateRequest& request); |
| 80 | |
| 81 | } // namespace ndncert |
| 82 | } // namespace ndn |
| 83 | |
Zhiyi Zhang | 00a4a00 | 2017-03-01 10:17:36 -0800 | [diff] [blame] | 84 | #endif // NDNCERT_CERTIFICATE_REQUEST_HPP |