blob: 5955f153f1c53818d660af8735864460efd0a09a [file] [log] [blame]
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017-2020, 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
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080021#ifndef NDNCERT_DETAIL_PROFILE_STORAGE_HPP
22#define NDNCERT_DETAIL_PROFILE_STORAGE_HPP
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080023
24#include "detail/ca-profile.hpp"
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080025
26namespace ndn {
27namespace ndncert {
28namespace requester {
29
30/**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080031 * @brief CA profiles kept by a requester.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080032 * @sa https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
33 */
34class ProfileStorage
35{
36public:
37 /**
38 * @throw std::runtime_error when config file cannot be correctly parsed.
39 */
40 void
41 load(const std::string& fileName);
42
43 /**
44 * @throw std::runtime_error when config file cannot be correctly parsed.
45 */
46 void
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080047 load(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080048
49 void
50 save(const std::string& fileName) const;
51
52 void
53 removeCaProfile(const Name& caName);
54
55 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080056 * @brief Add a new CA profile
57 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080058 * Be cautious. This will add a new trust anchor for requesters.
59 */
60 void
61 addCaProfile(const CaProfile& profile);
62
63 const std::list<CaProfile>&
Zhiyi Zhang84e11842020-11-19 20:03:23 -080064 getKnownProfiles() const;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080065
66private:
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080067 std::list<CaProfile> m_caProfiles;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080068};
69
70} // namespace requester
71} // namespace ndncert
72} // namespace ndn
73
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080074#endif // NDNCERT_DETAIL_PROFILE_STORAGE_HPP