From: Parkhi Date: Wed, 18 Jan 2017 12:03:41 +0000 (+0900) Subject: Update MOT condition check logic & easysetup MOT function signature X-Git-Tag: 1.3.0~801 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbafcd641430796d44b95afe6449408092551918;p=platform%2Fupstream%2Fiotivity.git Update MOT condition check logic & easysetup MOT function signature - if user didn't want to MOT, MOT process is skipped. Change-Id: I4ea7e41eab398d7d8f9bc46fdc9a7940c9423500 Signed-off-by: Parkhi Reviewed-on: https://gerrit.iotivity.org/gerrit/16529 Tested-by: jenkins-iotivity Reviewed-by: Jihun Ha Reviewed-by: Uze Choi --- diff --git a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp index b09d1fb..2dba9dd 100755 --- a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp +++ b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp @@ -66,7 +66,6 @@ namespace OIC { (void) secDbPath; m_ocResource = resource; - m_ownershipTransferData = {}; } void EnrolleeSecurity::onEnrolleeSecuritySafetyCB(OC::PMResultList_t *result, @@ -328,6 +327,8 @@ namespace OIC ESResult res = ESResult::ES_ERROR; OCStackResult result = OC_STACK_ERROR; + ESOwnershipTransferData ownershipTransferData; + OicUuid_t uuid; if(OC_STACK_OK != ConvertStrToUuid(m_ocResource->sid().c_str(), &uuid)) { @@ -381,18 +382,18 @@ namespace OIC std::make_shared< SecProvisioningStatus > (m_securedResource, ESResult::ES_SECURE_RESOURCE_IS_DISCOVERED); - m_ownershipTransferData = callback(securityProvisioningStatus); + ownershipTransferData = callback(securityProvisioningStatus); - if(OIC_RANDOM_DEVICE_PIN == m_ownershipTransferData.getMOTMethod()) + if(OIC_RANDOM_DEVICE_PIN == ownershipTransferData.getMOTMethod()) { OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Selected MOT Method: OIC_RANDOM_DEVICE_PIN"); } #ifdef MULTIPLE_OWNER - else if(OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod()) + else if(OIC_PRECONFIG_PIN == ownershipTransferData.getMOTMethod()) { OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Selected MOT Method: OIC_PRECONFIG_PIN"); OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "Pre-configured PIN: %s", - m_ownershipTransferData.getPreConfiguredPin().c_str()); + ownershipTransferData.getPreConfiguredPin().c_str()); } #endif } @@ -463,8 +464,8 @@ namespace OIC #ifdef MULTIPLE_OWNER if( m_securedResource->isMOTSupported() && m_securedResource->isMOTEnabled() && - OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() && - !m_ownershipTransferData.getPreConfiguredPin().empty()) + OIC_PRECONFIG_PIN == ownershipTransferData.getMOTMethod() && + !ownershipTransferData.getPreConfiguredPin().empty()) { OC::ResultCallBack preconfigPinProvCB = std::bind( &EnrolleeSecurity::onEnrolleeSecuritySafetyCB, @@ -473,7 +474,7 @@ namespace OIC this, std::placeholders::_1, std::placeholders::_2)), shared_from_this()); - std::string pin = m_ownershipTransferData.getPreConfiguredPin(); + std::string pin = ownershipTransferData.getPreConfiguredPin(); OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "provisionPreconfPin is called."); if(OC_STACK_OK != m_securedResource->provisionPreconfPin( @@ -496,8 +497,8 @@ namespace OIC if( m_securedResource->isMOTSupported() && m_securedResource->isMOTEnabled() && - (OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() || - OIC_RANDOM_DEVICE_PIN == m_ownershipTransferData.getMOTMethod())) + (OIC_PRECONFIG_PIN == ownershipTransferData.getMOTMethod() || + OIC_RANDOM_DEVICE_PIN == ownershipTransferData.getMOTMethod())) { OC::ResultCallBack selectMOTMethodCB = std::bind( &EnrolleeSecurity::onEnrolleeSecuritySafetyCB, @@ -508,7 +509,7 @@ namespace OIC OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "selectMOTMethod is called."); if(OC_STACK_OK != m_securedResource->selectMOTMethod( - m_ownershipTransferData.getMOTMethod(), + ownershipTransferData.getMOTMethod(), selectMOTMethodCB)) { OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "selectMOTMethod API error"); @@ -528,7 +529,9 @@ namespace OIC #endif } #ifdef MULTIPLE_OWNER - else if(m_securedResource->isMOTSupported() && m_securedResource->isMOTEnabled()) + else if(m_securedResource->isMOTSupported() && m_securedResource->isMOTEnabled() + && (ownershipTransferData.getMOTMethod() == OIC_RANDOM_DEVICE_PIN || + ownershipTransferData.getMOTMethod() == OIC_PRECONFIG_PIN)) { OCUUIdentity* mediatorDevId = (OCUUIdentity* )OICMalloc(sizeof(OCUUIdentity)); @@ -577,7 +580,7 @@ namespace OIC OICFree(mediatorDevId); - res = performMultipleOwnershipTransfer(); + res = performMultipleOwnershipTransfer(ownershipTransferData); if(res != ESResult::ES_OK) { @@ -640,7 +643,7 @@ namespace OIC } #ifdef MULTIPLE_OWNER - ESResult EnrolleeSecurity::performMultipleOwnershipTransfer() + ESResult EnrolleeSecurity::performMultipleOwnershipTransfer(const ESOwnershipTransferData& MOTdata) { OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "performMultipleOwnershipTransfer IN."); @@ -649,10 +652,10 @@ namespace OIC OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "Transfering sub-ownership for : %s ", m_securedResource->getDeviceID().c_str()); - if(OIC_PRECONFIG_PIN == m_ownershipTransferData.getMOTMethod() && - !m_ownershipTransferData.getPreConfiguredPin().empty()) + if(OIC_PRECONFIG_PIN == MOTdata.getMOTMethod() && + !MOTdata.getPreConfiguredPin().empty()) { - std::string pin = m_ownershipTransferData.getPreConfiguredPin(); + std::string pin = MOTdata.getPreConfiguredPin(); result = m_securedResource->addPreconfigPIN(pin.c_str(), pin.length()); if(OC_STACK_OK != result) diff --git a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h index 435ef7c..6ce1abe 100755 --- a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h +++ b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h @@ -74,8 +74,6 @@ namespace OIC std::shared_ptr< OC::OCSecureResource > m_securedResource; - ESOwnershipTransferData m_ownershipTransferData; - static void onEnrolleeSecuritySafetyCB(OC::PMResultList_t *result, int hasError, ESSecurityCb cb, @@ -85,7 +83,7 @@ namespace OIC bool isOwnedDeviceRegisteredInSVRDB(); void removeDeviceWithUuidCB(OC::PMResultList_t *result, int hasError); #ifdef MULTIPLE_OWNER - ESResult performMultipleOwnershipTransfer(); + ESResult performMultipleOwnershipTransfer(const ESOwnershipTransferData& MOTdata); void SelectMOTMethodCB(PMResultList_t *result, int hasError); void PreconfigPinProvCB(PMResultList_t *result, int hasError); void MultipleOwnershipTransferCb(OC::PMResultList_t *result, int hasError);