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_
26 #include <condition_variable>
28 #include "ESRichCommon.h"
29 #include "OCProvisioningManager.h"
35 #define ENROLEE_SECURITY_TAG "ENROLLEE_SECURITY"
36 #define UUID_SIZE (16)
37 #define UUID_STRING_SIZE (37)
40 class EnrolleeResource;
41 class OCSecureResource;
43 typedef std::vector<OCProvisionResult_t> PMResultList_t;
46 * This class contains the methods needed for security layer interaction.
48 * @see EnrolleeSecurity
50 class EnrolleeSecurity
53 EnrolleeSecurity(std::shared_ptr< OC::OCResource > resource,
54 const std::string secDbPath);
55 void registerCallbackHandler(
56 const SecurityProvStatusCb securityProvStatusCb,
57 const SecurityPinCb securityPinCb,
58 const SecProvisioningDbPathCb secProvisioningDbPathCb);
59 ESResult provisionOwnership();
60 std::string getUUID() const;
63 std::shared_ptr< OC::OCResource > m_ocResource;
64 SecurityProvStatusCb m_securityProvStatusCb;
65 SecurityPinCb m_securityPinCb;
66 SecProvisioningDbPathCb m_secProvisioningDbPathCb;
69 std::condition_variable m_cond;
70 std::atomic<bool> OTMResult;
71 std::atomic<bool> removeDeviceResult;
72 std::atomic<bool> aclResult;
73 std::atomic<bool> certResult;
75 std::shared_ptr< OC::OCSecureResource > m_securedResource;
77 ESResult performOwnershipTransfer();
78 bool isOwnedDeviceRegisteredInSVRDB();
79 void removeDeviceWithUuidCB(OC::PMResultList_t *result, int hasError);
80 void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
81 void convertUUIDToString(const uint8_t uuid[UUID_SIZE],
82 std::string& uuidString);
84 #if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
86 ESResult provisionSecurityForCloudServer(
87 std::string cloudUuid, int credId);
89 ESResult performCertProvisioningForCloudServer(
90 std::shared_ptr< OC::OCSecureResource > ownedDevice,
92 ESResult performACLProvisioningForCloudServer(
93 std::shared_ptr< OC::OCSecureResource > ownedDevice,
94 std::string& cloudUuid);
95 OicSecAcl_t* createAcl(const OicUuid_t cloudUuid);
96 void ACLProvisioningCb(PMResultList_t *result, int hasError);
97 void CertProvisioningCb(PMResultList_t *result, int hasError);
98 #endif //defined(__WITH_DTLS__) && defined(__WITH_TLS__)
103 #endif /* ENROLLEE_SECURITY_H_*/