ES_OWNERSHIP_IS_NOT_SYNCHRONIZED,
/**
+ * Ownership transfer which is cert-based method fails due to user confirmation is denied.
+ */
+ ES_USER_DENIED_CONFIRMATION_REQ,
+
+ /**
+ * Ownership transfer which is cert-based method fails due to wrong certificate.
+ */
+ ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT,
+
+ /**
+ * Ownership transfer which is random-pin method fails due to wrong pin.
+ */
+ ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN,
+
+ /**
* Provisioning fails for some reason.
*/
ES_ERROR = 255
}
#endif
- void EnrolleeSecurity::ownershipTransferCb(OC::PMResultList_t *result, int hasError)
+ void EnrolleeSecurity::ownershipTransferCb(OC::PMResultList_t *result, int hasError
+ , ESResult& res)
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "ownershipTransferCb IN");
if (hasError)
{
- OIC_LOG_V(ERROR, ENROLEE_SECURITY_TAG, "OwnershipTransfer is failed with code(%d)", hasError);
+ for (unsigned int i = 0; i < result->size(); i++)
+ {
+ std::string uuid;
+ convertUUIDToString(result->at(i).deviceId.id, uuid);
+
+ if(m_ocResource != NULL && m_ocResource->sid() == uuid)
+ {
+ if(OC_STACK_USER_DENIED_REQ == result->at(i).res)
+ {
+ res = ESResult::ES_USER_DENIED_CONFIRMATION_REQ;
+ }
+ else if(OC_STACK_AUTHENTICATION_FAILURE == result->at(i).res)
+ {
+ OicSecOxm_t oxm;
+ if(OC_STACK_OK != m_securedResource->getOTMethod(&oxm))
+ {
+ OTMResult = false;
+ return;
+ }
+
+ if(OIC_MANUFACTURER_CERTIFICATE == oxm)
+ {
+ res = ESResult::ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT;
+ }
+ else if(OIC_CON_MFG_CERT == oxm)
+ {
+ res = ESResult::ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT;
+ }
+ else if(OIC_RANDOM_DEVICE_PIN == oxm)
+ {
+ res = ESResult::ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN;
+ }
+ }
+ }
+ }
+ OIC_LOG_V(ERROR, ENROLEE_SECURITY_TAG, "OwnershipTransfer is failed with ESResult(%d)", res);
+
OTMResult = false;
}
else
res = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE;
return res;
}
- OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "Removing device is succeeded.");
+ OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Removing device is succeeded.");
}
if(!m_securedResource->getOwnedStatus())
{
- res = performOwnershipTransfer();
+ ESResult result = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE;
+ res = performOwnershipTransfer(result);
if(res != ESResult::ES_OK)
{
if(!OTMResult)
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "Ownership-Transfer failed.");
- res = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE;
- return res;
+ return result;
}
#ifdef MULTIPLE_OWNER
if( m_securedResource->isMOTSupported() &&
return res;
}
- ESResult EnrolleeSecurity::performOwnershipTransfer()
+ ESResult EnrolleeSecurity::performOwnershipTransfer(ESResult& res)
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "performOwnershipTransfer IN.");
std::bind(&EnrolleeSecurity::onEnrolleeSecuritySafetyCB,
std::placeholders::_1, std::placeholders::_2,
static_cast<ESSecurityCb>(std::bind(&EnrolleeSecurity::ownershipTransferCb,
- this, std::placeholders::_1, std::placeholders::_2)),
+ this, std::placeholders::_1, std::placeholders::_2, std::ref(res))),
shared_from_this());
#endif //defined(__WITH_DTLS__) && defined(__WITH_TLS__)
}
}
+
ESSecurityCb cb,
std::weak_ptr<EnrolleeSecurity> this_ptr);
- ESResult performOwnershipTransfer();
+ ESResult performOwnershipTransfer(ESResult& res);
bool isOwnedDeviceRegisteredInSVRDB();
void removeDeviceWithUuidCB(OC::PMResultList_t *result, int hasError);
#ifdef MULTIPLE_OWNER
void PreconfigPinProvCB(PMResultList_t *result, int hasError);
void MultipleOwnershipTransferCb(OC::PMResultList_t *result, int hasError);
#endif
- void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
+ void ownershipTransferCb(OC::PMResultList_t *result, int hasError, ESResult& res);
void convertUUIDToString(const uint8_t uuid[UUID_SIZE],
std::string& uuidString);
std::string getResourceDeviceAddress(const std::string& host);