* @param[in] selectedOperationMode selected operation mode
* @return OC_STACK_OK on success
*/
-static OCStackResult PutOwnerCredential(OTMContext_t* otmCtx);
+static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx);
/**
* Function to send ownerShip info.
return OC_STACK_DELETE_TRANSACTION;
}
- //PUT owner credential to new device according to security spec B.
- res = PutOwnerCredential(otmCtx);
+ //POST owner credential to new device according to security spec B.
+ res = PostOwnerCredential(otmCtx);
if(OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG,
- "OwnerUuidUpdateHandler:Failed to send PUT request for onwer credential");
+ "OwnerUuidUpdateHandler:Failed to send PosT request for onwer credential");
SetResult(otmCtx, res);
return OC_STACK_DELETE_TRANSACTION;
}
return OC_STACK_DELETE_TRANSACTION;
}
-static OCStackResult PutOwnerCredential(OTMContext_t* otmCtx)
+static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx)
{
- OIC_LOG(DEBUG, TAG, "IN PutOwnerCredential");
+ OIC_LOG(DEBUG, TAG, "IN PostOwnerCredential");
if(!otmCtx || !otmCtx->selectedDeviceInfo)
{
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_CRED_URI))
{
- OIC_LOG(ERROR, TAG, "PutOwnerCredential : Failed to generate query");
+ OIC_LOG(ERROR, TAG, "PostOwnerCredential : Failed to generate query");
return OC_STACK_ERROR;
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
newCredential.publicData.len = 0;
#endif
int secureFlag = 0;
- //Send owner credential to new device : PUT /oic/sec/cred [ owner credential ]
+ //Send owner credential to new device : POST /oic/sec/cred [ owner credential ]
if (OC_STACK_OK != CredToCBORPayload(&newCredential, &secPayload->securityData,
&secPayload->payloadSize, secureFlag))
{
cbData.cb = &OwnerCredentialHandler;
cbData.context = (void *)otmCtx;
cbData.cd = NULL;
- OCStackResult res = OCDoResource(NULL, OC_REST_PUT, query,
+ OCStackResult res = OCDoResource(NULL, OC_REST_POST, query,
&deviceInfo->endpoint, (OCPayload*)secPayload,
deviceInfo->connType, OC_HIGH_QOS, &cbData, NULL, 0);
if (res != OC_STACK_OK)
return OC_STACK_NO_RESOURCE;
}
- OIC_LOG(DEBUG, TAG, "OUT PutOwnerCredential");
+ OIC_LOG(DEBUG, TAG, "OUT PostOwnerCredential");
return OC_STACK_OK;
}
#endif //__WITH_DTLS__
-static OCEntityHandlerResult HandlePutRequest(const OCEntityHandlerRequest * ehRequest)
+static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * ehRequest)
{
OCEntityHandlerResult ret = OC_EH_ERROR;
- OIC_LOG(DEBUG, TAG, "HandleCREDPutRequest IN");
+ OIC_LOG(DEBUG, TAG, "HandleCREDPostRequest IN");
//Get binary representation of cbor
OicSecCred_t *cred = NULL;
}
FreeCred(cred);
}
- OIC_LOG(DEBUG, TAG, "HandleCREDPutRequest OUT");
+ OIC_LOG(DEBUG, TAG, "HandleCREDPostRequest OUT");
return ret;
}
return ehRet;
}
-static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * ehRequest)
-{
- OCEntityHandlerResult ret = OC_EH_ERROR;
-
- //Get binary representation of CBOR
- OicSecCred_t *cred = NULL;
- uint8_t *payload = ((OCSecurityPayload*)ehRequest->payload)->securityData;
- size_t size = ((OCSecurityPayload*)ehRequest->payload)->payloadSize;
- OCStackResult res = CBORPayloadToCred(payload, size, &cred);
- if ((OC_STACK_OK == res) && cred)
- {
- //If the Post request credential has credId, it will be
- //discarded and the next available credId will be assigned
- //to it before getting appended to the existing credential
- //list and updating svr database.
- ret = (OC_STACK_OK == AddCredential(cred))? OC_EH_RESOURCE_CREATED : OC_EH_ERROR;
- }
-
- return ret;
-}
-
static OCEntityHandlerResult HandleDeleteRequest(const OCEntityHandlerRequest *ehRequest)
{
OIC_LOG(DEBUG, TAG, "Processing CredDeleteRequest");
if (flag & OC_REQUEST_FLAG)
{
OIC_LOG (DEBUG, TAG, "Flag includes OC_REQUEST_FLAG");
- //TODO : Handle PUT/DEL methods
+ //TODO : Remove Handle PUT methods once CTT have changed to POST on OTM
switch (ehRequest->method)
{
case OC_REST_GET:
ret = HandleGetRequest(ehRequest);;
break;
case OC_REST_PUT:
- ret = HandlePutRequest(ehRequest);
- break;
case OC_REST_POST:
ret = HandlePostRequest(ehRequest);
break;