Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / doxmresource.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_DOXM_H
22 #define IOTVT_SRM_DOXM_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * Initialize DOXM resource by loading data from persistent storage.
30  *
31  * @retval  OC_STACK_OK for Success, otherwise some error value
32  */
33 OCStackResult InitDoxmResource();
34
35 /**
36  * Perform cleanup for DOXM resources.
37  *
38  * @retval  OC_STACK_OK for Success, otherwise some error value
39  */
40 OCStackResult DeInitDoxmResource();
41
42 /**
43  * This method is used by SRM to retrieve DOXM resource data..
44  *
45  * @retval  reference to @ref OicSecDoxm_t, binary format of Doxm resource data
46  */
47 const OicSecDoxm_t* GetDoxmResourceData();
48
49 /**
50  * This method converts JSON DOXM into binary DOXM.
51  * The JSON DOXM can be from persistent database or
52  * or received as PUT/POST request.
53  *
54  * @param[in] jsonStr  doxm data in json string.
55  * @return pointer to OicSecDoxm_t.
56  *
57  * @note Caller needs to invoke OCFree after done
58  *       using the return pointer
59  */
60 OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr);
61
62 /**
63  * This method converts DOXM data into JSON format.
64  * Caller needs to invoke 'free' when finished done using
65  * return string
66  *
67  * @param[in] doxm  Pointer to OicSecDoxm_t.
68  * @return pointer to json string.
69  *
70  * @note Caller needs to invoke OCFree after done
71  *       using the return pointer
72  */
73 char * BinToDoxmJSON(const OicSecDoxm_t * doxm);
74
75 /**
76  * This method returns the SRM device ID for this device.
77  *
78  * @retval  OC_STACK_OK for Success, otherwise some error value
79  */
80 OCStackResult GetDoxmDeviceID(OicUuid_t *deviceID);
81
82 /**
83  * @brief Gets the OicUuid_t value for the owner of this device.
84  *
85  * @return OC_STACK_OK if devOwner is a valid UUID, otherwise OC_STACK_ERROR.
86  */
87 OCStackResult GetDoxmDevOwnerId(OicUuid_t *devOwner);
88
89 /** This function deallocates the memory for OicSecDoxm_t .
90  *
91  * @param[in] doxm  Pointer to OicSecDoxm_t.
92  */
93 void DeleteDoxmBinData(OicSecDoxm_t* doxm);
94
95
96 #ifdef __cplusplus
97 }
98 #endif
99
100 #endif //IOTVT_SRM_DOXMR_H
101
102