blob: 59c8f09e1bdcf0a528a1b3acce74381ab88b28d0 [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 {
Yingdi Yu3715f8d2014-01-30 00:32:20 -080016
17class SecRuleRelative : public SecRule
18{
19public:
20 struct Error : public SecRule::Error { Error(const std::string &what) : SecRule::Error(what) {} };
21
22 SecRuleRelative(const std::string& dataRegex, const std::string& signerRegex, const std::string& op,
23 const std::string& dataExpand, const std::string& signerExpand, bool isPositive);
24
25 virtual
26 ~SecRuleRelative();
27
28 virtual bool
29 matchDataName(const Data& data);
30
31 virtual bool
32 matchSignerName(const Data& data);
33
34 virtual bool
35 satisfy(const Data& data);
36
37 virtual bool
38 satisfy(const Name& dataName, const Name& signerName);
39
40private:
41 bool
42 compare(const Name& dataName, const Name& signerName);
43
44private:
45 const std::string m_dataRegex;
46 const std::string m_signerRegex;
47 const std::string m_op;
48 const std::string m_dataExpand;
49 const std::string m_signerExpand;
50
51 Regex m_dataNameRegex;
52 Regex m_signerNameRegex;
53};
54
Yingdi Yufc40d872014-02-18 12:56:04 -080055} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080056
Yingdi Yufc40d872014-02-18 12:56:04 -080057#endif //NDN_SECURITY_SEC_RULE_RELATIVE_HPP