1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef IOTVT_SRM_ACLR_H
22 #define IOTVT_SRM_ACLR_H
29 * Initialize ACL resource by loading data from persistent storage.
31 * @return ::OC_STACK_OK for Success, otherwise some error value.
33 OCStackResult InitACLResource();
36 * Perform cleanup for ACL resources.
39 OCStackResult DeInitACLResource();
42 * This method is used by PolicyEngine to retrieve ACL for a Subject.
44 * @param subjectId ID of the subject for which ACL is required.
45 * @param savePtr is used internally by @ref GetACLResourceData to maintain index between
46 * successive calls for same subjectId.
48 * @note On the first call to @ref GetACLResourceData, savePtr should point to NULL.
50 * @return reference to @ref OicSecAce_t if ACE is found, else NULL.
52 const OicSecAce_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAce_t **savePtr);
55 * This function converts ACL data into CBOR format.
57 * @param acl instance of @ref OicSecAcl_t structure.
58 * @param outPayload is the pointer to allocated memory for cbor payload.
59 * @param size of the cbor payload.
61 * @return ::OC_STACK_OK for Success, otherwise some error value.
63 OCStackResult AclToCBORPayload(const OicSecAcl_t * acl, uint8_t **outPayload, size_t *size);
66 * This method removes ACE for the subject and resource from the ACL
68 * @param subject of the ACE
69 * @param resource of the ACE
72 * ::OC_STACK_RESOURCE_DELETED on success
73 * ::OC_STACK_NO_RESOURCE on failure to find the appropriate ACE
74 * ::OC_STACK_INVALID_PARAM on invalid parameter
76 OCStackResult RemoveACE(const OicUuid_t * subject, const char * resource);
79 * This function deletes ACL data.
81 * @param acl instance of @ref OicSecAcl_t structure to be deleted.
83 void DeleteACLList(OicSecAcl_t* acl);
86 * This function frees OicSecRsrc_t object's fields and object itself.
88 * @param rsrc instance of @ref OicSecRsrc_t structure to be deleted.
90 void FreeRsrc(OicSecRsrc_t *rsrc);
93 * Internal function to duplicate the ACE instance.
95 * @param ace instance of @ref OicSecAce_t structure to be duplicated.
96 * @return reference to @ref OicSecAce_t if ACE was successfully duplicated.
98 OicSecAce_t* DuplicateACE(const OicSecAce_t* ace);
101 * This function installs a new ACL.
103 * @param payload cbor value representing a new ACL.
104 * @param size of the cbor payload.
106 * @return ::OC_STACK_OK for Success, otherwise some error value
108 OCStackResult InstallNewACL(const uint8_t* payload, const size_t size);
111 * This function installs a new ACL.
113 * @param acl new acl to install.
115 * @return ::OC_STACK_OK for Success, otherwise some error value
117 OCStackResult InstallNewACL2(const OicSecAcl_t* acl);
119 * This function updates default ACE which is required for ownership transfer.
120 * This function should be invoked after OTM is complete to prevent anonymous user access.
122 * @retval OC_STACK_OK for Success, otherwise some error value
124 OCStackResult UpdateDefaultSecProvACE();
127 * Internal function to update resource owner
129 * @param newROwner new owner
131 * @retval ::OC_STACK_OK for Success, otherwise some error value
133 OCStackResult SetAclRownerId(const OicUuid_t* newROwner);
137 * Gets the OicUuid_t value for the rownerid of the acl resource.
139 * @param rowneruuid a pointer to be assigned to the rowneruuid property
140 * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
142 OCStackResult GetAclRownerId(OicUuid_t *rowneruuid);
145 * This function converts CBOR data into ACL.
147 * @param cborPayload is the pointer to cbor payload to parse.
148 * @param size of the cbor payload.
150 * @return ::acl instance of @ref OicSecAcl_t structure or NULL if error occurs
152 OicSecAcl_t* CBORPayloadToAcl2(const uint8_t *cborPayload, const size_t size);
155 * This function prints ACL to stdin
156 * For debug purposes only
158 * @param acl acl to print
160 void printACL(const OicSecAcl_t* acl);
166 #endif //IOTVT_SRM_ACLR_H