Commit a83fd153 authored by Parkhi's avatar Parkhi Committed by Uze Choi

Update OTM condition check logic.

 - we need to seperate OTM condition(i.e. Not synchronized with DB, enrollee is already owned by other mediator)

Change-Id: I20696908ff961f3c2ae2f18f9fec01cb6a60fc82
Signed-off-by: default avatarParkhi <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17013Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 034c990a
......@@ -559,23 +559,6 @@ namespace OIC
return ownershipTransferData;
}
bool EnrolleeSecurity::isTargetDeviceMine()
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "isTargetDeviceMine IN");
#ifdef MULTIPLE_OWNER
if(isOwnedDeviceRegisteredInDB() &&
(isOwnerIDMatched(m_securedResource) ||
isSubOwnerIDMatched(m_securedResource)))
#else
if(isOwnedDeviceRegisteredInDB() &&
isOwnerIDMatched(m_securedResource))
#endif
{
return true;
}
return false;
}
ESResult EnrolleeSecurity::syncUpWithMediatorDB()
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "syncUpWithMediatorDB IN");
......@@ -677,7 +660,15 @@ namespace OIC
if(m_securedResource->getOwnedStatus())
{
if(isTargetDeviceMine())
#ifdef MULTIPLE_OWNER
if(isOwnedDeviceRegisteredInDB() &&
(isOwnerIDMatched(m_securedResource) ||
isSubOwnerIDMatched(m_securedResource)))
#else
if(isOwnedDeviceRegisteredInDB() &&
isOwnerIDMatched(m_securedResource))
#endif
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG,
"The found device is already owned by Mediator.(SUCCESS)");
......@@ -686,6 +677,8 @@ namespace OIC
}
#ifdef MULTIPLE_OWNER
else if( !isOwnedDeviceRegisteredInDB() &&
!isOwnerIDMatched(m_securedResource) &&
!isSubOwnerIDMatched(m_securedResource) &&
m_securedResource->isMOTSupported() &&
m_securedResource->isMOTEnabled() &&
OIC_PRECONFIG_PIN == ownershipTransferData.getMOTMethod() &&
......@@ -701,12 +694,23 @@ namespace OIC
return res;
}
}
else if( !isOwnedDeviceRegisteredInDB() &&
(isOwnerIDMatched(m_securedResource) ||
isSubOwnerIDMatched(m_securedResource)))
#else
else if( !isOwnedDeviceRegisteredInDB() && isOwnerIDMatched(m_securedResource))
#endif
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,
"An ownership transfer knowledge is not synchronized between mediator and found enrollee.(FAILED)");
res = ESResult::ES_OWNERSHIP_IS_NOT_SYNCHRONIZED;
return res;
}
else
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG,
"The found device is already owned by Other Mediator.(FAILED)");
res = ESResult::ES_OWNERSHIP_IS_NOT_SYNCHRONIZED;
res = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE;
return res;
}
}
......
......@@ -85,7 +85,6 @@ namespace OIC
ESResult discoverTargetSecureResource();
ESOwnershipTransferData getOwnershipTransferDataFromUser
(SecurityProvStatusCbWithOption callback);
bool isTargetDeviceMine();
ESResult syncUpWithMediatorDB();
#ifdef MULTIPLE_OWNER
ESResult performMultipleOwnershipTransfer(const ESOwnershipTransferData& MOTdata);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment