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 ENROLLEE_SECURITY_H_
22 #define ENROLLEE_SECURITY_H_
25 #include <condition_variable>
27 #include "ESRichCommon.h"
28 #include "OCProvisioningManager.h"
34 #define ENROLEE_SECURITY_TAG "ENROLEE_SECURITY"
36 class EnrolleeResource;
37 class OCSecureResource;
39 typedef std::vector<OCProvisionResult_t> PMResultList_t;
42 * This class contains the methods needed for security layer interaction.
44 * @see EnrolleeSecurity
46 class EnrolleeSecurity
49 EnrolleeSecurity(std::shared_ptr< OC::OCResource > resource,
50 std::string secDbPath);
51 void registerCallbackHandler(SecurityProvStatusCb securityProvStatusCb,
52 SecurityPinCb securityPinCb, SecProvisioningDbPathCb secProvisioningDbPathCb);
53 void performOwnershipTransfer();
54 ESResult performACLProvisioningForCloudServer(std::string cloudUuid);
55 std::string getUUID() const;
58 std::shared_ptr< OC::OCResource > m_ocResource;
59 SecurityProvStatusCb m_securityProvStatusCb;
60 SecurityPinCb m_securityPinCb;
61 SecProvisioningDbPathCb m_secProvisioningDbPathCb;
62 std::shared_ptr< OC::OCSecureResource > m_unownedDevice;
65 std::condition_variable m_cond;
68 std::shared_ptr< OC::OCSecureResource > m_securedResource;
69 std::shared_ptr< OC::OCSecureResource > getEnrollee(OC::DeviceList_t &list);
70 void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
71 void convertUUIDToString(OicUuid_t uuid, std::string& uuidString);
72 void convertStringToUUID(OicUuid_t& uuid, std::string uuidString);
73 OicSecAcl_t* createAcl(OicUuid_t cloudUuid);
75 void ACLProvisioningCb(PMResultList_t *result, int hasError);
80 #endif /* ENROLLEE_SECURITY_H_*/