Merge tizen_5.0 codes into tizen_4.0
[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  * Register Persistent storage callback.
32  *
33  * @param  persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
34  *
35  * @return ::OC_STACK_OK  is no errors and successful. ::OC_STACK_INVALID_PARAM for invalid parameter.
36  */
37 OCStackResult SRMRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
38
39 /**
40  * Get Persistent storage handler pointer.
41  *
42  * @return The pointer to Persistent Storage callback handler.
43  */
44 OCPersistentStorage* SRMGetPersistentStorageHandler();
45
46 /**
47  * Register request and response callbacks. Requests and responses are delivered in these callbacks.
48  *
49  * @param reqHandler Request handler callback ( for GET,PUT ..etc)
50  * @param respHandler Response handler callback.
51  * @param errHandler Error handler callback.
52  *
53  * @return ::OC_STACK_OK  is no errors and successful. ::OC_STACK_INVALID_PARAM for invalid parameter.
54  */
55 OCStackResult SRMRegisterHandler(CARequestCallback reqHandler,
56                                  CAResponseCallback respHandler,
57                                  CAErrorCallback errHandler);
58
59 /**
60  * Initialize all secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
61  * @return  ::OC_STACK_OK for Success, otherwise some error value.
62  */
63 OCStackResult SRMInitSecureResources();
64
65 /**
66  * Perform cleanup for secure resources ( /oic/sec/cred, /oic/sec/acl, /oic/sec/pstat etc).
67  */
68 void SRMDeInitSecureResources();
69
70 /**
71  * Initialize Policy Engine context.
72  *
73  * @return ::OC_STACK_OK for Success, otherwise some error value.
74  */
75 OCStackResult SRMInitPolicyEngine();
76
77 /**
78  * Cleanup Policy Engine context.
79  */
80 void SRMDeInitPolicyEngine();
81
82 /**
83  * Provisioning API response callback.
84  *
85  * @param object endpoint instance.
86  * @param responseInfo instance of CAResponseInfo_t structure.
87  *
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  * Function to register provisioning API's response callback.
95  *
96  * @param respHandler response handler callback.
97  */
98 void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler);
99
100 /**
101  * Check the security resource URI.
102  * @param uri Pointers to security resource URI.
103  * @return true if the URI is one of security resources, otherwise false.
104  */
105 bool SRMIsSecurityResourceURI(const char* uri);
106
107 /**
108  * Check whether persistent storage is valid
109  * @return OC_STACK_OK if valid, other errors otherwise;
110  */
111 OCStackResult CheckPersistentStorage(OCPersistentStorage* persistentStorageHandler);
112
113 /**
114  * Get the resource type from the URI.
115  * @param   uri [IN] Pointers to security resource URI.
116  * @return  SVR type (note that "NOT_A_SVR_RESOURCE" is returned if not a SVR)
117  */
118 OicSecSvrType_t GetSvrTypeFromUri(const char* uri);
119
120 /**
121  * Sends Response
122  * @param   resposeVal       SRMAccessResponse_t value
123  * @return  NONE
124  */
125 void SRMSendResponse(SRMAccessResponse_t responseVal);
126
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* SECURITYRESOURCEMANAGER_H_ */