blob: 41791ed47b0eeeb03e5ac0a78148e11c437faceb [file] [log] [blame]
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento0dc02012021-11-23 22:55:03 -05002/*
Davide Pesavento0d1d11c2022-04-11 22:11:34 -04003 * Copyright (c) 2017-2022, Regents of the University of California.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -08004 *
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
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040026namespace ndncert::requester {
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080027
28/**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080029 * @brief CA profiles kept by a requester.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080030 * @sa https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
31 */
32class ProfileStorage
33{
34public:
35 /**
36 * @throw std::runtime_error when config file cannot be correctly parsed.
37 */
38 void
39 load(const std::string& fileName);
40
41 /**
42 * @throw std::runtime_error when config file cannot be correctly parsed.
43 */
44 void
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080045 load(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080046
47 void
48 save(const std::string& fileName) const;
49
50 void
51 removeCaProfile(const Name& caName);
52
53 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080054 * @brief Add a new CA profile
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040055 * @warning This will add a new trust anchor for requesters.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080056 */
57 void
58 addCaProfile(const CaProfile& profile);
59
60 const std::list<CaProfile>&
Zhiyi Zhang84e11842020-11-19 20:03:23 -080061 getKnownProfiles() const;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080062
63private:
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080064 std::list<CaProfile> m_caProfiles;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080065};
66
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040067} // namespace ndncert::requester
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080068
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080069#endif // NDNCERT_DETAIL_PROFILE_STORAGE_HPP