Update a logic to utilize newly developed security APIs.
authorJihun Ha <jihun.ha@samsung.com>
Wed, 14 Dec 2016 06:44:40 +0000 (15:44 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 9 Jan 2017 01:41:02 +0000 (01:41 +0000)
A patch for security APIs is submitted: https://gerrit.iotivity.org/gerrit/#/c/15577/
With this patch, some points in easy setup can utilize the new APIs for more
correct decision.

Change-Id: I3b570f7f28d587ef39a0323f6d39294c0a391568
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15581
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit bb947106af8e4b51603cc82c40f96b7c43283dd6)
Reviewed-on: https://gerrit.iotivity.org/gerrit/16013

service/easy-setup/mediator/richsdk/inc/ESRichCommon.h
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp

index 7c1e8c3..4ba1249 100755 (executable)
@@ -523,11 +523,14 @@ namespace OIC
                 {
                     m_devUUID = resource->getDeviceID();
                     m_isOwned = resource->getOwnedStatus();
+#ifdef MULTIPLE_OWNER
+                    m_isMOTEnabled = resource->isMOTEnabled();
+#endif
 
-                    // TODO
-                    // When severAPIs in OCSecureResource for getting a list of supported methods or
-                    // status of MOT support, a code for setting this information will be implemeted.
-                    m_selectedOTMethod = OIC_JUST_WORKS;
+                    if( OC_STACK_OK != resource->getOTMethod(&m_selectedOTMethod) )
+                    {
+                        m_selectedOTMethod = OIC_OXM_COUNT; // Out-of-range
+                    }
                 }
             }
 
index d78e542..d9d1b47 100755 (executable)
@@ -424,7 +424,8 @@ namespace OIC
                             return res;
                         }
 #ifdef MULTIPLE_OWNER
-                        if( // m_securedResource->isMOTSupported() && //not provided, yet
+                        if( m_securedResource->isMOTSupported() &&
+                            m_securedResource->isMOTEnabled() &&
                             OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() &&
                                 !m_ownershipTransferData.getPreConfiguredPin().empty())
                         {
@@ -456,9 +457,10 @@ namespace OIC
                             }
                         }
 
-                        if(// m_securedResource->isMOTSupported() && //not provided, yet
-                            OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() ||
-                            OIC_RANDOM_DEVICE_PIN == m_ownershipTransferData.getMOTMethod())
+                        if( m_securedResource->isMOTSupported() &&
+                            m_securedResource->isMOTEnabled() &&
+                            (OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() ||
+                                OIC_RANDOM_DEVICE_PIN == m_ownershipTransferData.getMOTMethod()))
                         {
                             OC::ResultCallBack selectMOTMethodCB = std::bind(
                                     &EnrolleeSecurity::onEnrolleeSecuritySafetyCB,
index 32f7b54..082b74a 100755 (executable)
@@ -100,9 +100,11 @@ ESOwnershipTransferData provisionSecurityStatusCallback(std::shared_ptr<SecProvi
 
     if(secProvisioningStatus->getESResult() == ES_SECURE_RESOURCE_IS_DISCOVERED)
     {
-#if defined(__WITH_DTLS__) && defined(MULTIPLE_OWNER)
+#ifdef __WITH_DTLS__
         cout << "Owned Status : " << secProvisioningStatus->isOwnedDevice() << std::endl;
         cout << "OT Method : " << secProvisioningStatus->getSelectedOTMethod() << std::endl;
+#ifdef MULTIPLE_OWNER
+        cout << "MOT Enabled : " << secProvisioningStatus->isMOTEnabled() << std::endl;
 
         // TEST
         ESOwnershipTransferData OTData;
@@ -113,6 +115,7 @@ ESOwnershipTransferData provisionSecurityStatusCallback(std::shared_ptr<SecProvi
 
         return OTData;
 #endif
+#endif
     }
     else if(secProvisioningStatus->getESResult() == ES_OK)
     {
index dacc552..b548475 100755 (executable)
@@ -100,9 +100,11 @@ ESOwnershipTransferData provisionSecurityStatusCallback(std::shared_ptr<SecProvi
 
     if(secProvisioningStatus->getESResult() == ES_SECURE_RESOURCE_IS_DISCOVERED)
     {
-#if defined(__WITH_DTLS__) && defined(MULTIPLE_OWNER)
+#ifdef __WITH_DTLS__
         cout << "Owned Status : " << secProvisioningStatus->isOwnedDevice() << std::endl;
         cout << "OT Method : " << secProvisioningStatus->getSelectedOTMethod() << std::endl;
+#ifdef MULTIPLE_OWNER
+        cout << "MOT Enabled : " << secProvisioningStatus->isMOTEnabled() << std::endl;
 
         // TEST
         ESOwnershipTransferData OTData;
@@ -113,6 +115,8 @@ ESOwnershipTransferData provisionSecurityStatusCallback(std::shared_ptr<SecProvi
 
         return OTData;
 #endif
+#endif
+
     }
     else if(secProvisioningStatus->getESResult() == ES_OK)
     {