Updated Easysetup Security logic.
authorParkhi <h_w.park@samsung.com>
Tue, 11 Oct 2016 07:12:18 +0000 (16:12 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 13 Oct 2016 09:24:20 +0000 (09:24 +0000)
 - EnrolleeSecure resource not to re-created during previous request is processed
   for every security provisioning request to get callback from security-logic

Change-Id: I905b1cf708db68583a95bd9cad299212fa00ec84
Signed-off-by: Parkhi <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13077
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit 6bc9e3388d3cafb0af33e785b3650af9f94ff7d1)
Reviewed-on: https://gerrit.iotivity.org/gerrit/13203
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp

index 6fec143ed25e638e0122664ae4fe4002476f8327..58661d078cacdfbcdbac18edf7b04f7bbb31bdfd 100755 (executable)
@@ -220,13 +220,17 @@ namespace OIC
                     this,
                     std::placeholders::_1);
             //TODO : DBPath is passed empty as of now. Need to take dbpath from application.
-            m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
+            if(!m_enrolleeSecurity.get())
+            {
+                m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
+            }
 
             res = m_enrolleeSecurity->provisionOwnership();
 
             std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus =
                             std::make_shared< SecProvisioningStatus >(m_enrolleeSecurity->getUUID(), res);
             m_securityProvStatusCb(securityProvisioningStatus);
+            m_enrolleeSecurity.reset();
 #else
             OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Mediator is unsecured.");
             if(!callback)
@@ -375,11 +379,15 @@ namespace OIC
             if(!(cloudProp.getCloudID().empty() && cloudProp.getCredID() <= 0))
             {
                 ESResult res = ESResult::ES_ERROR;
-                m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
+                if(!m_enrolleeSecurity.get())
+                {
+                    m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
+                }
+
 
                 res = m_enrolleeSecurity->provisionSecurityForCloudServer(cloudProp.getCloudID(),
                                                                           cloudProp.getCredID());
-
+                m_enrolleeSecurity.reset();
                 if(res != ESResult::ES_OK)
                 {
                     m_cloudResource = nullptr;