blob: b3988c09010de1f403cb95c13c279a169b50a14b [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/*
3 * Copyright (c) 2017-2020, 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
21#ifndef NDNCERT_CA_DETAIL_CA_SQLITE_HPP
22#define NDNCERT_CA_DETAIL_CA_SQLITE_HPP
23
24#include "../ca-module.hpp"
tylerliu8704d032020-06-23 10:18:15 -070025#include "../ca-state.hpp"
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070026
27struct sqlite3;
28
29namespace ndn {
30namespace ndncert {
31
32class CaSqlite : public CaStorage
33{
34public:
35 const static std::string STORAGE_TYPE;
36
37 explicit
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070038 CaSqlite(const Name& caName, const std::string& path = "");
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070039
40 ~CaSqlite();
41
42public:
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070043 /**
44 * @throw if request cannot be fetched from underlying data storage
45 */
tylerliu8704d032020-06-23 10:18:15 -070046 CaState
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070047 getRequest(const std::string& requestId) override;
48
Zhiyi Zhang21d52b52020-10-05 18:29:15 -070049 /**
50 * @throw if there is an existing request with the same request ID
51 */
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070052 void
tylerliu8704d032020-06-23 10:18:15 -070053 addRequest(const CaState& request) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070054
55 void
tylerliu8704d032020-06-23 10:18:15 -070056 updateRequest(const CaState& request) override;
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070057
58 void
59 deleteRequest(const std::string& requestId) override;
60
tylerliu8704d032020-06-23 10:18:15 -070061 std::list<CaState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070062 listAllRequests() override;
63
tylerliu8704d032020-06-23 10:18:15 -070064 std::list<CaState>
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070065 listAllRequests(const Name& caName) override;
66
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070067private:
68 sqlite3* m_database;
69};
70
71} // namespace ndncert
72} // namespace ndn
73
74#endif // NDNCERT_CA_DETAIL_CA_SQLITE_HPP