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 | |||||
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 8 | #ifndef NDN_SECURITY_SEC_RULE_HPP |
9 | #define NDN_SECURITY_SEC_RULE_HPP | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 11 | #include "../common.hpp" |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 12 | #include "../data.hpp" |
13 | |||||
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 14 | namespace ndn { |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 15 | |
16 | class SecRule | ||||
17 | { | ||||
18 | public: | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 19 | class Error : public std::runtime_error |
20 | { | ||||
21 | public: | ||||
22 | explicit | ||||
23 | Error(const std::string& what) | ||||
24 | : std::runtime_error(what) | ||||
25 | { | ||||
26 | } | ||||
27 | }; | ||||
28 | |||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 29 | SecRule(bool isPositive) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 30 | : m_isPositive(isPositive) |
31 | { | ||||
32 | } | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 33 | |
34 | virtual | ||||
35 | ~SecRule() | ||||
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 36 | { |
37 | } | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 38 | |
39 | virtual bool | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 40 | matchDataName(const Data& data) = 0; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 41 | |
42 | virtual bool | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 43 | matchSignerName(const Data& data) = 0; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 45 | virtual bool |
46 | satisfy(const Data& data) = 0; | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 47 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 48 | virtual bool |
49 | satisfy(const Name& dataName, const Name& signerName) = 0; | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 50 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 51 | inline bool |
52 | isPositive(); | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 53 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 54 | protected: |
55 | bool m_isPositive; | ||||
56 | }; | ||||
57 | |||||
58 | bool | ||||
59 | SecRule::isPositive() | ||||
60 | { | ||||
61 | return m_isPositive; | ||||
62 | } | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 63 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 64 | } // namespace ndn |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 65 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 66 | #endif //NDN_SECURITY_SEC_RULE_HPP |