blob: 3df64074dfd86341c6c3776ff9b8d43f61c0bd80 [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/*
3 * Copyright (c) 2017-2021, 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
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080026namespace ndncert {
27namespace requester {
28
29/**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080030 * @brief CA profiles kept by a requester.
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080031 * @sa https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
32 */
33class ProfileStorage
34{
35public:
36 /**
37 * @throw std::runtime_error when config file cannot be correctly parsed.
38 */
39 void
40 load(const std::string& fileName);
41
42 /**
43 * @throw std::runtime_error when config file cannot be correctly parsed.
44 */
45 void
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080046 load(const JsonSection& json);
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080047
48 void
49 save(const std::string& fileName) const;
50
51 void
52 removeCaProfile(const Name& caName);
53
54 /**
Zhiyi Zhang84e11842020-11-19 20:03:23 -080055 * @brief Add a new CA profile
56 *
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080057 * Be cautious. This will add a new trust anchor for requesters.
58 */
59 void
60 addCaProfile(const CaProfile& profile);
61
62 const std::list<CaProfile>&
Zhiyi Zhang84e11842020-11-19 20:03:23 -080063 getKnownProfiles() const;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080064
65private:
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080066 std::list<CaProfile> m_caProfiles;
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080067};
68
69} // namespace requester
70} // namespace ndncert
Zhiyi Zhang3f20f952020-11-19 19:26:43 -080071
Zhiyi Zhang1e418f22020-11-19 19:49:32 -080072#endif // NDNCERT_DETAIL_PROFILE_STORAGE_HPP