blob: ecb968622bc21a299a38daf0eb2201dca998d4de [file] [log] [blame]
Yingdi Yu3715f8d2014-01-30 00:32:20 -08001/* -*- 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 Yufc40d872014-02-18 12:56:04 -08008#ifndef NDN_SECURITY_SEC_RULE_HPP
9#define NDN_SECURITY_SEC_RULE_HPP
Yingdi Yu3715f8d2014-01-30 00:32:20 -080010
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080011#include "../common.hpp"
Yingdi Yu3715f8d2014-01-30 00:32:20 -080012#include "../data.hpp"
13
Yingdi Yufc40d872014-02-18 12:56:04 -080014namespace ndn {
Yingdi Yu3715f8d2014-01-30 00:32:20 -080015
16class SecRule
17{
18public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070019 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 Yu3715f8d2014-01-30 00:32:20 -080029 SecRule(bool isPositive)
30 : m_isPositive(isPositive)
31 {}
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
33 virtual
34 ~SecRule()
Yingdi Yu3715f8d2014-01-30 00:32:20 -080035 {}
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036
37 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080038 matchDataName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039
40 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080041 matchSignerName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070042
Yingdi Yu3715f8d2014-01-30 00:32:20 -080043 virtual bool
44 satisfy(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045
Yingdi Yu3715f8d2014-01-30 00:32:20 -080046 virtual bool
47 satisfy(const Name& dataName, const Name& signerName) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048
Yingdi Yu3715f8d2014-01-30 00:32:20 -080049 inline bool
50 isPositive();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051
Yingdi Yu3715f8d2014-01-30 00:32:20 -080052protected:
53 bool m_isPositive;
54};
55
56bool
57SecRule::isPositive()
58{
59 return m_isPositive;
60}
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061
Yingdi Yufc40d872014-02-18 12:56:04 -080062} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080063
Yingdi Yufc40d872014-02-18 12:56:04 -080064#endif //NDN_SECURITY_SEC_RULE_HPP