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 04:24:21 +0000 (04: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>
service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp

index ef13296..00c5df7 100755 (executable)
@@ -222,13 +222,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 built.");
 
@@ -392,11 +396,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;