blob: 969cacfba74ab7f02563b14a88c690aa12cd28fe [file] [log] [blame]
Zhiyi Zhang91c846b2017-04-12 14:16:31 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventob48bbda2020-07-27 19:41:37 -04002/*
Davide Pesavento0dc02012021-11-23 22:55:03 -05003 * Copyright (c) 2017-2021, Regents of the University of California.
Zhiyi Zhang91c846b2017-04-12 14:16:31 -07004 *
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 Zhanga62bf982020-10-26 13:10:02 -070021#ifndef NDNCERT_DETAIL_CA_SQLITE_HPP
22#define NDNCERT_DETAIL_CA_SQLITE_HPP
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070023
Zhiyi Zhangb041d442020-10-22 21:57:11 -070024#include "detail/ca-storage.hpp"
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070025
26struct sqlite3;
27
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070028namespace ndncert {
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070029namespace ca {
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070030
31class CaSqlite : public CaStorage
32{
33public:
34 const static std::string STORAGE_TYPE;
35
36 explicit
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070037 CaSqlite(const Name& caName, const std::string& path = "");
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070038
Davide Pesavento0dc02012021-11-23 22:55:03 -050039 ~CaSqlite() override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070040
41public:
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070042 /**
43 * @throw if request cannot be fetched from underlying data storage
44 */
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070045 RequestState
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -070046 getRequest(const RequestId& requestId) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070047
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070048 /**
49 * @throw if there is an existing request with the same request ID
50 */
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070051 void
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070052 addRequest(const RequestState& request) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070053
54 void
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070055 updateRequest(const RequestState& request) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070056
57 void
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -070058 deleteRequest(const RequestId& requestId) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070059
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070060 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070061 listAllRequests() override;
62
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070063 std::list<RequestState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070064 listAllRequests(const Name& caName) override;
65
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070066private:
67 sqlite3* m_database;
68};
69
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070070} // namespace ca
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070071} // namespace ndncert
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070072
Zhiyi Zhanga62bf982020-10-26 13:10:02 -070073#endif // NDNCERT_DETAIL_CA_SQLITE_HPP