blob: 7ea4c51bdc100548ed4bdae189a72f1b8d07791f [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
30 SecRuleRelative(const std::string& dataRegex, const std::string& signerRegex, const std::string& op,
Yingdi Yu3715f8d2014-01-30 00:32:20 -080031 const std::string& dataExpand, const std::string& signerExpand, bool isPositive);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
Yingdi Yu3715f8d2014-01-30 00:32:20 -080033 virtual
34 ~SecRuleRelative();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070035
36 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080037 matchDataName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070038
39 virtual bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080040 matchSignerName(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041
Yingdi Yu3715f8d2014-01-30 00:32:20 -080042 virtual bool
43 satisfy(const Data& data);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044
Yingdi Yu3715f8d2014-01-30 00:32:20 -080045 virtual bool
46 satisfy(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047
Yingdi Yu3715f8d2014-01-30 00:32:20 -080048private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049 bool
Yingdi Yu3715f8d2014-01-30 00:32:20 -080050 compare(const Name& dataName, const Name& signerName);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051
Yingdi Yu3715f8d2014-01-30 00:32:20 -080052private:
53 const std::string m_dataRegex;
54 const std::string m_signerRegex;
55 const std::string m_op;
56 const std::string m_dataExpand;
57 const std::string m_signerExpand;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070058
Yingdi Yu3715f8d2014-01-30 00:32:20 -080059 Regex m_dataNameRegex;
60 Regex m_signerNameRegex;
61};
62
Yingdi Yufc40d872014-02-18 12:56:04 -080063} // namespace ndn
Yingdi Yu3715f8d2014-01-30 00:32:20 -080064
Yingdi Yufc40d872014-02-18 12:56:04 -080065#endif //NDN_SECURITY_SEC_RULE_RELATIVE_HPP