2fba49e7b81b3fbd0cdf4027e9edd1749dd83c8f
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / src / EnrolleeSecurity.h
1 //******************************************************************\r
2 //\r
3 // Copyright 2015 Samsung Electronics All Rights Reserved.\r
4 //\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 //\r
7 // Licensed under the Apache License, Version 2.0 (the "License");\r
8 // you may not use this file except in compliance with the License.\r
9 // You may obtain a copy of the License at\r
10 //\r
11 //      http://www.apache.org/licenses/LICENSE-2.0\r
12 //\r
13 // Unless required by applicable law or agreed to in writing, software\r
14 // distributed under the License is distributed on an "AS IS" BASIS,\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 // See the License for the specific language governing permissions and\r
17 // limitations under the License.\r
18 //\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 #ifndef ENROLLEE_SECURITY_H_\r
22 #define ENROLLEE_SECURITY_H_\r
23 \r
24 #include <functional>\r
25 \r
26 #include "escommon.h"\r
27 #include "OCProvisioningManager.h"\r
28 \r
29 namespace OIC\r
30 {\r
31     namespace Service\r
32     {\r
33 #define ENROLEE_SECURITY_TAG "ENROLEE_SECURITY"\r
34 \r
35         class RemoteEnrolleeResource;\r
36         class OCSecureResource;\r
37 \r
38         /**\r
39          * This class contains the methods needed for security  layer interaction.\r
40          *\r
41          * @see EnrolleeSecurity\r
42          */\r
43         class EnrolleeSecurity\r
44         {\r
45         public:\r
46             EnrolleeSecurity(std::shared_ptr< RemoteEnrolleeResource > remoteEnrolleeResource,\r
47             std::string secDbPath);\r
48 \r
49             ESResult registerCallbackHandler(EnrolleeSecStatusCb enrolleeSecStatusCb,\r
50                     SecurityPinCb securityPinCb, SecProvisioningDbPathCb secProvisioningDbPathCb);\r
51 \r
52             EasySetupState performOwnershipTransfer();\r
53 \r
54             ESResult provisionCreds();\r
55 \r
56             ESResult provisionAcl();\r
57 \r
58         private:\r
59             std::shared_ptr< RemoteEnrolleeResource > m_remoteEnrolleeResource;\r
60             EnrolleeSecStatusCb m_enrolleeSecStatusCb;\r
61             SecurityPinCb m_securityPinCb;\r
62             SecProvisioningDbPathCb m_secProvisioningDbPathCb;\r
63             std::shared_ptr< OC::OCSecureResource > m_unownedDevice;\r
64 \r
65             EnrolleeSecState m_enrolleeSecState;std::shared_ptr< OC::OCSecureResource > m_securedResource;\r
66 \r
67             std::shared_ptr< OC::OCSecureResource > findEnrollee(std::string host,\r
68                     OC::DeviceList_t &list);\r
69             void provisionCb(OC::PMResultList_t *result, int hasError);\r
70             void ownershipTransferCb(OC::PMResultList_t *result, int hasError);\r
71             void convertUUIDToString(OicUuid_t uuid, std::string& uuidString);\r
72             ESResult createProvisiongResourceACL(OicSecAcl_t *acl);\r
73             int CalculateAclPermission(const char *temp_pms, uint16_t *pms);\r
74         };\r
75     }\r
76 }\r
77 \r
78 #endif /* ENROLLEE_SECURITY_H_*/\r
79 \r