Friendly LWM2M client
wpp::Lwm2mAccessControl Class Reference

#include <Lwm2mAccessControl.h>

+ Inheritance diagram for wpp::Lwm2mAccessControl:
+ Collaboration diagram for wpp::Lwm2mAccessControl:

Public Types

enum  ID : ID_T { OBJECT_ID_0 = 0 , OBJECT_INSTANCE_ID_1 = 1 , ACL_2 = 2 , ACCESS_CONTROL_OWNER_3 = 3 }
 
enum  ACL : uint8_t {
  NO_ACCESS = LWM2M_AC_NO_ACCESS , R_O_W_ATTR = LWM2M_AC_READ_OP , WRITE = LWM2M_AC_WRITE_OP , EXECUTE = LWM2M_AC_EXECUTE_OP ,
  DELETE = LWM2M_AC_DELETE_OP , CREATE = LWM2M_AC_CREATE_OP , ALL_OBJ_RIGHTS = CREATE , ALL_INST_RIGHTS = R_O_W_ATTR | WRITE | EXECUTE | DELETE
}
 

Public Member Functions

 Lwm2mAccessControl (lwm2m_context_t &context, const OBJ_LINK_T &id)
 
 ~Lwm2mAccessControl ()
 
- Public Member Functions inherited from wpp::Instance
 Instance (lwm2m_context_t &context, const OBJ_LINK_T &id)
 
virtual ~Instance ()
 
 Instance (const Instance &)=delete
 
 Instance (Instance &&)=delete
 
Instanceoperator= (const Instance &)=delete
 
Instanceoperator= (Instance &&)=delete
 
OBJ_LINK_T getLink () const
 
OBJ_ID getObjectID () const
 
ID_T getInstanceID () const
 
lwm2m_context_t & getContext ()
 Return context that can be used by derived class. More...
 
WppClientgetClient ()
 Helpfull methods to get client instances. More...
 
WppRegistrygetRegistry ()
 Helpfull methods to get registry instances. More...
 
uint8_t readAsServer (lwm2m_server_t *server, int *numDataP, lwm2m_data_t **dataArray)
 This methods is called by the core when the server wants to read, write, discover, execute the value of the resource. User should not call this methods directly. More...
 
uint8_t writeAsServer (lwm2m_server_t *server, int numData, lwm2m_data_t *dataArray, lwm2m_write_type_t writeType)
 
uint8_t executeAsServer (lwm2m_server_t *server, ID_T resId, uint8_t *buffer, int length)
 
uint8_t discoverAsServer (lwm2m_server_t *server, int *numDataP, lwm2m_data_t **dataArray)
 
- Public Member Functions inherited from wpp::InstSubject
void opSubscribe (InstOpObserver *observer)
 Subscribes an observer to receive notifications about instance resource operations. More...
 
void opUnsubscribe (InstOpObserver *observer)
 Unsubscribes an observer from receiving notifications about instance resource operations. More...
 
void eventSubscribe (InstEventObserver *observer)
 Subscribes an observer to receive notifications about custom instance events. More...
 
void eventUnsubscribe (InstEventObserver *observer)
 Unsubscribes an observer from receiving notifications about custom instance events. More...
 
- Public Member Functions inherited from wpp::ResourceContainer
 ResourceContainer ()=default
 
virtual ~ResourceContainer ()=default
 
bool isSingle (ID_T resId)
 Check if the resource is SINGLE. More...
 
bool isMultiple (ID_T resId)
 Check if the resource is MULTIPLE. More...
 
bool isExist (ID_T resId)
 Check if the instance ID is exist. More...
 
bool isExist (ID_T resId, ID_T resInstId)
 Check if the instance ID is exist. More...
 
size_t instCount (ID_T resId)
 Get the number of resource instances. More...
 
std::vector< ID_TinstIds (ID_T resId)
 Returns vector with available ids of resource instances. More...
 
ID_T newInstId (ID_T resId)
 Find first available instance ID that is not used. More...
 
template<typename T >
bool set (ID_T resId, const T &value)
 Set data value by copy for the resource. More...
 
template<typename T >
bool set (ID_T resId, ID_T resInstId, const T &value)
 Set data value by copy for the resource instance. More...
 
template<typename T >
bool set (ID_T resId, T &&value)
 Set data value by move for the resource. More...
 
template<typename T >
bool set (ID_T resId, ID_T resInstId, T &&value)
 Set data value by move for the resource instance. More...
 
template<typename T >
const T & get (ID_T resId, ID_T resInstId=SINGLE_INSTANCE_ID)
 
template<typename T >
bool add (ID_T resId, const T &value)
 Add new instance with data value by copy for the MULTIPLE resource. More...
 
template<typename T >
bool add (ID_T resId, T &&value)
 Add new instance with data value by move for the MULTIPLE resource. More...
 
bool removeRes (ID_T resId, ID_T resInstId)
 Remove resource instance if resource is MULTIPLE and instance exists, if the resource is SINGLE remove is not possible. More...
 
