blob: 35fb2f7c58f6b93627363a8b754ea6d9f670932d [file] [log] [blame]
Zhiyi Zhanga41c5732017-01-18 14:06:44 -08001/* -*- 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_CERTFICATE_REQUEST_HPP
22#define NDNCERT_CERTFICATE_REQUEST_HPP
23
24#include "ndncert-common.hpp"
25#include <ndn-cxx/security/v2/certificate.hpp>
26
27namespace ndn {
28namespace ndncert {
29
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080030typedef boost::property_tree::ptree JsonSection;
31
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080032/**
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 */
39class CertificateRequest
40{
41public:
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080042 CertificateRequest(const Name& caName, const std::string& requestId,
43 const security::v2::Certificate& cert);
44
45 CertificateRequest(const Name& caName, const std::string& requestId,
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080046 const std::string& status, const std::string& challengeType,
47 const std::string& challengeDefinedField,
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080048 const security::v2::Certificate& certBlock);
49
50 const Name&
51 getCaName() const
52 {
53 return m_caName;
54 }
55
56 const std::string&
57 getRequestId() const
58 {
59 return m_requestId;
60 }
61
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080062 const std::string&
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080063 getStatus() const
64 {
65 return m_status;
66 }
67
68 const std::string&
69 getChallengeType() const
70 {
71 return m_challengeType;
72 }
73
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080074 const JsonSection&
75 getChallengeSecrets() const
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080076 {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080077 return m_challengeSecrets;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080078 }
79
80 const security::v2::Certificate&
81 getCert() const
82 {
83 return m_cert;
84 }
85
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080086 void
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080087 setStatus(const std::string& status)
Zhiyi Zhanga41c5732017-01-18 14:06:44 -080088 {
89 m_status = status;
90 }
91
92 void
93 setChallengeType(const std::string& challengeType)
94 {
95 m_challengeType = challengeType;
96 }
97
98 void
Zhiyi Zhang3b267e62017-02-09 17:59:34 -080099 setChallengeSecrets(const JsonSection& challengeSecrets)
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800100 {
Zhiyi Zhang3b267e62017-02-09 17:59:34 -0800101 m_challengeSecrets = challengeSecrets;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800102 }
103
104private:
105 Name m_caName;
106 std::string m_requestId;
Zhiyi Zhang3b267e62017-02-09 17:59:34 -0800107 std::string m_status;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800108 std::string m_challengeType;
109
110 /**
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800111 * @brief Defined by ChallengeModule to store secret information.
112 *
113 * This field will be stored by CA.
114 */
Zhiyi Zhang3b267e62017-02-09 17:59:34 -0800115 JsonSection m_challengeSecrets;
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800116
117 security::v2::Certificate m_cert;
118};
119
120std::ostream&
Zhiyi Zhanga41c5732017-01-18 14:06:44 -0800121operator<<(std::ostream& os, const CertificateRequest& request);
122
123} // namespace ndncert
124} // namespace ndn
125
126#endif // NDNCERT_CERTFICATE_REQUEST_HPP