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 ESResult provisionOwnership();
56 std::string getUUID() const;
59 std::shared_ptr< OC::OCResource > m_ocResource;
60 SecurityProvStatusCb m_securityProvStatusCb;
61 SecurityPinCb m_securityPinCb;
62 SecProvisioningDbPathCb m_secProvisioningDbPathCb;
65 std::condition_variable m_cond;
66 std::atomic<bool> OTMResult;
67 std::atomic<bool> removeDeviceResult;
68 std::atomic<bool> aclResult;
69 std::atomic<bool> certResult;
71 std::shared_ptr< OC::OCSecureResource > m_securedResource;
73 ESResult performOwnershipTransfer();
74 bool isOwnedDeviceRegisteredInSVRDB();
75 void removeDeviceWithUuidCB(OC::PMResultList_t *result, int hasError);
76 void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
77 void convertUUIDToString(const uint8_t uuid[UUID_SIZE],
78 std::string& uuidString);
80 #if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
82 ESResult provisionSecurityForCloudServer(
83 std::string cloudUuid, int credId);
85 ESResult performCertProvisioningForCloudServer(
86 std::shared_ptr< OC::OCSecureResource > ownedDevice,
88 ESResult performACLProvisioningForCloudServer(
89 std::shared_ptr< OC::OCSecureResource > ownedDevice,
90 std::string& cloudUuid);
91 OicSecAcl_t* createAcl(const OicUuid_t cloudUuid);
92 void ACLProvisioningCb(PMResultList_t *result, int hasError);
93 void CertProvisioningCb(PMResultList_t *result, int hasError);
94 #endif //defined(__WITH_DTLS__) && defined(__WITH_TLS__)
99 #endif /* ENROLLEE_SECURITY_H_*/