bool clearRes (ID_T resId)
 Remove all instances. More...
 

Static Public Member Functions

static Objectobject (WppClient &ctx)
 Gets the Object reference. More...
 
static Lwm2mAccessControlinstance (WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
 Gets an instance of the object. More...
 
static Lwm2mAccessControlcreateInst (WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
 Creates an instance of the object. More...
 
static bool removeInst (WppClient &ctx, ID_T instId)
 Removes an instance of the object. More...
 
static Lwm2mAccessControlcreate (Object &targetObj, uint8_t defaultAcl=NO_ACCESS)
 Create Lwm2mAccessControl object instance for target object. More...
 
static void remove (Object &targetObj)
 Delete Lwm2mAccessControl object instance for target object. More...
 
static bool addAcl (Object &targetObj, ID_T serverShortId, uint8_t acl=ALL_OBJ_RIGHTS)
 Add ACL for target object. More...
 
static void removeAcl (Object &targetObj, ID_T serverShortId)
 Remove ACL for target object. More...
 
static Lwm2mAccessControlcreate (Instance &targetInst, ID_T owner=AC_CLIENT_OWNER, uint8_t defaultAcl=NO_ACCESS)
 Get Lwm2mAccessControl object instance for target object instance. More...
 
static void remove (Instance &targetInst)
 Delete Lwm2mAccessControl object instance for target object instance. More...
 
static bool addAcl (Instance &targetInst, ID_T serverShortId, uint8_t acl=ALL_INST_RIGHTS)
 Add ACL for target object instance. More...
 
static void removeAcl (Instance &targetInst, ID_T serverShortId)
 Remove ACL for target object instance. More...
 

Protected Member Functions

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 (WRITE, EXECUTE). Called by Instance after resource operation performed by SERVER if the operation is
WRITE, if the operation is EXECUTE then called before this operation. When the EXECUTE operation, the handler that was set before the serverOperationNotifier() call is used. More...
 
void userOperationNotifier (ItemOp::TYPE type, const ResLink &resLink) override
 This method must be implemented by the derived class, and handle information about resource operation (WRITE, DELETE). Called by Instance after resource operation performed by the USER. More...
 
- Protected Member Functions inherited from wpp::Instance
void notifyResChanged (ID_T resId, ID_T resInstId=ID_T_MAX_VAL)
 Notify server about resource value change. More...
 
std::vector< Resource * > getInstantiatedResList ()
 This method return list with resources that has been instantiated. If resources does not exist then return empty list. More...
 
std::vector< Resource * > getInstantiatedResList (const ItemOp &filter)
 
std::vector< Resource * > getResList ()
 This method return list with all resources that has been defined. If resources does not exist then return empty list. More...
 
void resourceOperationNotifier (ItemOp::TYPE type, ID_T resId, ID_T resInstId) override
 Handle information about resource operation (WRITE, DELETE). Called by ResourceContainer after resource operation performed. More...
 
- Protected Member Functions inherited from wpp::InstSubject
void operationNotify (Instance &inst, const ResLink &resLink, ItemOp::TYPE type)
 Notifies the observers about an operation on an instance resource. More...
 
void eventNotify (Instance &inst, EVENT_ID_T eventId)
 Notifies the observers about a custom instance event. More...
 
- Protected Member Functions inherited from wpp::ResourceContainer
void setupResources (const std::vector< Resource > &resources)
 This methods setup resources list. More...
 
void setupResources (std::vector< Resource > &&resources)
 
Resourceresource (ID_T resId)
 This method return resource ptr if it exists. If resources does not exist then return NULL. More...
 
std::vector< Resource > & resources ()
 This method return list with all resources that has been defined. More...
 

Detailed Description

Definition at line 29 of file Lwm2mAccessControl.h.

Member Enumeration Documentation

◆ ACL

Enumerator
NO_ACCESS 
R_O_W_ATTR 
WRITE 
EXECUTE 
DELETE 
CREATE 
ALL_OBJ_RIGHTS 
ALL_INST_RIGHTS 

Definition at line 42 of file Lwm2mAccessControl.h.

◆ ID

Enumerator
OBJECT_ID_0 
OBJECT_INSTANCE_ID_1 
ACL_2 
ACCESS_CONTROL_OWNER_3 

Definition at line 31 of file Lwm2mAccessControl.h.

Constructor & Destructor Documentation

◆ Lwm2mAccessControl()

wpp::Lwm2mAccessControl::Lwm2mAccessControl ( lwm2m_context_t &  context,
const OBJ_LINK_T id 
)

Definition at line 32 of file Lwm2mAccessControl.cpp.

◆ ~Lwm2mAccessControl()

wpp::Lwm2mAccessControl::~Lwm2mAccessControl ( )

Definition at line 45 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ addAcl() [1/2]

static bool wpp::Lwm2mAccessControl::addAcl ( Instance targetInst,
ID_T  serverShortId,
uint8_t  acl = ALL_INST_RIGHTS 
)
static

Add ACL for target object instance.

Parameters
targetInstTarget object instance
serverShortIdServer short ID
aclACL for target object instance, can be NO_ACCESS or ALL_INST_RIGHTS

◆ addAcl() [2/2]

static bool wpp::Lwm2mAccessControl::addAcl ( Object targetObj,
ID_T  serverShortId,
uint8_t  acl = ALL_OBJ_RIGHTS 
)
static

Add ACL for target object.

Parameters
targetObjTarget object
serverShortIdServer short ID
aclACL for target object, can be NO_ACCESS or ALL_OBJ_RIGHTS

◆ create() [1/2]

Lwm2mAccessControl * wpp::Lwm2mAccessControl::create ( Instance targetInst,
ID_T  owner = AC_CLIENT_OWNER,
uint8_t  defaultAcl = NO_ACCESS 
)
static

Get Lwm2mAccessControl object instance for target object instance.

Parameters
ownerTarget object instance owner, should be set to AC_CLIENT_OWNER or server short id
defaultAclDefault ACL for target object, can be NO_ACCESS or ALL_INST_RIGHTS

Definition at line 181 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ create() [2/2]

Lwm2mAccessControl * wpp::Lwm2mAccessControl::create ( Object targetObj,
uint8_t  defaultAcl = NO_ACCESS 
)
static

Create Lwm2mAccessControl object instance for target object.

Parameters
targetObjTarget object
defaultAclDefault ACL for target object, can be NO_ACCESS or ALL_OBJ_RIGHTS

Definition at line 132 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ createInst()

Lwm2mAccessControl * wpp::Lwm2mAccessControl::createInst ( WppClient ctx,
ID_T  instId = ID_T_MAX_VAL 
)
static

Creates an instance of the object.

Parameters
ctx- WppClient context
instanceIDThe instance ID.
Returns
A pointer to the created Instance object or NULL.

Definition at line 61 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ instance()

Lwm2mAccessControl * wpp::Lwm2mAccessControl::instance ( WppClient ctx,
ID_T  instId = ID_T_MAX_VAL 
)
static

Gets an instance of the object.

Parameters
ctx- WppClient context.
instIdThe instance ID. If not provided, the first available instance is returned.
Returns
A pointer to the Instance object or NULL.

Definition at line 55 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ object()

Object & wpp::Lwm2mAccessControl::object ( WppClient ctx)
static

Gets the Object reference.

Parameters
ctx- WppClient context.
Returns
A reference to the Object.

Definition at line 51 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ remove() [1/2]

void wpp::Lwm2mAccessControl::remove ( Instance targetInst)
static

Delete Lwm2mAccessControl object instance for target object instance.

Parameters
targetInstTarget object instance

Definition at line 199 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ remove() [2/2]

void wpp::Lwm2mAccessControl::remove ( Object targetObj)
static

Delete Lwm2mAccessControl object instance for target object.

Parameters
targetObjTarget object

Definition at line 150 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ removeAcl() [1/2]

static void wpp::Lwm2mAccessControl::removeAcl ( Instance targetInst,
ID_T  serverShortId 
)
static

Remove ACL for target object instance.

Parameters
targetInstTarget object instance
serverShortIdServer short ID

◆ removeAcl() [2/2]

static void wpp::Lwm2mAccessControl::removeAcl ( Object targetObj,
ID_T  serverShortId 
)
static

Remove ACL for target object.

Parameters
targetObjTarget object
serverShortIdServer short ID

◆ removeInst()

bool wpp::Lwm2mAccessControl::removeInst ( WppClient ctx,
ID_T  instId 
)
static

Removes an instance of the object.

Parameters
ctx- WppClient context.
instIdThe instance ID.
Returns
True if the instance was successfully removed, false otherwise.

Definition at line 67 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ serverOperationNotifier()

void wpp::Lwm2mAccessControl::serverOperationNotifier ( Instance securityInst,
ItemOp::TYPE  type,
const ResLink resLink 
)
overrideprotectedvirtual

This method must be implemented by the derived class, and handle information about resource operation (WRITE, EXECUTE). Called by Instance after resource operation performed by SERVER if the operation is
WRITE, if the operation is EXECUTE then called before this operation. When the EXECUTE operation, the handler that was set before the serverOperationNotifier() call is used.

Parameters
securityInst- Contains security instance when the request received from the server or NULL if the request is initiated by the core.

Implements wpp::Instance.

Definition at line 71 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function:

◆ userOperationNotifier()

void wpp::Lwm2mAccessControl::userOperationNotifier ( ItemOp::TYPE  type,
const ResLink resLink 
)
overrideprotectedvirtual

This method must be implemented by the derived class, and handle information about resource operation (WRITE, DELETE). Called by Instance after resource operation performed by the USER.

Implements wpp::Instance.

Definition at line 82 of file Lwm2mAccessControl.cpp.

+ Here is the call graph for this function: