blob: c756ea207c2dad89535d2ab12863bec41f281cd1 [file] [log] [blame]
Yingdi Yu3715f8d2014-01-30 00:32:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Yingdi Yu3715f8d2014-01-30 00:32:20 -080013 */
14
Yingdi Yufc40d872014-02-18 12:56:04 -080015#ifndef NDN_SECURITY_SEC_RULE_HPP
16#define NDN_SECURITY_SEC_RULE_HPP
Yingdi Yu3715f8d2014-01-30 00:32:20 -080017
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080018#include "../common.hpp"
Yingdi Yu3715f8d2014-01-30 00:32:20 -080019#include "../data.hpp"
20
Yingdi Yufc40d872014-02-18 12:56:04 -080021namespace ndn {
Yingdi Yu3715f8d2014-01-30 00:32:20 -080022
23class SecRule
24{
25public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070026 class Error : public std::runtime_error
27 {
28 public:
29 explicit
30 Error(const std::string& what)
31 : std::runtime_error(what)
32 {
33 }
34 };
35
Yingdi Yu3715f8d2014-01-30 00:32:20 -080036 SecRule(bool isPositive)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070037 : m_isPositive(isPositive)
38 {
39 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040
41 virtual
42 ~SecRule()
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070043 {
44 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045
46 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080047 matchDataName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048
49 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080050 matchSignerName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051
Yingdi Yu3715f8d2014-01-30 00:32:20 -080052 virtual bool
53 satisfy(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054
Yingdi Yu3715f8d2014-01-30 00:32:20 -080055 virtual bool
56 satisfy(const Name& dataName, const Name& signerName) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070057
Yingdi Yu3715f8d2014-01-30 00:32:20 -080058 inline bool
59 isPositive();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070060
Yingdi Yu3715f8d2014-01-30 00:32:20 -080061protected:
62 bool m_isPositive;
63};
64
65bool
66SecRule::isPositive()
67{
68 return m_isPositive;
69}
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070070
Yingdi Yufc40d872014-02-18 12:56:04 -080071} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080072
Yingdi Yufc40d872014-02-18 12:56:04 -080073#endif //NDN_SECURITY_SEC_RULE_HPP