Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | b48bbda | 2020-07-27 19:41:37 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [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 | |
| 21 | #ifndef NDNCERT_CA_DETAIL_CA_SQLITE_HPP |
| 22 | #define NDNCERT_CA_DETAIL_CA_SQLITE_HPP |
| 23 | |
| 24 | #include "../ca-module.hpp" |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 25 | #include "../ca-state.hpp" |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 26 | |
| 27 | struct sqlite3; |
| 28 | |
| 29 | namespace ndn { |
| 30 | namespace ndncert { |
| 31 | |
| 32 | class CaSqlite : public CaStorage |
| 33 | { |
| 34 | public: |
| 35 | const static std::string STORAGE_TYPE; |
| 36 | |
| 37 | explicit |
| 38 | CaSqlite(const std::string& location = ""); |
| 39 | |
| 40 | ~CaSqlite(); |
| 41 | |
| 42 | public: |
| 43 | // certificate request related |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 44 | CaState |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 45 | getRequest(const std::string& requestId) override; |
| 46 | |
| 47 | void |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 48 | addRequest(const CaState& request) override; |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 49 | |
| 50 | void |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 51 | updateRequest(const CaState& request) override; |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 52 | |
| 53 | void |
| 54 | deleteRequest(const std::string& requestId) override; |
| 55 | |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 56 | std::list<CaState> |
Zhiyi Zhang | ae123bf | 2017-04-14 12:24:53 -0700 | [diff] [blame] | 57 | listAllRequests() override; |
| 58 | |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 59 | std::list<CaState> |
Zhiyi Zhang | ae123bf | 2017-04-14 12:24:53 -0700 | [diff] [blame] | 60 | listAllRequests(const Name& caName) override; |
| 61 | |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 62 | // certificate related |
Zhiyi Zhang | ef6b36a | 2020-09-22 21:20:59 -0700 | [diff] [blame] | 63 | security::v2::Certificate |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 64 | getCertificate(const std::string& certId) override; |
| 65 | |
| 66 | void |
Zhiyi Zhang | ef6b36a | 2020-09-22 21:20:59 -0700 | [diff] [blame] | 67 | addCertificate(const std::string& certId, const security::v2::Certificate& cert) override; |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 68 | |
| 69 | void |
Zhiyi Zhang | ef6b36a | 2020-09-22 21:20:59 -0700 | [diff] [blame] | 70 | updateCertificate(const std::string& certId, const security::v2::Certificate& cert) override; |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 71 | |
| 72 | void |
| 73 | deleteCertificate(const std::string& certId) override; |
| 74 | |
Zhiyi Zhang | ef6b36a | 2020-09-22 21:20:59 -0700 | [diff] [blame] | 75 | std::list<security::v2::Certificate> |
Zhiyi Zhang | ae123bf | 2017-04-14 12:24:53 -0700 | [diff] [blame] | 76 | listAllIssuedCertificates() override; |
| 77 | |
Zhiyi Zhang | ef6b36a | 2020-09-22 21:20:59 -0700 | [diff] [blame] | 78 | std::list<security::v2::Certificate> |
Zhiyi Zhang | ae123bf | 2017-04-14 12:24:53 -0700 | [diff] [blame] | 79 | listAllIssuedCertificates(const Name& caName) override; |
| 80 | |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 81 | private: |
| 82 | sqlite3* m_database; |
| 83 | }; |
| 84 | |
| 85 | } // namespace ndncert |
| 86 | } // namespace ndn |
| 87 | |
| 88 | #endif // NDNCERT_CA_DETAIL_CA_SQLITE_HPP |