22 #ifndef NDN_SECURITY_VALIDATOR_CONFIG_HPP
23 #define NDN_SECURITY_VALIDATOR_CONFIG_HPP
57 const size_t stepLimit = 10,
58 const size_t maxTrackedKeys = 1000,
66 const size_t stepLimit = 10,
67 const size_t maxTrackedKeys = 1000,
71 load(
const std::string& filename);
74 load(
const std::string& input,
const std::string& filename);
77 load(std::istream& input,
const std::string& filename);
81 const std::string& filename);
95 std::vector<shared_ptr<ValidationRequest>>& nextSteps)
override;
102 std::vector<shared_ptr<ValidationRequest>>& nextSteps)
override;
105 template<
class Packet,
class OnVal
idated,
class OnFailed>
107 checkSignature(
const Packet& packet,
110 const OnValidated& onValidated,
111 const OnFailed& onValidationFailed,
112 std::vector<shared_ptr<ValidationRequest>>& nextSteps);
115 checkTimestamp(
const shared_ptr<const Interest>& interest,
120 template<
class Packet,
class OnVal
idated,
class OnFailed>
122 onCertValidated(
const shared_ptr<const Data>& signCertificate,
123 const shared_ptr<const Packet>& packet,
124 const OnValidated& onValidated,
125 const OnFailed& onValidationFailed);
127 template<
class Packet,
class OnFailed>
129 onCertFailed(
const shared_ptr<const Data>& signCertificate,
130 const std::string& failureInfo,
131 const shared_ptr<const Packet>& packet,
132 const OnFailed& onValidationFailed);
136 const std::string& filename);
140 const std::string& filename);
143 getRefreshPeriod(std::string refreshString);
146 getDefaultRefreshPeriod();
154 class TrustAnchorContainer
157 const std::list<shared_ptr<v1::IdentityCertificate>>&
160 return m_certificates;
164 add(shared_ptr<v1::IdentityCertificate> certificate)
166 m_certificates.push_back(certificate);
170 std::list<shared_ptr<v1::IdentityCertificate>> m_certificates;
173 class DynamicTrustAnchorContainer :
public TrustAnchorContainer
176 DynamicTrustAnchorContainer(
const boost::filesystem::path& path,
bool isDir,
177 time::nanoseconds refreshPeriod)
180 , m_refreshPeriod(refreshPeriod)
187 m_lastRefresh = lastRefresh;
191 getLastRefresh()
const
193 return m_lastRefresh;
196 const time::nanoseconds&
197 getRefreshPeriod()
const
199 return m_refreshPeriod;
206 boost::filesystem::path m_path;
210 time::nanoseconds m_refreshPeriod;
214 compareDynamicContainer(
const DynamicTrustAnchorContainer& containerA,
215 const DynamicTrustAnchorContainer& containerB)
217 return (containerA.getLastRefresh() < containerB.getLastRefresh());
228 typedef std::vector<shared_ptr<InterestRule>> InterestRuleList;
229 typedef std::vector<shared_ptr<DataRule>> DataRuleList;
230 typedef std::map<Name, shared_ptr<v1::IdentityCertificate>> AnchorList;
231 typedef std::list<DynamicTrustAnchorContainer> DynamicContainers;
232 typedef std::list<shared_ptr<v1::IdentityCertificate>> CertificateList;
239 bool m_shouldValidate;
242 shared_ptr<CertificateCache> m_certificateCache;
244 InterestRuleList m_interestRules;
245 DataRuleList m_dataRules;
247 AnchorList m_anchors;
248 TrustAnchorContainer m_staticContainer;
249 DynamicContainers m_dynamicContainers;
251 time::milliseconds m_graceInterval;
252 size_t m_maxTrackedKeys;
253 typedef std::map<Name, time::system_clock::TimePoint> LastTimestampMap;
254 LastTimestampMap m_lastTimestamp;
264 #endif // NDN_SECURITY_VALIDATOR_CONFIG_HPP
function< void(const shared_ptr< const Interest > &, const std::string &)> OnInterestValidationFailed
Callback to report a failed Interest validation.
Copyright (c) 2013-2016 Regents of the University of California.
void load(const std::string &filename)
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
The validator which can be set up via a configuration file.
Error(const std::string &what)
represents an Interest packet
ValidatorConfig(Face *face=nullptr, const shared_ptr< CertificateCache > &certificateCache=DEFAULT_CERTIFICATE_CACHE, const time::milliseconds &graceInterval=DEFAULT_GRACE_INTERVAL, const size_t stepLimit=10, const size_t maxTrackedKeys=1000, const time::system_clock::Duration &keyTimestampTtl=DEFAULT_KEY_TIMESTAMP_TTL)
function< void(const shared_ptr< const Data > &, const std::string &)> OnDataValidationFailed
Callback to report a failed Data validation.
static const time::milliseconds DEFAULT_GRACE_INTERVAL
function< void(const shared_ptr< const Data > &)> OnDataValidated
Callback to report a successful Data validation.
function< void(const shared_ptr< const Interest > &)> OnInterestValidated
Callback to report a successful Interest validation.
static const shared_ptr< CertificateCache > DEFAULT_CERTIFICATE_CACHE
provides the interfaces for packet validation.
Provide a communication channel with local or remote NDN forwarder.
Name abstraction to represent an absolute name.
void checkPolicy(const Data &data, int nSteps, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest >> &nextSteps) override
Check the Data against policy and return the next validation step if necessary.
boost::property_tree::ptree ConfigSection
static const time::system_clock::Duration DEFAULT_KEY_TIMESTAMP_TTL
A Signature is storage for the signature-related information (info and value) in a Data packet...