Cloud ACL Modifications
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / cloud / occloudprovisioning.h
1 /* *****************************************************************
2  *
3  * Copyright 2016 Samsung Electronics 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 #ifndef OC_CLOUD_PROVISIONING_H
21 #define OC_CLOUD_PROVISIONING_H
22
23 #include "octypes.h"
24 #include "securevirtualresourcetypes.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif // __cplusplus
29
30 typedef void (*OCCloudResponseCB )(void* ctx, OCStackResult result, void* data);
31
32 typedef struct cloudAce cloudAce_t;
33
34 struct cloudAce {
35     char *aceId;
36     OicUuid_t subjectuuid;
37     uint16_t stype;
38     uint16_t permission;
39     OicSecRsrc_t *resources;
40     OicSecValidity_t *validities;
41     cloudAce_t *next;
42 };
43
44 typedef struct {
45     char **array;
46     size_t length;
47 }stringArray_t;
48
49 typedef struct {
50     stringArray_t gidlist;
51     stringArray_t midlist;
52 }stringArrayPair_t;
53
54 typedef struct {
55     stringArrayPair_t invite;
56     stringArrayPair_t invited;
57 }inviteResponse_t;
58
59 /**
60  * Certificate-Issue request function
61  *
62  * @param[in] ctx               user-defined context
63  * @param[in] endPoint          cloud host and port
64  * @param[in] callback          optional result callback, can be NULL if not required
65  * @return  OCStackResult application result
66  */
67 OCStackResult OCCloudCertificateIssueRequest(void* ctx,
68                                              const OCDevAddr *endPoint,
69                                              OCCloudResponseCB callback);
70
71 /**
72  * CRL GET request function
73  *
74  * @param[in] ctx               user-defined context
75  * @param[in] endPoint          cloud host and port
76  * @param[in] callback          optional result callback, can be NULL if not required
77  * @return  OCStackResult application result
78  */
79 OCStackResult OCCloudGetCRL(void* ctx,
80                             const OCDevAddr *endPoint,
81                             OCCloudResponseCB callback);
82
83 /**
84  * CRL POST request function (with Serial Numbers list to revoke)
85  *
86  * @param[in] ctx               user-defined context
87  * @param[in] thisUpdate        mandatory parameter thisUpdate
88  * @param[in] nextUpdate        mandatory parameter nextUpdate
89  * @param[in] crl               optional parameter crl
90  * @param[in] serialNumbers     optional parameter serial numbers
91  * @param[in] endPoint          cloud host and port
92  * @param[in] callback          optional result callback, can be NULL if not required
93  * @return  OCStackResult application result
94  */
95 OCStackResult OCCloudPostCRL(void* ctx,
96                              const char *thisUpdate,
97                              const char *nextUpdate,
98                              const OCByteString *crl,
99                              const stringArray_t *serialNumbers,
100                              const OCDevAddr *endPoint,
101                              OCCloudResponseCB callback);
102
103 /**
104  * ACL id retrieve by device id
105  *
106  * @param[in] ctx               user-defined context
107  * @param[in] deviceId          mandatory parameter device id
108  * @param[in] endPoint          cloud host and port
109  * @param[in] callback          optional result callback, can be NULL if not required
110  * @return  OCStackResult application result
111  */
112 OCStackResult OCCloudGetAclIdByDevice(void* ctx,
113                                       const char *deviceId,
114                                       const OCDevAddr *endPoint,
115                                       OCCloudResponseCB callback);
116
117 /**
118  * ACL id create
119  *
120  * @param[in] ctx               user-defined context
121  * @param[in] ownerId           mandatory parameter owner id
122  * @param[in] deviceId          mandatory parameter device id
123  * @param[in] endPoint          cloud host and port
124  * @param[in] callback          optional result callback, can be NULL if not required
125  * @return  OCStackResult application result
126  */
127 OCStackResult OCCloudAclIdCreate(void* ctx,
128                                  const char *ownerId,
129                                  const char *deviceId,
130                                  const OCDevAddr *endPoint,
131                                  OCCloudResponseCB callback);
132
133 /**
134  * ACL id delete
135  *
136  * @param[in] ctx               user-defined context
137  * @param[in] aclId             mandatory parameter acl id
138  * @param[in] endPoint          cloud host and port
139  * @param[in] callback          optional result callback, can be NULL if not required
140  * @return  OCStackResult application result
141  */
142 OCStackResult OCCloudAclIdDelete(void* ctx,
143                                  const char *aclId,
144                                  const OCDevAddr *endPoint,
145                                  OCCloudResponseCB callback);
146
147 /**
148  * ACL individual get info
149  *
150  * @param[in] ctx               user-defined context
151  * @param[in] aclId             mandatory parameter acl id
152  * @param[in] endPoint          cloud host and port
153  * @param[in] callback          optional result callback, can be NULL if not required
154  * @return  OCStackResult application result
155  */
156 OCStackResult OCCloudAclIndividualGetInfo(void* ctx,
157                                           const char *aclId,
158                                           const OCDevAddr *endPoint,
159                                           OCCloudResponseCB callback);
160
161 /**
162  * ACL individual update ACE
163  *
164  * @param[in] ctx               user-defined context
165  * @param[in] aclId             mandatory parameter acl id
166  * @param[in] aces              mandatory parameter aces
167  * @param[in] endPoint          cloud host and port
168  * @param[in] callback          optional result callback, can be NULL if not required
169  * @return  OCStackResult application result
170  */
171 OCStackResult OCCloudAclIndividualUpdateAce(void* ctx,
172                                             const char *aclId,
173                                             const cloudAce_t *aces,
174                                             const OCDevAddr *endPoint,
175                                             OCCloudResponseCB callback);
176
177 /**
178  * ACL individual update
179  *
180  * @param[in] ctx               user-defined context
181  * @param[in] aclId             mandatory parameter acl id
182  * @param[in] aceId             mandatory parameter target ace id
183  * @param[in] aces              mandatory parameter aces
184  * @param[in] endPoint          cloud host and port
185  * @param[in] callback          optional result callback, can be NULL if not required
186  * @return  OCStackResult application result
187  */
188 OCStackResult OCCloudAclIndividualUpdate(void* ctx,
189                                             const char *aclId,
190                                             const char *aceId,
191                                             const cloudAce_t *aces,
192                                             const OCDevAddr *endPoint,
193                                             OCCloudResponseCB callback);
194
195 /**
196  * ACL individual delete - replaces ACE with given aceid with provided ACE
197  *
198  * @param[in] ctx               user-defined context
199  * @param[in] aclId             mandatory parameter acl id
200  * @param[in] endPoint          cloud host and port
201  * @param[in] callback          optional result callback, can be NULL if not required
202  * @return  OCStackResult application result
203  */
204 OCStackResult OCCloudAclIndividualDelete(void* ctx,
205                                          const char *aclId,
206                                          const OCDevAddr *endPoint,
207                                          OCCloudResponseCB callback);
208
209 /**
210  * ACL individual delete ACE
211  *
212  * @param[in] ctx               user-defined context
213  * @param[in] aclId             mandatory parameter acl id
214  * @param[in] aceId             target ace id
215  * @param[in] endPoint          cloud host and port
216  * @param[in] callback          optional result callback, can be NULL if not required
217  * @return  OCStackResult application result
218  */
219 OCStackResult OCCloudAclIndividualDeleteAce(void* ctx,
220                                          const char *aclId,
221                                          const char *aceId,
222                                          const OCDevAddr *endPoint,
223                                          OCCloudResponseCB callback);
224
225 /**
226  * ACL post group request function
227  *
228  * @param[in] ctx               user-defined context
229  * @param[in] groupType         mandatory parameter group type
230  * @param[in] groupMasterId     optional parameter group master id
231  * @param[in] endPoint          cloud host and port
232  * @param[in] callback          optional result callback, can be NULL if not required
233  * @return  OCStackResult application result
234  */
235 OCStackResult OCCloudAclCreateGroup(void* ctx,
236                                     const char *groupType,
237                                     const char *groupMasterId,
238                                     const OCDevAddr *endPoint,
239                                     OCCloudResponseCB callback);
240
241 /**
242  * ACL get group request function
243  *
244  * @param[in] ctx               user-defined context
245  * @param[in] memberId          mandatory parameter member id
246  * @param[in] endPoint          cloud host and port
247  * @param[in] callback          optional result callback, can be NULL if not required
248  * @return  OCStackResult application result
249  */
250 OCStackResult OCCloudAclFindMyGroup(void* ctx,
251                                     const char *memberId,
252                                     const OCDevAddr *endPoint,
253                                     OCCloudResponseCB callback);
254
255 /**
256  * ACL delete group request function
257  *
258  * @param[in] ctx               user-defined context
259  * @param[in] groupId           mandatory parameter group id
260  * @param[in] groupMasterId     optional parameter group master id
261  * @param[in] endPoint          cloud host and port
262  * @param[in] callback          optional result callback, can be NULL if not required
263  * @return  OCStackResult application result
264  */
265 OCStackResult OCCloudAclDeleteGroup(void* ctx,
266                                     const char *groupId,
267                                     const char *groupMasterId,
268                                     const OCDevAddr *endPoint,
269                                     OCCloudResponseCB callback);
270
271 /**
272  * ACL join to invited group request function
273  *
274  * @param[in] ctx               user-defined context
275  * @param[in] groupId           mandatory parameter group id
276  * @param[in] endPoint          cloud host and port
277  * @param[in] callback          optional result callback, can be NULL if not required
278  * @return  OCStackResult application result
279  */
280 OCStackResult OCCloudAclJoinToInvitedGroup(void* ctx,
281                                            const char *groupId,
282                                            const OCDevAddr *endPoint,
283                                            OCCloudResponseCB callback);
284
285 /**
286  * ACL observe group request function
287  *
288  * @param[in] ctx               user-defined context
289  * @param[in] groupId           mandatory parameter group id
290  * @param[in] endPoint          cloud host and port
291  * @param[in] callback          optional result callback, can be NULL if not required
292  * @return  OCStackResult application result
293  */
294 OCStackResult OCCloudAclObserveGroup(void* ctx,
295                                      const char *groupId,
296                                      const OCDevAddr *endPoint,
297                                      OCCloudResponseCB callback);
298
299 /**
300  * ACL share device into group request function
301  *
302  * @param[in] ctx               user-defined context
303  * @param[in] groupId           mandatory parameter group id
304  * @param[in] memberIds         mandatory parameter members list
305  * @param[in] deviceIds         mandatory parameter devices list
306  * @param[in] endPoint          cloud host and port
307  * @param[in] callback          optional result callback, can be NULL if not required
308  * @return  OCStackResult application result
309  */
310 OCStackResult OCCloudAclShareDeviceIntoGroup(void* ctx,
311                                              const char *groupId,
312                                              const stringArray_t *memberIds,
313                                              const stringArray_t *deviceIds,
314                                              const OCDevAddr *endPoint,
315                                              OCCloudResponseCB callback);
316
317 /**
318  * ACL delete device from group request function
319  *
320  * @param[in] ctx               user-defined context
321  * @param[in] groupId           mandatory parameter group id
322  * @param[in] memberIds         mandatory parameter members list
323  * @param[in] deviceIds         mandatory parameter devices list
324  * @param[in] endPoint          cloud host and port
325  * @param[in] callback          optional result callback, can be NULL if not required
326  * @return  OCStackResult application result
327  */
328 OCStackResult OCCloudAclDeleteDeviceFromGroup(void* ctx,
329                                               const char *groupId,
330                                               const stringArray_t *memberIds,
331                                               const stringArray_t *deviceIds,
332                                               const OCDevAddr *endPoint,
333                                               OCCloudResponseCB callback);
334
335 /**
336  * ACL get group info request function
337  *
338  * @param[in] ctx               user-defined context
339  * @param[in] groupId           mandatory parameter group id
340  * @param[in] memberId          optional parameter member id
341  * @param[in] endPoint          cloud host and port
342  * @param[in] callback          optional result callback, can be NULL if not required
343  * @return  OCStackResult application result
344  */
345 OCStackResult OCCloudAclGroupGetInfo(void* ctx,
346                                      const char *groupId,
347                                      const char *memberId,
348                                      const OCDevAddr *endPoint,
349                                      OCCloudResponseCB callback);
350
351 /**
352  * ACL invite user to group request function
353  *
354  * @param[in] ctx               user-defined context
355  * @param[in] userId            optional parameter user id
356  * @param[in] groupIds          mandatory parameter groups list
357  * @param[in] memberIds         mandatory parameter members list
358  * @param[in] endPoint          cloud host and port
359  * @param[in] callback          optional result callback, can be NULL if not required
360  * @return  OCStackResult application result
361  */
362 OCStackResult OCCloudAclInviteUser(void* ctx,
363                                    const char *userId,
364                                    const stringArray_t *groupIds,
365                                    const stringArray_t *memberIds,
366                                    const OCDevAddr *endPoint,
367                                    OCCloudResponseCB callback);
368
369 /**
370  * ACL get invitation request function
371  *
372  * @param[in] ctx               user-defined context
373  * @param[in] userId            optional parameter user id
374  * @param[in] endPoint          cloud host and port
375  * @param[in] callback          optional result callback, can be NULL if not required
376  * @return  OCStackResult application result
377  */
378 OCStackResult OCCloudAclGetInvitation(void* ctx,
379                                       const char *userId,
380                                       const OCDevAddr *endPoint,
381                                       OCCloudResponseCB callback);
382
383 /**
384  * ACL delete invitation request function (by receiver)
385  *
386  * @param[in] ctx               user-defined context
387  * @param[in] userId            optional parameter user id
388  * @param[in] groupId           mandatory parameter group id
389  * @param[in] endPoint          cloud host and port
390  * @param[in] callback          optional result callback, can be NULL if not required
391  * @return  OCStackResult application result
392  */
393 OCStackResult OCCloudAclDeleteInvitation(void* ctx,
394                                          const char *userId,
395                                          const char *groupId,
396                                          const OCDevAddr *endPoint,
397                                          OCCloudResponseCB callback);
398
399 /**
400  * ACL cancel invitation request function (by sender)
401  *
402  * @param[in] ctx               user-defined context
403  * @param[in] userId            optional parameter user id
404  * @param[in] groupId           mandatory parameter group id
405  * @param[in] memberId          mandatory parameter member id
406  * @param[in] endPoint          cloud host and port
407  * @param[in] callback          optional result callback, can be NULL if not required
408  * @return  OCStackResult application result
409  */
410 OCStackResult OCCloudAclCancelInvitation(void* ctx,
411                                          const char *userId,
412                                          const char *groupId,
413                                          const char *memberId,
414                                          const OCDevAddr *endPoint,
415                                          OCCloudResponseCB callback);
416
417 /**
418  * ACL check that given request can be applied to resource
419  *
420  * @param[in] ctx               user-defined context
421  * @param[in] subjectId         mandatory parameter subject id
422  * @param[in] deviceId          mandatory parameter device id
423  * @param[in] method            mandatory parameter method
424  * @param[in] uri               mandatory parameter uri
425  * @param[in] endPoint          cloud host and port
426  * @param[in] callback          optional result callback, can be NULL if not required
427  * @return  OCStackResult application result
428  */
429 OCStackResult OCCloudAclPolicyCheck(void* ctx,
430                                     const char *subjectId,
431                                     const char *deviceId,
432                                     const char *method,
433                                     const char *uri,
434                                     const OCDevAddr *endPoint,
435                                     OCCloudResponseCB callback);
436
437 #ifdef __cplusplus
438 }
439 #endif // __cplusplus
440 #endif //OC_CLOUD_PROVISIONING_H