2 * Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @file rule_manager.h
20 * @brief Audit rule manager (class for parsing and applying audit rules)
21 * @date Created Apr 04, 2018
22 * @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>
25 #ifndef RULE_MANAGER_H
26 #define RULE_MANAGER_H
31 #include <audit-trail/audit-trail.h>
32 #include <audit-trail/rule.h>
34 #include <jsoncpp/json/value.h>
35 #include <jsoncpp/json/reader.h>
36 #include <jsoncpp/json/writer.h>
45 * @brief Array of audit rules handles
47 using AuditRules = std::vector<audit_rule_h>;
51 * @brief Class for parsing and applying audit rules
53 class RuleManager final
56 * @brief Audit rules iteration callback
57 * @details Called from audit_trail_foreach_rule for each audit rule
58 * @param handle [in] audit rule handle
59 * @param user_data [in] pointer to user defined data
61 friend void ruleCallback(audit_rule_h handle, void* user_data);
65 * @brief Singleton instance recieving method
66 * @return Link to AuditRuleManager instance
68 static RuleManager& GetInstance();
71 * @brief Get all existing rules
72 * @return All existing rules as Json
74 Json::Value getRulesAsJson();
77 * @brief Update all existing rules
78 * @param rules [in] rules to apply
81 bool updateRules(const Json::Value& rules);
89 * @brief Copy constructor
91 RuleManager(const RuleManager&) = delete;
92 RuleManager(const RuleManager&&) = delete;
100 * @brief Copy operator
102 RuleManager& operator=(const RuleManager&) = delete;
103 RuleManager& operator=(const RuleManager&&) = delete;
106 * @brief Get all existing rules
107 * @return Array of audit rules handles
109 AuditRules getRules();
111 audit_trail_h m_audit_trail;
116 #endif // RULE_MANAGER_H