Remove unused old API.
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / src / EnrolleeSecurity.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef ENROLLEE_SECURITY_H_
22 #define ENROLLEE_SECURITY_H_
23
24 #include <functional>
25 #include <atomic>
26 #include <condition_variable>
27
28 #include "ESRichCommon.h"
29 #include "OCProvisioningManager.h"
30
31 namespace OIC
32 {
33     namespace Service
34     {
35         #define ENROLEE_SECURITY_TAG "ENROLLEE_SECURITY"
36         #define UUID_SIZE (16)
37         #define UUID_STRING_SIZE (37)
38
39
40         class EnrolleeResource;
41         class OCSecureResource;
42
43         typedef std::vector<OCProvisionResult_t> PMResultList_t;
44
45         /**
46          * This class contains the methods needed for security  layer interaction.
47          *
48          * @see EnrolleeSecurity
49          */
50         class EnrolleeSecurity
51         {
52         public:
53             EnrolleeSecurity(std::shared_ptr< OC::OCResource > resource,
54             const std::string secDbPath);
55             ESResult provisionOwnership();
56             std::string getUUID() const;
57
58         private:
59             std::shared_ptr< OC::OCResource > m_ocResource;
60             SecurityProvStatusCb m_securityProvStatusCb;
61             SecurityPinCb m_securityPinCb;
62             SecProvisioningDbPathCb m_secProvisioningDbPathCb;
63
64             std::mutex m_mtx;
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;
70
71             std::shared_ptr< OC::OCSecureResource > m_securedResource;
72
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);
79
80 #if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
81         public:
82             ESResult provisionSecurityForCloudServer(
83                 std::string cloudUuid, int credId);
84         private:
85             ESResult performCertProvisioningForCloudServer(
86                 std::shared_ptr< OC::OCSecureResource > ownedDevice,
87                 int credId);
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__)
95         };
96     }
97 }
98
99 #endif /* ENROLLEE_SECURITY_H_*/
100