eb2643b3a1fd6d3f67e3bff478bb449c1673f6e3
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / secureresourcemanager.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 SECURITYRESOURCEMANAGER_H_
22 #define SECURITYRESOURCEMANAGER_H_
23
24 #include "securevirtualresourcetypes.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * @brief   Register Persistent storage callback.
32  * @param   persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
33  * @return
34  *     OC_STACK_OK    - No errors; Success
35  *     OC_STACK_INVALID_PARAM - Invalid parameter
36  */
37 OCStackResult SRMRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
38
39 /**
40  * @brief   Get Persistent storage handler pointer.
41  * @return
42  *     The pointer to Persistent Storage callback handler
43  */
44 OCPersistentStorage* SRMGetPersistentStorageHandler();
45
46 /**
47  * @brief   Register request and response callbacks.
48  *          Requests and responses are delivered in these callbacks.
49  * @param   reqHandler   [IN] Request handler callback ( for GET,PUT ..etc)
50  * @param   respHandler  [IN] Response handler callback.
51  * @param   errHandler   [IN] Error handler callback.
52  * @return
53  *     OC_STACK_OK    - No errors; Success
54  *     OC_STACK_INVALID_PARAM - Invalid parameter
55  */
56 OCStackResult SRMRegisterHandler(CARequestCallback reqHandler,
57                                  CAResponseCallback respHandler,
58                                  CAErrorCallback errHandler);
59
60 /**
61  * @brief   Initialize all secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
62  * @return  OC_STACK_OK for Success, otherwise some error value
63  */
64 OCStackResult SRMInitSecureResources();
65
66 /**
67  * @brief   Perform cleanup for secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
68  * @return  none
69  */
70 void SRMDeInitSecureResources();
71
72 /**
73  * @brief   Initialize Policy Engine context.
74  * @return  OC_STACK_OK for Success, otherwise some error value.
75  */
76 OCStackResult SRMInitPolicyEngine();
77
78 /**
79  * @brief   Cleanup Policy Engine context.
80  * @return  none
81  */
82 void SRMDeInitPolicyEngine();
83
84 /**
85  * @brief   Provisioning API response callback.
86  * @param object[IN]       endpoint instance.
87  * @param responseInfo[IN] instance of CAResponseInfo_t structure.
88  * @return true if received response is for provisioning API false otherwise.
89  */
90 typedef bool (*SPResponseCallback) (const CAEndpoint_t *object,
91                                     const CAResponseInfo_t *responseInfo);
92
93 /**
94  * @brief function to register provisoning API's response callback.
95  * @param respHandler response handler callback.
96  */
97 void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler);
98
99 /**
100  * @brief   Check the security resource URI.
101  * @param   uri [IN] Pointers to security resource URI.
102  * @return  true if the URI is one of security resources, otherwise false.
103  */
104 bool SRMIsSecurityResourceURI(const char* uri);
105
106 /**
107  * @brief   Sends Response
108  * @param   resposeVal       SRMAccessResponse_t value
109  * @return  NONE
110  */
111 void SRMSendResponse(SRMAccessResponse_t responseVal);
112
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif /* SECURITYRESOURCEMANAGER_H_ */