fbd273d70230b5322fc276e4920b578f578ce894
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / include / RemoteEnrollee.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 REMOTE_ENROLLEE_H_\r
22 #define REMOTE_ENROLLEE_H_\r
23 \r
24 #include "escommon.h"\r
25 \r
26 namespace OIC\r
27 {\r
28     namespace Service\r
29     {\r
30         class RemoteEnrolleeResource;\r
31         class EnrolleeSecurity;\r
32 \r
33         /**\r
34          * This class represents Remote Enrollee device instance.\r
35          * It will provide APIs for Mediator to perform operations to enable the Enrollee device\r
36          * to connect to the Enroller.\r
37          */\r
38         class RemoteEnrollee\r
39         {\r
40         public:\r
41             /**\r
42              * RemoteEnrollee constructor\r
43              *\r
44              * @param enrolleeNWProvInfo Provisioning information for the Enrollee\r
45              *\r
46              * @throw ESBadRequestException is thrown if the parameters are invalid\r
47              */\r
48             RemoteEnrollee(const EnrolleeNWProvInfo& enrolleeNWProvInfo) ;\r
49 \r
50             ~RemoteEnrollee() = default;\r
51 \r
52             typedef std::shared_ptr< RemoteEnrollee > shared_ptr;\r
53 \r
54             /**\r
55              * Callback definition to be invoked when EasySetup status is changed.\r
56              * The same callback will be invoked when there is an error in the\r
57              * EasySetup process.\r
58              *\r
59              * @see registerResourceHandler\r
60              * @see ResourceState\r
61              */\r
62             typedef std::function< void(std::shared_ptr< EasySetupStatus >) >\r
63                                                                         EasySetupStatusCB;\r
64 \r
65 #ifdef __WITH_DTLS__\r
66             /**\r
67              * Register Security status and other information callback handlers.\r
68              *\r
69              * @param secProvisioningDbCb Callback to be invoked when the stack expects a\r
70              *        path for the provisioning db.\r
71              * @param securityPinCb Callback to get security pin during pin based ownership transfer.\r
72              *\r
73              * @throws InvalidParameterException If callback is an empty function or null.\r
74              * @throws ESBadRequestException If registration is already completed.\r
75              *\r
76              * @see SecProvisioningResult\r
77              */\r
78             ESResult registerSecurityCallbackHandler(SecurityPinCb securityPinCb,\r
79                     SecProvisioningDbPathCb secProvisioningDbPathCb);\r
80 #endif //__WITH_DTLS__\r
81 \r
82             /**\r
83              * Register EasySetup status handler.\r
84              *\r
85              * @param callback Callback to get EasySetup status.\r
86              * @param secProvisioningDbCB Callback to be invoked when the stack expects a\r
87              *        path for the provisioning db.\r
88              *\r
89              * @throws InvalidParameterException If callback is an empty function or null.\r
90              * @throws ESBadRequestException If registration is already completed.\r
91              *\r
92              * @see EasySetupStatus\r
93              */\r
94             void registerEasySetupStatusHandler(EasySetupStatusCB callback);\r
95 \r
96             /**\r
97              * Start provisioning of target Enrollers information to the Enrollee.\r
98              *\r
99              * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.\r
100              *\r
101              * @see RemoteEnrollee\r
102              */\r
103             void startProvisioning();\r
104 \r
105             /**\r
106              * Stop provisioning process that is currently in progress.\r
107              *\r
108              * @throws BadRequestException If provisioning is not in progress.\r
109              */\r
110             void stopProvisioning();\r
111 \r
112             /**\r
113              * Check if the Enrollee device provisioned.\r
114              */\r
115             bool isEnrolleeProvisioned();\r
116 \r
117             /**\r
118              * Get the Provisioning information provided for the current Enrollee.\r
119              *\r
120              * @return EnrolleeNWProvInfo Provisioning information provided for the current Enrollee.\r
121              */\r
122             EnrolleeNWProvInfo& getEnrolleeProvisioningInfo ();\r
123 \r
124         private:\r
125             std::shared_ptr< RemoteEnrolleeResource > m_remoteResource;\r
126             EasySetupStatusCB m_easySetupStatusCb;\r
127             EnrolleeSecStatusCb m_enrolleeSecStatusCb;\r
128             SecurityPinCb m_securityPinCb;\r
129             SecProvisioningDbPathCb m_secProvisioningDbPathCb;\r
130             EnrolleeNWProvInfo m_enrolleeNWProvInfo;\r
131             std::shared_ptr< EnrolleeSecurity > m_enrolleeSecurity;\r
132             CurrentESState m_currentESState;\r
133             bool m_needSecuredEasysetup;\r
134 \r
135             void provisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);\r
136             void easySetupSecurityStatusCallback(\r
137             std::shared_ptr< SecProvisioningResult > secProvisioningResult);\r
138         };\r
139     }\r
140 }\r
141 \r
142 #endif //REMOTE_ENROLLEE_H_\r