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) |
30 | : m_isPositive(isPositive) | ||||
31 | {} | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 32 | |
33 | virtual | ||||
34 | ~SecRule() | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 35 | {} |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 36 | |
37 | virtual bool | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 38 | matchDataName(const Data& data) = 0; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 39 | |
40 | virtual bool | ||||
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 41 | matchSignerName(const Data& data) = 0; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 42 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 43 | virtual bool |
44 | satisfy(const Data& data) = 0; | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 45 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 46 | virtual bool |
47 | satisfy(const Name& dataName, const Name& signerName) = 0; | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 48 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 49 | inline bool |
50 | isPositive(); | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 51 | |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 52 | protected: |
53 | bool m_isPositive; | ||||
54 | }; | ||||
55 | |||||
56 | bool | ||||
57 | SecRule::isPositive() | ||||
58 | { | ||||
59 | return m_isPositive; | ||||
60 | } | ||||
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 61 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 62 | } // namespace ndn |
Yingdi Yu | 3715f8d | 2014-01-30 00:32:20 -0800 | [diff] [blame] | 63 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 64 | #endif //NDN_SECURITY_SEC_RULE_HPP |