partially working new chronochat
diff --git a/src/chat-policy-rule.cpp b/src/chat-policy-rule.cpp
index 1aa8b24..201cf70 100644
--- a/src/chat-policy-rule.cpp
+++ b/src/chat-policy-rule.cpp
@@ -8,33 +8,37 @@
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
*/
-#include "chat-policy-rule.cpp"
+#include "chat-policy-rule.h"
+#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
using namespace ndn;
using namespace std;
using namespace ndn::security;
-ChatPolicyRule::ChatPolicyRule(Ptr<Regex> dataRegex, const Name& dataRef,
- Ptr<Regex> signerRegex, const Name& signerRef,
- bool isPositive)
- : PolicyRule(PolicyRule::IDENTITY_POLICY, isPositive)
+ChatPolicyRule::ChatPolicyRule(Ptr<Regex> dataRegex,
+ Ptr<Regex> signerRegex)
+ : PolicyRule(PolicyRule::IDENTITY_POLICY, true)
, m_dataRegex(dataRegex)
, m_signerRegex(signerRegex)
- , m_dataRef(dataRef)
- , m_signerRef(signerRef)
+{}
+
+ChatPolicyRule::ChatPolicyRule(const ChatPolicyRule& rule)
+ : PolicyRule(PolicyRule::IDENTITY_POLICY, true)
+ , m_dataRegex(rule.m_dataRegex)
+ , m_signerRegex(rule.m_signerRegex)
{}
bool
ChatPolicyRule::matchDataName(const Data & data)
-{ return (m_dataRegex.match(data.getName()) && m_dataRegex.expand() == m_dataRef) ? true : false; }
+{ return m_dataRegex->match(data.getName()); }
bool
ChatPolicyRule::matchSignerName(const Data & data)
{
Ptr<const signature::Sha256WithRsa> sigPtr = DynamicCast<const signature::Sha256WithRsa> (data.getSignature());
Name signerName = sigPtr->getKeyLocator ().getKeyName ();
- return (m_signerRegex.match(signerName) && m_signerRegex.expand() == m_signerRef) ? true : false;
+ return m_signerRegex->match(signerName);
}
bool
@@ -43,20 +47,4 @@
bool
ChatPolicyRule::satisfy(const Name & dataName, const Name & signerName)
-{
- if (m_dataRegex.match(data.getName())
- && m_dataRegex.expand() == m_dataRef
- && m_signerRegex.match(signerName)
- && m_signerRegex.expand() == m_signerRef)
- return true;
- else
- return false;
-}
-
-TiXmlElement *
-ChatPolicyRule::toXmlElement()
-{
- //TODO:
- return NULL;
-}
-};
+{ return (m_dataRegex->match(dataName) && m_signerRegex->match(signerName)); }