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 | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 21 | #ifndef NDNCERT_REQUEST_STATE_HPP |
| 22 | #define NDNCERT_REQUEST_STATE_HPP |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 23 | |
| 24 | #include "ndncert-common.hpp" |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace ndncert { |
| 28 | |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 29 | struct ChallengeState { |
| 30 | ChallengeState(const std::string& challengeStatus, const system_clock::TimePoint& challengeTp, |
| 31 | size_t remainingTries, time::seconds remainingTime, |
| 32 | JsonSection&& challengeSecrets); |
| 33 | std::string m_challengeStatus; |
| 34 | system_clock::TimePoint m_timestamp; |
| 35 | size_t m_remainingTries; |
| 36 | time::seconds m_remainingTime; |
| 37 | JsonSection m_secrets; |
| 38 | }; |
Zhiyi Zhang | 3b267e6 | 2017-02-09 17:59:34 -0800 | [diff] [blame] | 39 | |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 40 | /** |
| 41 | * @brief Represents a certificate request instance. |
| 42 | * |
| 43 | * ChallengeModule should take use of m_challengeStatus, m_challengeInstruction and |
| 44 | * m_challengeDefinedField to finish verification. |
| 45 | * |
| 46 | */ |
Zhiyi Zhang | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 47 | class RequestState { |
tylerliu | 8e170d6 | 2020-09-30 01:31:53 -0700 | [diff] [blame] | 48 | |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 49 | public: |
Zhiyi Zhang | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 50 | RequestState(); |
| 51 | RequestState(const Name& caName, const std::string& requestId, RequestType requestType, Status status, |
tylerliu | 8e170d6 | 2020-09-30 01:31:53 -0700 | [diff] [blame] | 52 | const security::v2::Certificate& cert, Block m_encryptionKey); |
Zhiyi Zhang | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 53 | RequestState(const Name& caName, const std::string& requestId, RequestType requestType, Status status, |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 54 | const security::v2::Certificate& cert, const std::string& challengeType, |
| 55 | const std::string& challengeStatus, const system_clock::TimePoint& challengeTp, |
tylerliu | 8e170d6 | 2020-09-30 01:31:53 -0700 | [diff] [blame] | 56 | size_t remainingTries, time::seconds remainingTime, JsonSection&& challengeSecrets, |
| 57 | Block m_encryptionKey); |
Zhiyi Zhang | 5f749a2 | 2019-06-12 17:02:33 -0700 | [diff] [blame] | 58 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 59 | public: |
Suyong Won | 256c906 | 2020-05-11 02:45:56 -0700 | [diff] [blame] | 60 | Name m_caPrefix; |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 61 | std::string m_requestId; |
| 62 | RequestType m_requestType; |
| 63 | Status m_status; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 64 | security::v2::Certificate m_cert; |
tylerliu | 8e170d6 | 2020-09-30 01:31:53 -0700 | [diff] [blame] | 65 | Block m_encryptionKey; |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 66 | |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 67 | std::string m_challengeType; |
| 68 | boost::optional<ChallengeState> m_challengeState; |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | std::ostream& |
Zhiyi Zhang | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 72 | operator<<(std::ostream& os, const RequestState& request); |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 73 | |
Zhiyi Zhang | c87d52b | 2020-09-28 22:07:18 -0700 | [diff] [blame] | 74 | } // namespace ndncert |
| 75 | } // namespace ndn |
Zhiyi Zhang | a41c573 | 2017-01-18 14:06:44 -0800 | [diff] [blame] | 76 | |
Zhiyi Zhang | e232a74 | 2020-09-29 17:34:17 -0700 | [diff] [blame] | 77 | #endif // NDNCERT_REQUEST_STATE_HPP |