NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
sec-rule-specific.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24
#include "common.hpp"
25
26
#include "
sec-rule-specific.hpp
"
27
#include "
signature-sha256-with-rsa.hpp
"
28
29
namespace
ndn
{
30
31
SecRuleSpecific::SecRuleSpecific
(shared_ptr<Regex> dataRegex,
32
shared_ptr<Regex> signerRegex)
33
:
SecRule
(true)
34
, m_dataRegex(dataRegex)
35
, m_signerRegex(signerRegex)
36
, m_isExempted(false)
37
{
38
}
39
40
SecRuleSpecific::SecRuleSpecific
(shared_ptr<Regex> dataRegex)
41
:
SecRule
(true)
42
, m_dataRegex(dataRegex)
43
, m_isExempted(true)
44
{
45
}
46
47
SecRuleSpecific::SecRuleSpecific
(
const
SecRuleSpecific
& rule)
48
:
SecRule
(true)
49
, m_dataRegex(rule.m_dataRegex)
50
, m_signerRegex(rule.m_signerRegex)
51
, m_isExempted(rule.m_isExempted)
52
{
53
}
54
55
bool
56
SecRuleSpecific::matchDataName
(
const
Data
& data)
57
{
58
return
m_dataRegex->match(data.
getName
());
59
}
60
61
bool
62
SecRuleSpecific::matchSignerName
(
const
Data
& data)
63
{
64
if
(m_isExempted)
65
return
true
;
66
67
try
68
{
69
if
(!data.
getSignature
().
hasKeyLocator
())
70
return
false
;
71
72
const
KeyLocator
& keyLocator = data.
getSignature
().
getKeyLocator
();
73
if
(keyLocator.
getType
() !=
KeyLocator::KeyLocator_Name
)
74
return
false
;
75
76
const
Name
& signerName = keyLocator.
getName
();
77
return
m_signerRegex->match(signerName);
78
}
79
catch
(
tlv::Error
& e)
80
{
81
return
false
;
82
}
83
catch
(
RegexMatcher::Error
& e)
84
{
85
return
false
;
86
}
87
}
88
89
bool
90
SecRuleSpecific::satisfy
(
const
Data
& data)
91
{
92
return
(
matchDataName
(data) &&
matchSignerName
(data)) ? true :
false
;
93
}
94
95
bool
96
SecRuleSpecific::satisfy
(
const
Name
& dataName,
const
Name
& signerName)
97
{
98
bool
isSignerMatched = m_isExempted || m_signerRegex->match(signerName);
99
return
m_dataRegex->match(dataName) && isSignerMatched;
100
}
101
102
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
signature-sha256-with-rsa.hpp
ndn::SecRuleSpecific::matchDataName
bool matchDataName(const Data &data)
Definition:
sec-rule-specific.cpp:56
ndn::SecRuleSpecific::matchSignerName
bool matchSignerName(const Data &data)
Definition:
sec-rule-specific.cpp:62
ndn::Data::getName
const Name & getName() const
Get name of the Data packet.
Definition:
data.hpp:343
ndn::SecRuleSpecific
Definition:
sec-rule-specific.hpp:33
ndn::KeyLocator::getName
const Name & getName() const
get Name element
Definition:
key-locator.cpp:138
ndn::KeyLocator::KeyLocator_Name
indicates KeyLocator contains a Name
Definition:
key-locator.hpp:49
ndn::Signature::hasKeyLocator
bool hasKeyLocator() const
Check if SignatureInfo block has a KeyLocator.
Definition:
signature.hpp:123
ndn::Name
Name abstraction to represent an absolute name.
Definition:
name.hpp:46
sec-rule-specific.hpp
ndn::KeyLocator
Definition:
key-locator.hpp:30
ndn::KeyLocator::getType
Type getType() const
Definition:
key-locator.hpp:101
ndn::RegexMatcher::Error
Definition:
regex-matcher.hpp:37
ndn::SecRuleSpecific::SecRuleSpecific
SecRuleSpecific(shared_ptr< Regex > dataRegex, shared_ptr< Regex > signerRegex)
Definition:
sec-rule-specific.cpp:31
ndn::Data::getSignature
const Signature & getSignature() const
Definition:
data.hpp:373
ndn::Signature::getKeyLocator
const KeyLocator & getKeyLocator() const
Get KeyLocator.
Definition:
signature.hpp:134
ndn::Data
represents a Data packet
Definition:
data.hpp:39
ndn::SecRule
Definition:
sec-rule.hpp:32
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:50
ndn::SecRuleSpecific::satisfy
bool satisfy(const Data &data)
Definition:
sec-rule-specific.cpp:90
ndnSIM
ndn-cxx
src
security
sec-rule-specific.cpp
Generated on Fri Feb 23 2018 12:30:55 for ndnSIM by
1.8.14