blob: 4db324fe0acec47bb5c29151e8a73a9a3c02af83 [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)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070030 : m_isPositive(isPositive)
31 {
32 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070033
34 virtual
35 ~SecRule()
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070036 {
37 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070038
39 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080040 matchDataName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041
42 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080043 matchSignerName(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044
Yingdi Yu3715f8d2014-01-30 00:32:20 -080045 virtual bool
46 satisfy(const Data& data) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047
Yingdi Yu3715f8d2014-01-30 00:32:20 -080048 virtual bool
49 satisfy(const Name& dataName, const Name& signerName) = 0;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070050
Yingdi Yu3715f8d2014-01-30 00:32:20 -080051 inline bool
52 isPositive();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053
Yingdi Yu3715f8d2014-01-30 00:32:20 -080054protected:
55 bool m_isPositive;
56};
57
58bool
59SecRule::isPositive()
60{
61 return m_isPositive;
62}
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070063
Yingdi Yufc40d872014-02-18 12:56:04 -080064} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080065
Yingdi Yufc40d872014-02-18 12:56:04 -080066#endif //NDN_SECURITY_SEC_RULE_HPP