libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
Acls.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef LIBHOMEGEAR_BASE_ACLS_H
32 #define LIBHOMEGEAR_BASE_ACLS_H
33 
34 #include "Acl.h"
35 #include "../Output/Output.h"
36 
37 #include <mutex>
38 
39 namespace BaseLib {
40 
41 class SharedObjects;
42 
43 namespace Systems {
44 class Peer;
45 }
46 
47 namespace Security {
48 
49 class Acls {
50  private:
51  BaseLib::SharedObjects *_bl = nullptr;
52  int32_t _clientId = -1;
53  BaseLib::Output _out;
54  std::mutex _aclsMutex;
55  std::vector<PAcl> _acls;
56  public:
57  Acls(BaseLib::SharedObjects *bl, int32_t clientId);
58  ~Acls();
59 
60  bool categoriesReadSet();
61  bool categoriesWriteSet();
62  bool rolesReadSet();
63  bool rolesWriteSet();
64  bool devicesReadSet();
65  bool devicesWriteSet();
66  bool roomsReadSet();
67  bool roomsWriteSet();
68  bool buildingPartsReadSet();
69  bool buildingPartsWriteSet();
70  bool buildingPartsRoomsCategoriesRolesDevicesReadSet();
71  bool buildingPartsRoomsCategoriesRolesDevicesWriteSet();
72  bool variablesReadSet();
73  bool variablesWriteSet();
74  bool variablesBuildingPartsRoomsCategoriesRolesDevicesReadSet();
75  bool variablesBuildingPartsRoomsCategoriesRolesDevicesWriteSet();
76  bool variablesBuildingPartsRoomsCategoriesRolesReadSet();
77  bool variablesBuildingPartsRoomsCategoriesRolesWriteSet();
78 
79  void clear();
80  bool fromUser(std::string &userName);
81  bool fromGroups(std::vector<uint64_t> &groupIds);
82 
83  PVariable toVariable();
84  void fromVariable(PVariable serializedData);
85 
92  bool checkServiceAccess(std::string serviceName);
93 
100  bool checkCategoriesReadAccess(std::set<uint64_t> &categories);
101 
108  bool checkCategoriesWriteAccess(std::set<uint64_t> &categories);
109 
116  bool checkCategoryReadAccess(uint64_t categoryId);
117 
124  bool checkCategoryWriteAccess(uint64_t categoryId);
125 
132  bool checkRolesReadAccess(std::set<uint64_t> &roles);
133 
140  bool checkRolesWriteAccess(std::set<uint64_t> &roles);
141 
148  bool checkRoleReadAccess(uint64_t roleId);
149 
156  bool checkRoleWriteAccess(uint64_t roleId);
157 
164  bool checkDeviceReadAccess(std::shared_ptr<Systems::Peer> peer);
165 
172  bool checkDeviceWriteAccess(std::shared_ptr<Systems::Peer> peer);
173 
180  bool checkEventServerMethodAccess(std::string methodName);
181 
188  bool checkMethodAccess(std::string methodName);
189 
197  bool checkMethodAndCategoryReadAccess(std::string methodName, uint64_t categoryId);
198 
206  bool checkMethodAndCategoryWriteAccess(std::string methodName, uint64_t categoryId);
207 
215  bool checkMethodAndRoleReadAccess(std::string methodName, uint64_t roleId);
216 
224  bool checkMethodAndRoleWriteAccess(std::string methodName, uint64_t roleId);
225 
233  bool checkMethodAndRoomReadAccess(std::string methodName, uint64_t roomId);
234 
242  bool checkMethodAndRoomWriteAccess(std::string methodName, uint64_t roomId);
243 
251  bool checkMethodAndBuildingPartReadAccess(std::string methodName, uint64_t buildingPartId);
252 
260  bool checkMethodAndBuildingPartWriteAccess(std::string methodName, uint64_t buildingPartId);
261 
269  bool checkMethodAndDeviceWriteAccess(std::string methodName, uint64_t peerId);
270 
278  bool checkNodeBlueVariableReadAccess(const std::string &nodeId, int32_t input);
279 
287  bool checkNodeBlueVariableWriteAccess(const std::string &nodeId, int32_t input);
288 
295  bool checkRoomReadAccess(uint64_t roomId);
296 
303  bool checkRoomWriteAccess(uint64_t roomId);
304 
311  bool checkBuildingPartReadAccess(uint64_t buildingPartId);
312 
319  bool checkBuildingPartWriteAccess(uint64_t buildingPartId);
320 
327  bool checkSystemVariableReadAccess(Database::PSystemVariable systemVariable);
328 
335  bool checkSystemVariableWriteAccess(Database::PSystemVariable systemVariable);
336 
345  bool checkVariableReadAccess(std::shared_ptr<Systems::Peer> peer, int32_t channel, const std::string &variableName);
346 
355  bool checkVariableWriteAccess(std::shared_ptr<Systems::Peer> peer, int32_t channel, const std::string &variableName);
356 };
357 typedef std::shared_ptr<Acls> PAcls;
358 
359 }
360 }
361 
362 #endif
This is the base library main class.
Definition: BaseLib.h:95
std::shared_ptr< SystemVariable > PSystemVariable
Definition: IDatabaseController.h:51
Definition: BaseLib.cpp:34
Class to print output of different kinds to the standard and error output.
Definition: Output.h:54
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
int32_t channel
Definition: UiElements.h:215
std::shared_ptr< Acls > PAcls
Definition: Acls.h:357
uint64_t peerId
Definition: UiElements.h:214
Definition: Acls.h:49