m_deviceId = resource->sid();
}
-#ifdef __WITH_DTLS__
- ESResult RemoteEnrollee::registerSecurityCallbackHandler(
- const SecurityPinCb securityPinCb,
- const SecProvisioningDbPathCb secProvisioningDbPathCb)
- {
- // No need to check NULL for m_secProvisioningDbPathCB as this is not a mandatory
- // callback function. If m_secProvisioningDbPathCB is NULL, provisioning manager
- // in security layer will try to find the PDM.db file in the local path.
- // If PDM.db is found, the provisioning manager operations will succeed.
- // Otherwise all the provisioning manager operations will fail.
- m_secProvisioningDbPathCb = secProvisioningDbPathCb;
- m_securityPinCb = securityPinCb;
- return ES_OK;
- }
-#endif //__WITH_DTLS__
-
void RemoteEnrollee::securityStatusHandler(
const std::shared_ptr< SecProvisioningStatus > status) const
{
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Entering cloudPropProvisioningStatusHandler");
OIC_LOG_V(DEBUG,ES_REMOTE_ENROLLEE_TAG,"CloudProvStatus = %d",
- status->getESCloudState());
+ status->getESResult());
m_cloudPropProvStatusCb(status);
return;
void RemoteEnrollee::provisionSecurity(const SecurityProvStatusCb callback)
{
#ifdef __WITH_DTLS__
- std::cout << __func__ << std::endl;
+ ESResult res = ESResult::ES_ERROR;
if(!callback)
{
throw ESInvalidParameterException("Callback is empty");
//TODO : DBPath is passed empty as of now. Need to take dbpath from application.
m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
- m_enrolleeSecurity->registerCallbackHandler(securityProvStatusCb, m_securityPinCb,
- m_secProvisioningDbPathCb);
+ res = m_enrolleeSecurity->provisionOwnership();
- try
- {
- m_enrolleeSecurity->performOwnershipTransfer();
- }
- catch (const std::exception& e)
- {
- OIC_LOG_V(ERROR, ES_REMOTE_ENROLLEE_TAG,
- "Exception for performOwnershipTransfer : %s", e.what());
-
- OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Fail performOwnershipTransfer");
- std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus =
- std::make_shared< SecProvisioningStatus >
- (m_enrolleeSecurity->getUUID(), ES_ERROR);
- m_securityProvStatusCb(securityProvisioningStatus);
- return ;
- }
+ std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus =
+ std::make_shared< SecProvisioningStatus >(m_enrolleeSecurity->getUUID(), res);
+ m_securityProvStatusCb(securityProvisioningStatus);
#else
OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_TAG,"Mediator is unsecured.");
if(!callback)
{
ESResult result = ES_ERROR;
- if (m_cloudResource != nullptr)
- {
- throw ESBadRequestException ("Already created");
- }
-
result = discoverResource();
if (result == ES_ERROR)
if(m_ocResource != nullptr)
{
m_cloudResource = std::make_shared<CloudResource>(m_ocResource);
-
- std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_FOUND_ENROLLEE);
-
- m_cloudPropProvStatusCb(provStatus);
}
else
{
"Exception caught in provisionCloudProperties = %s", e.what());
std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_NOT_FOUND_ENROLLEE);
+ CloudPropProvisioningStatus >(ESResult::ES_ENROLLEE_DISCOVERY_FAILURE);
m_cloudPropProvStatusCb(provStatus);
return;
}
-
-#ifdef __WITH_DTLS__
- try
+#if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
+ if(!(cloudProp.getCloudID().empty() && cloudProp.getCredID() <= 0))
{
- ESResult res = ES_OK;
+ ESResult res = ESResult::ES_ERROR;
m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
- if(cloudProp.getCloudID().empty())
- {
- throw ESBadRequestException("Invalid Cloud Server UUID.");
- }
-
- res = m_enrolleeSecurity->performACLProvisioningForCloudServer(cloudProp.getCloudID());
+ res = m_enrolleeSecurity->provisionSecurityForCloudServer(cloudProp.getCloudID(),
+ cloudProp.getCredID());
- if(res == ESResult::ES_ERROR)
+ if(res != ESResult::ES_OK)
{
- throw ESBadRequestException("Error in provisioning operation!");
+ m_cloudResource = nullptr;
+ std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
+ CloudPropProvisioningStatus >(res);
+ m_cloudPropProvStatusCb(provStatus);
+ return;
}
-
}
-
- catch (const std::exception& e)
+ else
{
- OIC_LOG_V(ERROR, ES_REMOTE_ENROLLEE_TAG,
- "Exception caught in provisionCloudProperties = %s", e.what());
-
- m_cloudResource = nullptr;
-
- std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_ERROR);
- m_cloudPropProvStatusCb(provStatus);
- return;
+ OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_TAG, "ACL and Cert. provisioning are skipped.");
}
-#endif
+#endif //defined(__WITH_DTLS__) && defined(__WITH_TLS__)
if (m_cloudResource == nullptr)
{