}
}
-char *BinToCrlJSON(const OicSecCrl_t *crl, const bool isIncResName)
+char *BinToCrlJSON(const OicSecCrl_t *crl)
{
if (NULL == crl)
{
uint32_t base64CRLLen = 0;
B64Result b64Ret = B64_OK;
char *jsonStr = NULL;
-
cJSON *jsonRoot = cJSON_CreateObject();
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
+ cJSON *jsonCrl = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonCrl, ERROR);
- cJSON *jsonCrl = NULL;
- if(isIncResName)
- {
- jsonCrl = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonCrl, ERROR);
- cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRL_NAME, jsonCrl);
- }
- else
- {
- jsonCrl = jsonRoot;
- }
+ cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRL_NAME, jsonCrl);
//CRLId -- Mandatory
cJSON_AddNumberToObject(jsonCrl, OIC_JSON_CRL_ID, (int)crl->CrlId);
return jsonStr;
}
-OicSecCrl_t *JSONToCrlBin(const char * jsonStr, const bool isIncResName)
+OicSecCrl_t *JSONToCrlBin(const char * jsonStr)
{
if (NULL == jsonStr)
{
cJSON *jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonCrl = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRL_NAME);
- }
- else
- {
- jsonCrl = jsonRoot;
- }
+ jsonCrl = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRL_NAME);
VERIFY_NON_NULL(TAG, jsonCrl, ERROR);
-
crl = (OicSecCrl_t *)OICCalloc(1, sizeof(OicSecCrl_t));
VERIFY_NON_NULL(TAG, crl, ERROR);
char *jsonStr = NULL;
OCStackResult res = OC_STACK_ERROR;
- jsonStr = BinToCrlJSON((OicSecCrl_t *) crl, true);
+ jsonStr = BinToCrlJSON((OicSecCrl_t *) crl);
if (!jsonStr)
{
return OC_STACK_ERROR;
if (jsonCRL)
{
- OC_LOG(INFO, TAG, "UpdateSVRDB...");
- OC_LOG_V(INFO, TAG, "crl: \"%s\"", jsonCRL);
+ OIC_LOG(INFO, TAG, "UpdateSVRDB...");
+ OIC_LOG_V(INFO, TAG, "crl: \"%s\"", jsonCRL);
cJSON *jsonObj = cJSON_Parse(jsonCRL);
OicSecCrl_t *crl = NULL;
- crl = JSONToCrlBin(jsonCRL, false);
+ crl = JSONToCrlBin(jsonCRL);
if (!crl)
{
- OC_LOG(ERROR, TAG, "Error JSONToCrlBin");
+ OIC_LOG(ERROR, TAG, "Error JSONToCrlBin");
}
gCrl->CrlId = crl->CrlId;
if (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_CRL_NAME, jsonObj))
{
- OC_LOG(INFO, TAG, "UpdateSVRDB == OK");
+ OIC_LOG(INFO, TAG, "UpdateSVRDB == OK");
ehRet = OC_EH_RESOURCE_CREATED;
}
// Send payload to request originator
SendSRMResponse(ehRequest, ehRet, NULL);
- OC_LOG_V(INFO, TAG, "%s RetVal %d", __func__, ehRet);
+ OIC_LOG_V(INFO, TAG, "%s RetVal %d", __func__, ehRet);
return ehRet;
}
return ehRet;
}
- OC_LOG(INFO, TAG, "Handle CRL resource");
+ OIC_LOG(INFO, TAG, "Handle CRL resource");
if (flag & OC_REQUEST_FLAG)
{
// TODO : Handle PUT and DEL methods
- OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
switch (ehRequest->method)
{
case OC_REST_GET:
- OC_LOG (INFO, TAG, "Not implemented request method.");
+ OIC_LOG (INFO, TAG, "Not implemented request method.");
//ehRet = HandleCRLGetRequest(ehRequest);
break;
if (OC_STACK_OK != ret)
{
- OC_LOG(FATAL, TAG, "Unable to instantiate CRL resource");
+ OIC_LOG(FATAL, TAG, "Unable to instantiate CRL resource");
DeInitCRLResource();
}
return ret;
if (jsonSVRDatabase)
{
//Convert JSON CRL into binary format
- gCrl = JSONToCrlBin(jsonSVRDatabase, true);
+ gCrl = JSONToCrlBin(jsonSVRDatabase);
}
/*
* If SVR database in persistent storage got corrupted or
if (jsonSVRDatabase)
{
//Convert JSON CRL into binary format
- crl = JSONToCrlBin(jsonSVRDatabase, true);
+ crl = JSONToCrlBin(jsonSVRDatabase);
}
/*
* If SVR database in persistent storage got corrupted or