Friendly LWM2M client
Lwm2mAccessControl.h
Go to the documentation of this file.
1 /*
2  * Lwm2mAccessControl
3  * Generated on: 2023-11-03 15:05:47
4  * Created by: Sinai RnD
5  */
6 
7 #ifndef WPP_O_2_LWM2M_ACCESS_CONTROL_H
8 #define WPP_O_2_LWM2M_ACCESS_CONTROL_H
9 
11 #include "Lwm2mAccessControlInfo.h"
12 #include "Instance.h"
13 #include "InstSubject.h"
14 
15 /* --------------- Сode_h block 0 start --------------- */
16 #define AC_CLIENT_OWNER ID_T_MAX_VAL
17 #define AC_ACL_DEFAULT_ID LWM2M_AC_ACL_DEFAULT_ID
18 #define AC_OBJ_INST_NOT_SET ID_T_MAX_VAL
19 /* --------------- Сode_h block 0 end --------------- */
20 
21 namespace wpp {
22 
23 class WppClient;
24 class Object;
25 
26 /* --------------- Сode_h block 1 start --------------- */
27 /* --------------- Сode_h block 1 end --------------- */
28 
29 class Lwm2mAccessControl : public Instance {
30 public:
31  enum ID: ID_T {
34  #if RES_2_2
35  ACL_2 = 2,
36  #endif
38  };
39 
40  /* --------------- Code_h block 2 start --------------- */
41  #if RES_2_2
42  enum ACL: uint8_t {
43  NO_ACCESS = LWM2M_AC_NO_ACCESS,
44  R_O_W_ATTR = LWM2M_AC_READ_OP,
45  WRITE = LWM2M_AC_WRITE_OP,
46  EXECUTE = LWM2M_AC_EXECUTE_OP,
47  DELETE = LWM2M_AC_DELETE_OP,
48  CREATE = LWM2M_AC_CREATE_OP,
51  };
52  #endif
53  /* --------------- Code_h block 2 end --------------- */
54 
55 public:
56  Lwm2mAccessControl(lwm2m_context_t &context, const OBJ_LINK_T &id);
58 
59  /* --------------- Helpful methods --------------- */
65  static Object & object(WppClient &ctx);
66 
73  static Lwm2mAccessControl * instance(WppClient &ctx, ID_T instId = ID_T_MAX_VAL);
74 
81  static Lwm2mAccessControl * createInst(WppClient &ctx, ID_T instId = ID_T_MAX_VAL);
82 
89  static bool removeInst(WppClient &ctx, ID_T instId);
90 
91  /* --------------- Code_h block 3 start --------------- */
97  static Lwm2mAccessControl * create(Object &targetObj, uint8_t defaultAcl = NO_ACCESS);
98 
103  static void remove(Object &targetObj);
104 
111  static bool addAcl(Object &targetObj, ID_T serverShortId, uint8_t acl = ALL_OBJ_RIGHTS);
112 
118  static void removeAcl(Object &targetObj, ID_T serverShortId);
119 
125  static Lwm2mAccessControl * create(Instance &targetInst, ID_T owner = AC_CLIENT_OWNER, uint8_t defaultAcl = NO_ACCESS);
126 
131  static void remove(Instance &targetInst);
132 
139  static bool addAcl(Instance &targetInst, ID_T serverShortId, uint8_t acl = ALL_INST_RIGHTS);
140 
146  static void removeAcl(Instance &targetInst, ID_T serverShortId);
147  /* --------------- Code_h block 3 end --------------- */
148 
149 protected:
150  /* --------------- Instance implementation part --------------- */
151  /*
152  * Handles information about resource operation that made server
153  */
154  void serverOperationNotifier(Instance *securityInst, ItemOp::TYPE type, const ResLink &resLink) override;
155  /*
156  * Handles information about resource operation that made user
157  */
158  void userOperationNotifier(ItemOp::TYPE type, const ResLink &resLink) override;
159 
160  /* --------------- Code_h block 4 start --------------- */
161  /* --------------- Code_h block 4 end --------------- */
162 
163 private:
164  /* --------------- Class private methods --------------- */
165  /*
166  * Creates resources without initializing.
167  */
168  void resourcesCreate();
169  /*
170  * Initialize resources with default values
171  * SINGLE resource always must have at least one instance.
172  */
173  void resourcesInit();
174 
175  /* --------------- Code_h block 5 start --------------- */
176  static Lwm2mAccessControl * getAcInstForTarget(Object &acObj, ID_T objId, ID_T objInstId);
177  /* --------------- Code_h block 5 end --------------- */
178 
179 private:
180  /* --------------- Class private properties --------------- */
181  /* --------------- Code_h block 6 start --------------- */
182  /* --------------- Code_h block 6 end --------------- */
183 };
184 
185 } /* namespace wpp */
186 
187 #endif /* WPP_O_2_LWM2M_ACCESS_CONTROL_H */
#define AC_CLIENT_OWNER
#define ID_T_MAX_VAL
Definition: WppTypes.h:16
Instance is interface class that implements manipulation with derived class resources....
Definition: Instance.h:40
Lwm2mAccessControl(lwm2m_context_t &context, const OBJ_LINK_T &id)
static bool removeInst(WppClient &ctx, ID_T instId)
Removes an instance of the object.
static Lwm2mAccessControl * createInst(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Creates an instance of the object.
static void removeAcl(Instance &targetInst, ID_T serverShortId)
Remove ACL for target object instance.
void serverOperationNotifier(Instance *securityInst, ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
static Object & object(WppClient &ctx)
Gets the Object reference.
static bool addAcl(Instance &targetInst, ID_T serverShortId, uint8_t acl=ALL_INST_RIGHTS)
Add ACL for target object instance.
void userOperationNotifier(ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
static void remove(Object &targetObj)
Delete Lwm2mAccessControl object instance for target object.
static Lwm2mAccessControl * create(Object &targetObj, uint8_t defaultAcl=NO_ACCESS)
Create Lwm2mAccessControl object instance for target object.
static Lwm2mAccessControl * instance(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Gets an instance of the object.
static void removeAcl(Object &targetObj, ID_T serverShortId)
Remove ACL for target object.
static bool addAcl(Object &targetObj, ID_T serverShortId, uint8_t acl=ALL_OBJ_RIGHTS)
Add ACL for target object.
The Object class implements manipulation with Instance interface class and its inheritors.
Definition: Object.h:32
Represents a client interface for Wpp library.
Definition: WppClient.h:37
The WppConnection class represents a connection interface for the Wpp library.
Definition: WppClient.cpp:14
uint16_t ID_T
Definition: WppTypes.h:15
TYPE
Enum representing the different types of operations.
Definition: ItemOp.h:29