Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / amaclresource.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_AMACLR_H
22 #define IOTVT_SRM_AMACLR_H
23
24 /**
25  * @file
26  *
27  * This file contains the APIs for the /oic/sec/amacl resource is an ACL structure that
28  * specifies which resources will use an Access Manager Service (AMS) to resolve access decisions.
29  * It dynamically obtains an ACL using an AMS.
30  */
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /**
37  * Initialize Amacl resource by loading data from persistent storage.
38  *
39  * @return ::OC_STACK_OK for Success, otherwise some error value.
40  */
41 OCStackResult InitAmaclResource();
42
43 /**
44  * Perform cleanup for Amacl resources.
45  */
46 void DeInitAmaclResource();
47
48 /**
49  * This method is used by PolicyEngine to retrieve amsId for the resource.
50  * If the Amacl is found for the given resource then populate the parameter
51  * amsId with Amacl resource amss id.
52  *
53  * @param resource for which AMS service is required.
54  * @param amsId of the ams service for the given resource.
55  *
56  * @return ::OC_STACK_OK, if Amacl is found for the resource, else ::OC_STACK_ERROR,
57  *  if no Amacl found for the resource.
58  */
59 OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
60
61 /**
62  * This function converts Amacl data into CBOR format.
63  * Caller needs to invoke 'free' when done using returned string.
64  *
65  * @param amacl instance of @ref OicSecAmacl_t structure.
66  * @param cborPayload is the converted cbor value of @ref OicSecAmacl_t structure.
67  * @param cborSize is the size of the cbor payload. This value is the size of the
68  * cborPayload. It should not be NON-NULL value.
69  *
70  * @return ::OC_STACK_OK for Success. ::OC_STACK_INVALID in case of invalid parameters.
71  * ::OC_STACK_ERROR in case of error in converting to cbor.
72  */
73 OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amacl, uint8_t **cborPayload,
74                                  size_t *cborSize);
75
76 /**
77  * Internal function to update resource owner
78  *
79  * @param newROwner new owner
80  *
81  * @retval ::OC_STACK_OK for Success, otherwise some error value
82  */
83 OCStackResult SetAmaclRownerId(const OicUuid_t* newROwner);
84
85 /**
86  * Gets the OicUuid_t value for the rownerid of the amacl resource.
87  *
88  * @param rowneruuid a pointer to be assigned to the rowneruuid property
89  * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
90  */
91 OCStackResult GetAmaclRownerId(OicUuid_t *rowneruuid);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif //IOTVT_SRM_AMACLR_H