blob: 19e7d4f563786c10ef2e8472d501dc4f42cd4001 [file] [log] [blame]
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventob48bbda2020-07-27 19:41:37 -04002/*
3 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -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
21#ifndef NDNCERT_CA_DETAIL_CA_MEMORY_HPP
22#define NDNCERT_CA_DETAIL_CA_MEMORY_HPP
23
24#include "../ca-storage.hpp"
25
26namespace ndn {
27namespace ndncert {
28
29class CaMemory : public CaStorage
30{
31public:
32 const static std::string STORAGE_TYPE;
33
34public:
35 // certificate request related
Zhiyi Zhange232a742020-09-29 17:34:17 -070036 RequestState
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080037 getRequest(const std::string& requestId) override;
38
39 void
Zhiyi Zhange232a742020-09-29 17:34:17 -070040 addRequest(const RequestState& request) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080041
42 void
Zhiyi Zhange232a742020-09-29 17:34:17 -070043 updateRequest(const RequestState& request) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080044
45 void
46 deleteRequest(const std::string& requestId) override;
47
Zhiyi Zhange232a742020-09-29 17:34:17 -070048 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070049 listAllRequests() override;
50
Zhiyi Zhange232a742020-09-29 17:34:17 -070051 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070052 listAllRequests(const Name& caName) override;
53
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080054 // certificate related
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070055 security::v2::Certificate
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080056 getCertificate(const std::string& certId) override;
57
58 void
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070059 addCertificate(const std::string& certId, const security::v2::Certificate& cert) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080060
61 void
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070062 updateCertificate(const std::string& certId, const security::v2::Certificate& cert) override;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080063
64 void
65 deleteCertificate(const std::string& certId) override;
66
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070067 std::list<security::v2::Certificate>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070068 listAllIssuedCertificates() override;
69
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070070 std::list<security::v2::Certificate>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070071 listAllIssuedCertificates(const Name& caName) override;
72
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080073private:
Zhiyi Zhange232a742020-09-29 17:34:17 -070074 std::map<std::string, RequestState> m_requests;
Zhiyi Zhangef6b36a2020-09-22 21:20:59 -070075 std::map<std::string, security::v2::Certificate> m_issuedCerts;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080076};
77
78} // namespace ndncert
79} // namespace ndn
80
81#endif // NDNCERT_CA_DETAIL_CA_MEMORY_HPP