5f1ac9de3148bead40aa2af7226edbac1dba5347
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / aclresource.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef IOTVT_SRM_ACLR_H
22 #define IOTVT_SRM_ACLR_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * Initialize ACL resource by loading data from persistent storage.
30  *
31  * @return ::OC_STACK_OK for Success, otherwise some error value.
32  */
33 OCStackResult InitACLResource();
34
35 /**
36  * Perform cleanup for ACL resources.
37  *
38  */
39 OCStackResult DeInitACLResource();
40
41 /**
42  * This method is used by PolicyEngine to retrieve ACL for a Subject.
43  *
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.
47  *
48  * @note On the first call to @ref GetACLResourceData, savePtr should point to NULL.
49  *
50  * @return reference to @ref OicSecAcl_t if ACL is found, else NULL.
51  */
52 const OicSecAcl_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAcl_t **savePtr);
53
54 /**
55  * This function converts ACL data into CBOR format.
56  *
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.
60  *
61  * @return ::OC_STACK_OK for Success, otherwise some error value.
62  */
63 OCStackResult AclToCBORPayload(const OicSecAcl_t * acl, uint8_t **outPayload, size_t *size);
64
65 /**
66  * This function deletes ACL data.
67  *
68  * @param acl instance of @ref OicSecAcl_t structure to be deleted.
69  */
70 void DeleteACLList(OicSecAcl_t* acl);
71
72 /**
73  * This function installs a new ACL.
74  *
75  * @param payload cbor value representing a new ACL.
76  * @param size of the cbor payload.
77  *
78  * @return ::OC_STACK_OK for Success, otherwise some error value
79  */
80 OCStackResult InstallNewACL(const uint8_t* payload, const size_t size);
81
82 /**
83  * This function updates default ACL which is required for ownership transfer.
84  * This function should be invoked after OTM is complete to prevent anonymous user access.
85  *
86  * @retval OC_STACK_OK for Success, otherwise some error value
87  */
88 OCStackResult UpdateDefaultSecProvACL();
89
90 /**
91  * Internal function to update resource owner
92  *
93  * @param newROwner new owner
94  *
95  * @retval ::OC_STACK_OK for Success, otherwise some error value
96  */
97 OCStackResult SetAclRownerId(const OicUuid_t* newROwner);
98
99
100 /**
101  * Gets the OicUuid_t value for the rownerid of the acl resource.
102  *
103  * @param rowneruuid a pointer to be assigned to the rowneruuid property
104  * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
105  */
106 OCStackResult GetAclRownerId(OicUuid_t *rowneruuid);
107
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif //IOTVT_SRM_ACLR_H
113
114