24 #ifndef NDN_SECURITY_VALIDATOR_CONFIG_HPP 25 #define NDN_SECURITY_VALIDATOR_CONFIG_HPP 55 const size_t stepLimit = 10,
56 const size_t maxTrackedKeys = 1000,
64 const size_t stepLimit = 10,
65 const size_t maxTrackedKeys = 1000,
74 load(
const std::string& filename);
77 load(
const std::string& input,
const std::string& filename);
80 load(std::istream& input,
const std::string& filename);
84 const std::string& filename);
98 std::vector<shared_ptr<ValidationRequest> >& nextSteps);
105 std::vector<shared_ptr<ValidationRequest> >& nextSteps);
108 template<
class Packet,
class OnVal
idated,
class OnFailed>
110 checkSignature(
const Packet& packet,
113 const OnValidated& onValidated,
114 const OnFailed& onValidationFailed,
115 std::vector<shared_ptr<ValidationRequest> >& nextSteps);
118 checkTimestamp(
const shared_ptr<const Interest>& interest,
123 template<
class Packet,
class OnVal
idated,
class OnFailed>
125 onCertValidated(
const shared_ptr<const Data>& signCertificate,
126 const shared_ptr<const Packet>& packet,
127 const OnValidated& onValidated,
128 const OnFailed& onValidationFailed);
130 template<
class Packet,
class OnFailed>
132 onCertFailed(
const shared_ptr<const Data>& signCertificate,
133 const std::string& failureInfo,
134 const shared_ptr<const Packet>& packet,
135 const OnFailed& onValidationFailed);
139 const std::string& filename);
143 const std::string& filename);
146 getRefreshPeriod(std::string refreshString);
149 getDefaultRefreshPeriod();
157 #ifdef NDN_CXX_HAVE_TESTS 159 getTimestampMapSize()
161 return m_lastTimestamp.size();
165 class TrustAnchorContainer
168 TrustAnchorContainer()
172 const std::list<shared_ptr<IdentityCertificate> >&
175 return m_certificates;
179 add(shared_ptr<IdentityCertificate> certificate)
181 m_certificates.push_back(certificate);
185 std::list<shared_ptr<IdentityCertificate> > m_certificates;
188 class DynamicTrustAnchorContainer :
public TrustAnchorContainer
191 DynamicTrustAnchorContainer(
const boost::filesystem::path& path,
bool isDir,
192 time::nanoseconds refreshPeriod)
195 , m_refreshPeriod(refreshPeriod)
202 m_lastRefresh = lastRefresh;
206 getLastRefresh()
const 208 return m_lastRefresh;
211 const time::nanoseconds&
212 getRefreshPeriod()
const 214 return m_refreshPeriod;
221 boost::filesystem::path m_path;
225 time::nanoseconds m_refreshPeriod;
229 compareDynamicContainer(
const DynamicTrustAnchorContainer& containerA,
230 const DynamicTrustAnchorContainer& containerB)
232 return (containerA.getLastRefresh() < containerB.getLastRefresh());
243 typedef std::vector<shared_ptr<InterestRule> > InterestRuleList;
244 typedef std::vector<shared_ptr<DataRule> > DataRuleList;
245 typedef std::map<Name, shared_ptr<IdentityCertificate> > AnchorList;
246 typedef std::list<DynamicTrustAnchorContainer> DynamicContainers;
247 typedef std::list<shared_ptr<IdentityCertificate> > CertificateList;
255 bool m_shouldValidate;
258 shared_ptr<CertificateCache> m_certificateCache;
260 InterestRuleList m_interestRules;
261 DataRuleList m_dataRules;
263 AnchorList m_anchors;
264 TrustAnchorContainer m_staticContainer;
265 DynamicContainers m_dynamicContainers;
267 time::milliseconds m_graceInterval;
268 size_t m_maxTrackedKeys;
269 typedef std::map<Name, time::system_clock::TimePoint> LastTimestampMap;
270 LastTimestampMap m_lastTimestamp;
276 #endif // NDN_SECURITY_VALIDATOR_CONFIG_HPP Copyright (c) 2011-2015 Regents of the University of California.
void load(const std::string &filename)
static const time::system_clock::Duration DEFAULT_KEY_TIMESTAMP_TTL
represents an Interest packet
virtual void checkPolicy(const Data &data, int nSteps, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
Check the Data against policy and return the next validation step if necessary.
virtual ~ValidatorConfig()
Error(const std::string &what)
function< void(const shared_ptr< const Data > &)> OnDataValidated
Callback to report a successful Data validation.
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.
Abstraction to communicate with local or remote NDN forwarder.
static const shared_ptr< CertificateCache > DEFAULT_CERTIFICATE_CACHE
Name abstraction to represent an absolute name.
static const time::milliseconds DEFAULT_GRACE_INTERVAL
function< void(const shared_ptr< const Interest > &, const std::string &)> OnInterestValidationFailed
Callback to report a failed Interest validation.
boost::property_tree::ptree ConfigSection
Validator is one of the main classes of the security library.
function< void(const shared_ptr< const Interest > &)> OnInterestValidated
Callback to report a successful Interest validation.
A Signature is storage for the signature-related information (info and value) in a Data packet...