Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2019, 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" |
| 25 | #include <ndn-cxx/security/v2/certificate.hpp> |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace ndncert { |
| 29 | |
Zhiyi Zhang | 3b267e6 | 2017-02-09 17:59:34 -0800 | [diff] [blame] | 30 | typedef boost::property_tree::ptree JsonSection; |
| 31 | |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 32 | /** |
| 33 | * @brief Represents a certificate request instance. |
| 34 | * |
| 35 | * ChallengeModule should take use of m_challengeStatus, m_challengeInstruction and |
| 36 | * m_challengeDefinedField to finish verification. |
| 37 | * |
| 38 | */ |
| 39 | class CertificateRequest |
| 40 | { |
| 41 | public: |
Zhiyi Zhang | 00a4a00 | 2017-03-01 10:17:36 -0800 | [diff] [blame] | 42 | CertificateRequest(); |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 43 | CertificateRequest(const Name& caName, const std::string& requestId, int status, const security::v2::Certificate& cert); |
| 44 | CertificateRequest(const Name& caName, const std::string& requestId, int status, |
| 45 | const std::string& challengeStatus, const std::string& challengeType, |
| 46 | const std::string& challengeTp, int remainingTime, int remainingTries, |
| 47 | const JsonSection& challengeSecrets, const security::v2::Certificate& cert); |
Zhiyi Zhang | 5f749a2 | 2019-06-12 17:02:33 -0700 | [diff] [blame] | 48 | |
| 49 | void |
| 50 | setProbeToken(const std::shared_ptr<Data>& probeToken); |
| 51 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 52 | public: |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 53 | Name m_caName; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 54 | std::string m_requestId = ""; |
| 55 | int m_status = -1; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 56 | security::v2::Certificate m_cert; |
Zhiyi Zhang | 5f749a2 | 2019-06-12 17:02:33 -0700 | [diff] [blame] | 57 | std::shared_ptr<Data> m_probeToken = nullptr; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 58 | |
| 59 | std::string m_challengeStatus = ""; |
| 60 | std::string m_challengeType = ""; |
| 61 | std::string m_challengeTp = ""; |
| 62 | int m_remainingTime = 0; |
| 63 | int m_remainingTries = 0; |
| 64 | JsonSection m_challengeSecrets; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | std::ostream& |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 68 | operator<<(std::ostream& os, const CertificateRequest& request); |
| 69 | |
| 70 | } // namespace ndncert |
| 71 | } // namespace ndn |
| 72 | |
Zhiyi Zhang | 00a4a00 | 2017-03-01 10:17:36 -0800 | [diff] [blame] | 73 | #endif // NDNCERT_CERTIFICATE_REQUEST_HPP |