blob: 522e52e8feab55e2f92e077f9a07ad3c9dbb2cea [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
8
Yingdi Yufc40d872014-02-18 12:56:04 -08009#ifndef NDN_SECURITY_SEC_RULE_RELATIVE_HPP
10#define NDN_SECURITY_SEC_RULE_RELATIVE_HPP
Yingdi Yu3715f8d2014-01-30 00:32:20 -080011
12#include "sec-rule.hpp"
13#include "../util/regex.hpp"
14
Yingdi Yufc40d872014-02-18 12:56:04 -080015namespace ndn {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070016
Yingdi Yu3715f8d2014-01-30 00:32:20 -080017class SecRuleRelative : public SecRule
18{
19public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070020 class Error : public SecRule::Error
21 {
22 public:
23 explicit
24 Error(const std::string& what)
25 : SecRule::Error(what)
26 {
27 }
28 };
29
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070030 SecRuleRelative(const std::string& dataRegex, const std::string& signerRegex,
31 const std::string& op,
32 const std::string& dataExpand, const std::string& signerExpand,
33 bool isPositive);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070034
Yingdi Yu3715f8d2014-01-30 00:32:20 -080035 virtual
36 ~SecRuleRelative();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070037
38 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080039 matchDataName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040
41 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080042 matchSignerName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043
Yingdi Yu3715f8d2014-01-30 00:32:20 -080044 virtual bool
45 satisfy(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070046
Yingdi Yu3715f8d2014-01-30 00:32:20 -080047 virtual bool
48 satisfy(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049
Yingdi Yu3715f8d2014-01-30 00:32:20 -080050private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080052 compare(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053
Yingdi Yu3715f8d2014-01-30 00:32:20 -080054private:
55 const std::string m_dataRegex;
56 const std::string m_signerRegex;
57 const std::string m_op;
58 const std::string m_dataExpand;
59 const std::string m_signerExpand;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070060
Yingdi Yu3715f8d2014-01-30 00:32:20 -080061 Regex m_dataNameRegex;
62 Regex m_signerNameRegex;
63};
64
Yingdi Yufc40d872014-02-18 12:56:04 -080065} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080066
Yingdi Yufc40d872014-02-18 12:56:04 -080067#endif //NDN_SECURITY_SEC_RULE_RELATIVE_HPP