1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef REMOTE_ENROLLEE_H_
22 #define REMOTE_ENROLLEE_H_
31 class RemoteEnrolleeResource;
32 class EnrolleeSecurity;
35 * This class represents Remote Enrollee device instance.
36 * It will provide APIs for Mediator to perform operations to enable the Enrollee device
37 * to connect to the Enroller.
43 * RemoteEnrollee constructor
45 * @param enrolleeNWProvInfo Provisioning information for the Enrollee
47 * @throw ESBadRequestException is thrown if the parameters are invalid
49 RemoteEnrollee(const EnrolleeNWProvInfo& enrolleeNWProvInfo) ;
51 ~RemoteEnrollee() = default;
53 typedef std::shared_ptr< RemoteEnrollee > shared_ptr;
56 * Callback definition to be invoked when EasySetup status is changed.
57 * The same callback will be invoked when there is an error in the
60 * @see registerResourceHandler
63 typedef std::function< void(std::shared_ptr< EasySetupStatus >) >
68 * Register Security status and other information callback handlers.
70 * @param secProvisioningDbCb Callback to be invoked when the stack expects a
71 * path for the provisioning db.
72 * @param securityPinCb Callback to get security pin during pin based ownership transfer.
74 * @throws InvalidParameterException If callback is an empty function or null.
75 * @throws ESBadRequestException If registration is already completed.
77 * @see SecProvisioningResult
79 ESResult registerSecurityCallbackHandler(SecurityPinCb securityPinCb,
80 SecProvisioningDbPathCb secProvisioningDbPathCb);
81 #endif //__WITH_DTLS__
84 * Register EasySetup status handler.
86 * @param callback Callback to get EasySetup status.
87 * @param secProvisioningDbCB Callback to be invoked when the stack expects a
88 * path for the provisioning db.
90 * @throws InvalidParameterException If callback is an empty function or null.
91 * @throws ESBadRequestException If registration is already completed.
93 * @see EasySetupStatus
95 void registerEasySetupStatusHandler(EasySetupStatusCB callback);
98 * Start provisioning of target Enrollers information to the Enrollee.
100 * @throws ESBadRequestException If RemoteEnrollee device not created prior to this call.
102 * @see RemoteEnrollee
104 void startProvisioning();
107 * Stop provisioning process that is currently in progress.
109 * @throws BadRequestException If provisioning is not in progress.
111 void stopProvisioning();
114 * Check if the Enrollee device provisioned.
116 bool isEnrolleeProvisioned();
119 * Get the Provisioning information provided for the current Enrollee.
121 * @return EnrolleeNWProvInfo Provisioning information provided for the current Enrollee.
123 EnrolleeNWProvInfo& getEnrolleeProvisioningInfo ();
126 std::shared_ptr< RemoteEnrolleeResource > m_remoteResource;
127 EasySetupStatusCB m_easySetupStatusCb;
128 EnrolleeSecStatusCb m_enrolleeSecStatusCb;
129 SecurityPinCb m_securityPinCb;
130 SecProvisioningDbPathCb m_secProvisioningDbPathCb;
131 EnrolleeNWProvInfo m_enrolleeNWProvInfo;
132 std::shared_ptr< EnrolleeSecurity > m_enrolleeSecurity;
133 CurrentESState m_currentESState;
134 bool m_needSecuredEasysetup;
136 void provisioningStatusHandler (std::shared_ptr< ProvisioningStatus > provStatus);
137 void easySetupSecurityStatusCallback(
138 std::shared_ptr< SecProvisioningResult > secProvisioningResult);
143 #endif //REMOTE_ENROLLEE_H_