blob: 0f7076c0167f6f698668dc3918331c65a7f40d93 [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_RELATIVE_HPP
16#define NDN_SECURITY_SEC_RULE_RELATIVE_HPP
Yingdi Yu3715f8d2014-01-30 00:32:20 -080017
18#include "sec-rule.hpp"
19#include "../util/regex.hpp"
20
Yingdi Yufc40d872014-02-18 12:56:04 -080021namespace ndn {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070022
Yingdi Yu3715f8d2014-01-30 00:32:20 -080023class SecRuleRelative : public SecRule
24{
25public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070026 class Error : public SecRule::Error
27 {
28 public:
29 explicit
30 Error(const std::string& what)
31 : SecRule::Error(what)
32 {
33 }
34 };
35
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070036 SecRuleRelative(const std::string& dataRegex, const std::string& signerRegex,
37 const std::string& op,
38 const std::string& dataExpand, const std::string& signerExpand,
39 bool isPositive);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040
Yingdi Yu3715f8d2014-01-30 00:32:20 -080041 virtual
42 ~SecRuleRelative();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043
44 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080045 matchDataName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070046
47 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080048 matchSignerName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049
Yingdi Yu3715f8d2014-01-30 00:32:20 -080050 virtual bool
51 satisfy(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070052
Yingdi Yu3715f8d2014-01-30 00:32:20 -080053 virtual bool
54 satisfy(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070055
Yingdi Yu3715f8d2014-01-30 00:32:20 -080056private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070057 bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080058 compare(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070059
Yingdi Yu3715f8d2014-01-30 00:32:20 -080060private:
61 const std::string m_dataRegex;
62 const std::string m_signerRegex;
63 const std::string m_op;
64 const std::string m_dataExpand;
65 const std::string m_signerExpand;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070066
Yingdi Yu3715f8d2014-01-30 00:32:20 -080067 Regex m_dataNameRegex;
68 Regex m_signerNameRegex;
69};
70
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_RELATIVE_HPP