src: Improving consistency and correcting code style
As of this commit, all data structures can be directly constructed from
wire format.
This commit excludes full correction of code style in security/ and
tools/ndnsec*, which will be part of a different commit.
Change-Id: I121ac1f81948bc7468990df52cdefeb2988d91a1
Refs: #1403
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index 1fdfa7d..6133aac 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -20,7 +20,7 @@
namespace ndn {
-SecRuleRelative::SecRuleRelative (const string& dataRegex, const string& signerRegex, const string& op,
+SecRuleRelative::SecRuleRelative (const string& dataRegex, const string& signerRegex, const string& op,
const string& dataExpand, const string& signerExpand, bool isPositive)
: SecRule(isPositive),
m_dataRegex(dataRegex),
@@ -31,68 +31,73 @@
m_dataNameRegex(dataRegex, dataExpand),
m_signerNameRegex(signerRegex, signerExpand)
{
- if(op != ">" && op != ">=" && op != "==")
+ if (op != ">" && op != ">=" && op != "==")
throw Error("op is wrong!");
}
SecRuleRelative::~SecRuleRelative()
-{ }
+{
+}
-bool
+bool
SecRuleRelative::satisfy (const Data& data)
{
Name dataName = data.getName();
- try{
+ try {
SignatureSha256WithRsa sig(data.getSignature());
Name signerName = sig.getKeyLocator().getName ();
- return satisfy (dataName, signerName);
- }catch(SignatureSha256WithRsa::Error &e){
+ return satisfy (dataName, signerName);
+ }
+ catch (SignatureSha256WithRsa::Error& e){
return false;
- }catch(KeyLocator::Error &e){
+ }
+ catch (KeyLocator::Error& e){
return false;
}
}
-
-bool
+
+bool
SecRuleRelative::satisfy (const Name& dataName, const Name& signerName)
{
- if(!m_dataNameRegex.match(dataName))
+ if (!m_dataNameRegex.match(dataName))
return false;
Name expandDataName = m_dataNameRegex.expand();
- if(!m_signerNameRegex.match(signerName))
+ if (!m_signerNameRegex.match(signerName))
return false;
Name expandSignerName = m_signerNameRegex.expand();
-
+
bool matched = compare(expandDataName, expandSignerName);
-
+
return matched;
}
-bool
+bool
SecRuleRelative::matchDataName (const Data& data)
{ return m_dataNameRegex.match(data.getName()); }
bool
SecRuleRelative::matchSignerName (const Data& data)
-{
- try{
+{
+ try {
SignatureSha256WithRsa sig(data.getSignature());
Name signerName = sig.getKeyLocator().getName ();
- return m_signerNameRegex.match(signerName);
- }catch(SignatureSha256WithRsa::Error &e){
+ return m_signerNameRegex.match(signerName);
+ }
+ catch (SignatureSha256WithRsa::Error& e){
return false;
- }catch(KeyLocator::Error &e){
+ }
+ catch (KeyLocator::Error& e){
return false;
}
}
-bool
-SecRuleRelative::compare(const Name & dataName, const Name & signerName)
-{
- if((dataName == signerName) && ("==" == m_op || ">=" == m_op))
+bool
+SecRuleRelative::compare(const Name& dataName, const Name& signerName)
+{
+ if ((dataName == signerName) && ("==" == m_op || ">=" == m_op))
return true;
-
+
Name::const_iterator i = dataName.begin ();
Name::const_iterator j = signerName.begin ();
@@ -103,10 +108,10 @@
else
return false;
}
-
- if(i == dataName.end())
+
+ if (i == dataName.end())
return false;
- else
+ else
return true;
}