blob: 55b90c8c53f6817fa92516523213307b1c76b30d [file] [log] [blame]
Zhiyi Zhanga41c5732017-01-18 14:06:44 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev7838cfd2020-06-03 14:16:43 -04003 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhanga41c5732017-01-18 14:06:44 -08004 *
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 Zhang00a4a002017-03-01 10:17:36 -080021#ifndef NDNCERT_CERTIFICATE_REQUEST_HPP
22#define NDNCERT_CERTIFICATE_REQUEST_HPP
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080023
24#include "ndncert-common.hpp"
Zhiyi Zhang0453dbb2020-04-28 22:39:17 -070025#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 Zhanga41c5732017-01-18 14:06:44 -080029
30namespace ndn {
31namespace ndncert {
32
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080033typedef boost::property_tree::ptree JsonSection;
34
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080035/**
36 * @brief Represents a certificate request instance.
37 *
38 * ChallengeModule should take use of m_challengeStatus, m_challengeInstruction and
39 * m_challengeDefinedField to finish verification.
40 *
41 */
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070042class CertificateRequest {
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080043public:
Zhiyi Zhang00a4a002017-03-01 10:17:36 -080044 CertificateRequest();
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070045 CertificateRequest(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
tylerliu182bc532020-09-25 01:54:45 -070046 const security::v2::Certificate& cert);
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070047 CertificateRequest(const Name& caName, const std::string& requestId, RequestType requestType, Status status,
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070048 const std::string& challengeStatus, const std::string& challengeType,
49 const std::string& challengeTp, int remainingTime, int remainingTries,
50 const JsonSection& challengeSecrets, const security::v2::Certificate& cert);
Zhiyi Zhang5f749a22019-06-12 17:02:33 -070051
52 void
53 setProbeToken(const std::shared_ptr<Data>& probeToken);
54
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070055public:
Suyong Won256c9062020-05-11 02:45:56 -070056 Name m_caPrefix;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070057 std::string m_requestId = "";
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070058 RequestType m_requestType = RequestType::NOTINITIALIZED;
Zhiyi Zhang48f23782020-09-28 12:11:24 -070059 Status m_status = Status::NOT_STARTED;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080060 security::v2::Certificate m_cert;
Zhiyi Zhang5f749a22019-06-12 17:02:33 -070061 std::shared_ptr<Data> m_probeToken = nullptr;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070062
63 std::string m_challengeStatus = "";
64 std::string m_challengeType = "";
65 std::string m_challengeTp = "";
66 int m_remainingTime = 0;
67 int m_remainingTries = 0;
68 JsonSection m_challengeSecrets;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080069};
70
71std::ostream&
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080072operator<<(std::ostream& os, const CertificateRequest& request);
73
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070074} // namespace ndncert
75} // namespace ndn
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080076
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070077#endif // NDNCERT_CERTIFICATE_REQUEST_HPP