Add an API to provision ACL of cloud server
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / EnrolleeSecurity.h
1 //******************************************************************
2 //
3 // Copyright 2015 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
21 #ifndef ENROLLEE_SECURITY_H_
22 #define ENROLLEE_SECURITY_H_
23
24 #include <functional>
25
26 #include "ESRichCommon.h"
27 #include "OCProvisioningManager.h"
28
29 namespace OIC
30 {
31     namespace Service
32     {
33 #define ENROLEE_SECURITY_TAG "ENROLEE_SECURITY"
34
35         class EnrolleeResource;
36         class OCSecureResource;
37
38         typedef std::vector<OCProvisionResult_t> PMResultList_t;
39
40         /**
41          * This class contains the methods needed for security  layer interaction.
42          *
43          * @see EnrolleeSecurity
44          */
45         class EnrolleeSecurity
46         {
47         public:
48             EnrolleeSecurity(std::shared_ptr< OC::OCResource > resource,
49             std::string secDbPath);
50             void registerCallbackHandler(SecurityProvStatusCb securityProvStatusCb,
51                     SecurityPinCb securityPinCb, SecProvisioningDbPathCb secProvisioningDbPathCb);
52             void performOwnershipTransfer();
53             void performACLProvisioningForCloudServer(OicUuid_t serverUuid);
54
55         private:
56             std::shared_ptr< OC::OCResource > m_ocResource;
57             SecurityProvStatusCb m_securityProvStatusCb;
58             SecurityPinCb m_securityPinCb;
59             SecProvisioningDbPathCb m_secProvisioningDbPathCb;
60             std::shared_ptr< OC::OCSecureResource > m_unownedDevice;
61
62
63             std::shared_ptr< OC::OCSecureResource > m_securedResource;
64
65             std::shared_ptr< OC::OCSecureResource > getEnrollee(OC::DeviceList_t &list);
66             void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
67             void convertUUIDToString(OicUuid_t uuid, std::string& uuidString);
68             OicSecAcl_t* createAcl(OicUuid_t serverUuid);
69
70             void ACLProvisioningCb(PMResultList_t *result, int hasError);
71         };
72     }
73 }
74
75 #endif /* ENROLLEE_SECURITY_H_*/
76