Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 9 | #ifndef NDN_SECURITY_SEC_RULE_RELATIVE_HPP |
| 10 | #define NDN_SECURITY_SEC_RULE_RELATIVE_HPP |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 11 | |
| 12 | #include "sec-rule.hpp" |
| 13 | #include "../util/regex.hpp" |
| 14 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 15 | namespace ndn { |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 16 | |
| 17 | class SecRuleRelative : public SecRule |
| 18 | { |
| 19 | public: |
| 20 | struct Error : public SecRule::Error { Error(const std::string &what) : SecRule::Error(what) {} }; |
| 21 | |
| 22 | SecRuleRelative(const std::string& dataRegex, const std::string& signerRegex, const std::string& op, |
| 23 | const std::string& dataExpand, const std::string& signerExpand, bool isPositive); |
| 24 | |
| 25 | virtual |
| 26 | ~SecRuleRelative(); |
| 27 | |
| 28 | virtual bool |
| 29 | matchDataName(const Data& data); |
| 30 | |
| 31 | virtual bool |
| 32 | matchSignerName(const Data& data); |
| 33 | |
| 34 | virtual bool |
| 35 | satisfy(const Data& data); |
| 36 | |
| 37 | virtual bool |
| 38 | satisfy(const Name& dataName, const Name& signerName); |
| 39 | |
| 40 | private: |
| 41 | bool |
| 42 | compare(const Name& dataName, const Name& signerName); |
| 43 | |
| 44 | private: |
| 45 | const std::string m_dataRegex; |
| 46 | const std::string m_signerRegex; |
| 47 | const std::string m_op; |
| 48 | const std::string m_dataExpand; |
| 49 | const std::string m_signerExpand; |
| 50 | |
| 51 | Regex m_dataNameRegex; |
| 52 | Regex m_signerNameRegex; |
| 53 | }; |
| 54 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 55 | } // namespace ndn |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 56 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 57 | #endif //NDN_SECURITY_SEC_RULE_RELATIVE_HPP |