All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sec-rule-specific.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
8 #include "common.hpp"
9 
10 #include "sec-rule-specific.hpp"
12 
13 using namespace std;
14 
15 namespace ndn {
16 
17 SecRuleSpecific::SecRuleSpecific(shared_ptr<Regex> dataRegex,
18  shared_ptr<Regex> signerRegex)
19  : SecRule(true)
20  , m_dataRegex(dataRegex)
21  , m_signerRegex(signerRegex)
22 {
23 }
24 
26  : SecRule(true)
27  , m_dataRegex(rule.m_dataRegex)
28  , m_signerRegex(rule.m_signerRegex)
29 {
30 }
31 
32 bool
34 {
35  return m_dataRegex->match(data.getName());
36 }
37 
38 bool
40 {
41  try
42  {
44  Name signerName = sig.getKeyLocator().getName();
45  return m_signerRegex->match(signerName);
46  }
47  catch (std::runtime_error& e)
48  {
49  return false;
50  }
51 }
52 
53 bool
55 {
56  return (matchDataName(data) && matchSignerName(data)) ? true : false;
57 }
58 
59 bool
60 SecRuleSpecific::satisfy(const Name& dataName, const Name& signerName)
61 {
62  return (m_dataRegex->match(dataName) && m_signerRegex->match(signerName));
63 }
64 
65 } // namespace ndn
Representing of SHA256-with-RSA signature in a data packet.
bool matchDataName(const Data &data)
bool matchSignerName(const Data &data)
const Name & getName() const
Definition: data.hpp:346
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:26
const Signature & getSignature() const
Definition: data.hpp:450
SecRuleSpecific(shared_ptr< Regex > dataRegex, shared_ptr< Regex > signerRegex)
bool satisfy(const Data &data)