blob: d31f8955eb9a4aee467147c153dc2a8602b2781e [file] [log] [blame]
Zhiyi Zhang91c846b2017-04-12 14:16:31 -07001/* -*- 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_CA_DETAIL_CA_SQLITE_HPP
22#define NDNCERT_CA_DETAIL_CA_SQLITE_HPP
23
24#include "../ca-module.hpp"
25#include "../certificate-request.hpp"
26
27struct sqlite3;
28
29namespace ndn {
30namespace ndncert {
31
32class CaSqlite : public CaStorage
33{
34public:
35 const static std::string STORAGE_TYPE;
36
37 explicit
38 CaSqlite(const std::string& location = "");
39
40 ~CaSqlite();
41
42public:
43 // certificate request related
44 CertificateRequest
45 getRequest(const std::string& requestId) override;
46
47 void
48 addRequest(const CertificateRequest& request) override;
49
50 void
51 updateRequest(const CertificateRequest& request) override;
52
53 void
54 deleteRequest(const std::string& requestId) override;
55
56 // certificate related
57 security::v2::Certificate
58 getCertificate(const std::string& certId) override;
59
60 void
61 addCertificate(const std::string& certId, const security::v2::Certificate& cert) override;
62
63 void
64 updateCertificate(const std::string& certId, const security::v2::Certificate& cert) override;
65
66 void
67 deleteCertificate(const std::string& certId) override;
68
69private:
70 static std::string
71 convertJson2String(const JsonSection& json);
72
73 static JsonSection
74 convertString2Json(const std::string& jsonContent);
75
76private:
77 sqlite3* m_database;
78};
79
80} // namespace ndncert
81} // namespace ndn
82
83#endif // NDNCERT_CA_DETAIL_CA_SQLITE_HPP