trust-anchor-group.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2024 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library 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 Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_SECURITY_TRUST_ANCHOR_GROUP_HPP
23 #define NDN_CXX_SECURITY_TRUST_ANCHOR_GROUP_HPP
24 
25 #include "ndn-cxx/data.hpp"
27 
28 #include <filesystem>
29 #include <set>
30 
31 namespace ndn::security {
32 
34 {
35 public:
36  virtual
38 
39  virtual void
40  add(Certificate&& cert) = 0;
41 
42  virtual void
43  remove(const Name& certName) = 0;
44 };
45 
49 class TrustAnchorGroup : noncopyable
50 {
51 public:
55  TrustAnchorGroup(CertContainerInterface& certContainer, const std::string& id);
56 
57  virtual
59 
63  const std::string&
64  getId() const
65  {
66  return m_id;
67  }
68 
72  size_t
73  size() const;
74 
78  virtual void
79  refresh();
80 
81 protected:
83  std::set<Name> m_anchorNames;
84 
85 private:
86  std::string m_id;
87 };
88 
93 {
94 public:
100  StaticTrustAnchorGroup(CertContainerInterface& certContainer, const std::string& id);
101 
105  void
106  add(Certificate&& cert);
107 
111  void
112  remove(const Name& certName);
113 };
114 
119 {
120 public:
150  DynamicTrustAnchorGroup(CertContainerInterface& certContainer, const std::string& id,
151  const std::filesystem::path& path, time::nanoseconds refreshPeriod,
152  bool isDir = false);
153 
154  void
155  refresh() override;
156 
157 private:
158  bool m_isDir;
159  std::filesystem::path m_path;
160  time::nanoseconds m_refreshPeriod;
161  time::steady_clock::time_point m_expireTime;
162 };
163 
164 } // namespace ndn::security
165 
166 #endif // NDN_CXX_SECURITY_TRUST_ANCHOR_GROUP_HPP
Represents an absolute name.
Definition: name.hpp:45
virtual void remove(const Name &certName)=0
virtual void add(Certificate &&cert)=0
Represents an NDN certificate.
Definition: certificate.hpp:58
DynamicTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id, const std::filesystem::path &path, time::nanoseconds refreshPeriod, bool isDir=false)
Create a dynamic trust anchor group.
void refresh() override
Request certificate refresh.
void add(Certificate &&cert)
Load static anchor cert.
void remove(const Name &certName)
Remove static anchor certName.
StaticTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create a static trust anchor group.
TrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create an anchor group.
CertContainerInterface & m_certs
const std::string & getId() const
virtual void refresh()
Request certificate refresh.
::boost::chrono::time_point< steady_clock > time_point
Definition: time.hpp:232
Contains the ndn-cxx security framework.
::boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:54