* Caller needs to invoke 'free' when done using
* returned string.
* @param acl instance of OicSecAcl_t structure.
- * @param isIncResName decide whether or not to include the resource name in output.
*
* @retval pointer to ACL in json format.
*/
-char* BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName);
+char* BinToAclJSON(const OicSecAcl_t * acl);
/**
/**
* This function installs a new ACL.
* @param newJsonStr JSON string representing a new ACL.
- * @param isIncResName if resource name is included into payload, it is true.
*
* @retval OC_STACK_OK for Success, otherwise some error value
*/
-OCStackResult InstallNewACL(const char* newJsonStr, const bool isIncResName);
+OCStackResult InstallNewACL(const char* newJsonStr);
#ifdef __cplusplus
* Caller needs to invoke 'free' when done using
* returned string.
* @param Amacl instance of OicSecAmacl_t structure.
- * @param isIncResName Decide whether or not to include the name of the resource in output.
*
* @retval pointer to Amacl in json format.
*/
-char* BinToAmaclJSON(const OicSecAmacl_t * amacl, const bool isIncResName);
+char* BinToAmaclJSON(const OicSecAmacl_t * amacl);
#ifdef __cplusplus
}
* Caller needs to invoke 'free' when done using
* returned string.
* @param cred pointer to instance of OicSecCred_t structure.
- * @param isIncResName Decide whether or not to include the resource name in output.
*
* @retval
* pointer to JSON credential representation - if credential for subjectId found
* NULL - if credential for subjectId not found
*/
-char* BinToCredJSON(const OicSecCred_t* cred, const bool isIncResName);
+char* BinToCredJSON(const OicSecCred_t* cred);
/**
* This function generates the bin credential data.
void GetDerCrl(ByteArray crlArray);
/**
- * This method converts JSON CRL into binary CRL.
- * The JSON CRL can be from persistent database or received as PUT/POST request.
+ * This function get CRL from SRM
*
- * @param[in] jsonStr CRL data in json string.
- * @param[in] isIncResName if resource name is included into payload, it is true.
- * @return pointer to OicSecCrl_t.
+ * @param crl [out] - pointer to buffer that contains crl. Shoul be not NULL. Buffer
+ * will be allocated by the function and content of *crl will be ignored.
+ * @param outlen [out] - pointer to length of the CRL buffer. Shoul be not NULL.
*
- * @note Caller needs to invoke OCFree after done using the return pointer
+ * @returns OC_STACK_OK if success and errorcode otherwise.
+ * @note Caller responsible for crl buffer memory (use OICFree to free it)
*/
-OicSecCrl_t * JSONToCrlBin(const char * jsonStr, const bool isIncResName);
+OicSecCrl_t * JSONToCrlBin(const char * jsonStr);
/**
* Initialize CLR resource by loading data from persistent storage.
* or received as PUT/POST request.
*
* @param[in] jsonStr doxm data in json string.
- * @param[in] isIncResName if resource name is included into payload, it is true.
* @return pointer to OicSecDoxm_t.
*
* @note Caller needs to invoke OCFree after done
* using the return pointer
*/
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName);
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr);
/**
* This method converts DOXM data into JSON format.
* return string
*
* @param[in] doxm Pointer to OicSecDoxm_t.
- * @param[in] isIncResName Decide whether or not to include the resource name in output.
* @return pointer to json string.
*
* @note Caller needs to invoke OCFree after done
* using the return pointer
*/
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName);
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm);
/**
* This method returns the SRM device ID for this device.
* This method converts JSON PSTAT into binary PSTAT.
*
* @param[in] jsonStr pstat data in json string.
- * @param[in] isIncResName if resource name is included into payload, it is true.
* @return pointer to OicSecPstat_t.
*/
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName);
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr);
/**
* This method converts pstat data into JSON format.
*
* @param[in] pstat pstat data in binary format.
- * @param[in] isIncResName Decide whether or not to include the resource name in output.
* @return pointer to pstat json string.
*/
-char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName);
+char * BinToPstatJSON(const OicSecPstat_t * pstat);
/** This function deallocates the memory for OicSecPstat_t.
*
extern const char * OIC_JSON_PERMISSION_NAME;
extern const char * OIC_JSON_OWNERS_NAME;
extern const char * OIC_JSON_OWNER_NAME;
-extern const char * OIC_JSON_DEV_OWNER_NAME;
extern const char * OIC_JSON_OWNED_NAME;
extern const char * OIC_JSON_OXM_NAME;
extern const char * OIC_JSON_OXM_TYPE_NAME;
extern const char * OIC_JSON_OXM_SEL_NAME;
extern const char * OIC_JSON_DEVICE_ID_FORMAT_NAME;
extern const char * OIC_JSON_CREDID_NAME;
-extern const char * OIC_JSON_SUBJECTID_NAME;
extern const char * OIC_JSON_ROLEIDS_NAME;
extern const char * OIC_JSON_CREDTYPE_NAME;
extern const char * OIC_JSON_PUBLICDATA_NAME;
* Caller needs to invoke 'free' when done using
* returned string.
* @param svc instance of OicSecSvc_t structure.
- * @param isIncResName Decide whether or not to include the resource name in output.
*
* @retval pointer to SVC in json format.
*/
-char* BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName);
+char* BinToSvcJSON(const OicSecSvc_t * svc);
#ifdef __cplusplus
}
struct OicSecDoxm
{
// <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
+ OicUrn_t *oxmType; // 0:R:M:N:URN
+ size_t oxmTypeLen; // the number of elts in OxmType
OicSecOxm_t *oxm; // 1:R:M:N:UINT16
size_t oxmLen; // the number of elts in Oxm
OicSecOxm_t oxmSel; // 2:R/W:S:Y:UINT16
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/res/d",
"/oic/res/types/d",
"/oic/presence"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"ZG9vckRldmljZVVVSUQwMA=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/crl",
"/oic/sec/cred"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"ZG9vckRldmljZVVVSUQwMA=="
]
}
"pstat": {
"isop": false,
"deviceid": "ZG9vckRldmljZVVVSUQwMA==",
- "ch": 0,
+ "commithash": 0,
"cm": 0,
"tm": 0,
"om": 3,
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/res/d",
"/oic/res/types/d",
"/oic/presence"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"bGlnaHREZXZpY2VVVUlEMA=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/crl",
"/oic/sec/cred"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"bGlnaHREZXZpY2VVVUlEMA=="
]
}
"pstat": {
"isop": false,
"deviceid": "bGlnaHREZXZpY2VVVUlEMA==",
- "ch": 0,
+ "commithash": 0,
"cm": 0,
"tm": 0,
"om": 3,
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
],
- "permission": 7,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 7,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlEMA==",
- "devowner": "YWRtaW5EZXZpY2VVVUlEMA=="
+ "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
}
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
],
- "permission": 7,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
+ "perms": 7,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
}
],
"crl": {
"oxmsel": 0,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlE",
- "devowner": "YWRtaW5EZXZpY2VVVUlE"
+ "ownr": "YWRtaW5EZXZpY2VVVUlE"
}
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/ad",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlEMA==",
- "devowner": "YWRtaW5EZXZpY2VVVUlEMA=="
+ "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
}
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
],
- "permission": 7,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
+ "perms": 7,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlE",
- "devowner": "YWRtaW5EZXZpY2VVVUlE"
+ "ownr": "YWRtaW5EZXZpY2VVVUlE"
}
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/res/d",
"/oic/res/types/d",
"/oic/presence"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"anVzdHdvcmtzRGV2VVVJRA=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"anVzdHdvcmtzRGV2VVVJRA=="
]
}
"pstat": {
"isop": false,
"deviceid": "anVzdHdvcmtzRGV2VVVJRA==",
- "ch": 0,
+ "commithash": 0,
"cm": 0,
"tm": 0,
"om": 3,
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/res/d",
"/oic/res/types/d",
"/oic/presence"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"cmFuZG9tUGluRGV2VVVJRA=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"cmFuZG9tUGluRGV2VVVJRA=="
]
}
"pstat": {
"isop": false,
"deviceid": "cmFuZG9tUGluRGV2VVVJRA==",
- "ch": 0,
+ "commithash": 0,
"cm": 0,
"tm": 0,
"om": 3,
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/sec/svc",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 2,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 6,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 6,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
}
],
"pstat": {
}
OicSecPstat_t* pstat = JSONToPstatBin(
- ((OCSecurityPayload*)clientResponse->payload)->securityData, false);
+ ((OCSecurityPayload*)clientResponse->payload)->securityData);
if(NULL == pstat)
{
OC_LOG(ERROR, TAG, "Error while converting json to pstat bin");
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToPstatJSON(deviceInfo->pstat, false);
+ secPayload->securityData = BinToPstatJSON(deviceInfo->pstat);
if (NULL == secPayload->securityData)
{
OICFree(secPayload);
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToPstatJSON(otmCtx->selectedDeviceInfo->pstat, false);
+ secPayload->securityData = BinToPstatJSON(otmCtx->selectedDeviceInfo->pstat);
if (NULL == secPayload->securityData)
{
OICFree(secPayload);
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToAclJSON(&defaultAcl, false);
+ secPayload->securityData = BinToAclJSON(&defaultAcl);
OICFree(defaultAcl.owners);
if(!secPayload->securityData)
{
}
otmCtx->selectedDeviceInfo->doxm->oxmSel = OIC_JUST_WORKS;
- return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
+ return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
}
char* CreateJustWorksOwnerTransferPayload(OTMContext_t* otmCtx)
memcpy(otmCtx->selectedDeviceInfo->doxm->owner.id, uuidPT.id , UUID_LENGTH);
otmCtx->selectedDeviceInfo->doxm->owned = true;
- return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
+ return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
}
OCStackResult LoadSecretJustWorksCallback(OTMContext_t* UNUSED_PARAM)
}
memcpy(otmCtx->selectedDeviceInfo->doxm->owner.id, uuidPT.id, UUID_LENGTH);
- return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
+ return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
}
char* CreatePinBasedOwnerTransferPayload(OTMContext_t* otmCtx)
memcpy(otmCtx->selectedDeviceInfo->doxm->owner.id, uuidPT.id , UUID_LENGTH);
otmCtx->selectedDeviceInfo->doxm->owned = true;
- return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
+ return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
}
OCStackResult InputPinCodeCallback(OTMContext_t* otmCtx)
#include "cJSON.h"
#include "utlist.h"
#include "ocpayload.h"
-#include "payload_logging.h"
#include "securevirtualresourcetypes.h"
#include "srmresourcestrings.h" //@note: SRM's internal header
memcpy(newDev->doxm, src->doxm, sizeof(OicSecDoxm_t));
// We have to assign NULL for not necessary information to prevent memory corruption.
+ newDev->doxm->oxmType = NULL;
newDev->doxm->oxm = NULL;
}
}
else
{
- OC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
-
if (PAYLOAD_TYPE_DISCOVERY != clientResponse->payload->type)
{
OC_LOG(INFO, TAG, "Wrong payload type");
}
else
{
- OC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
-
if (PAYLOAD_TYPE_SECURITY != clientResponse->payload->type)
{
OC_LOG(INFO, TAG, "Unknown payload type");
return OC_STACK_KEEP_TRANSACTION;
}
OicSecDoxm_t *ptrDoxm = JSONToDoxmBin(
- ((OCSecurityPayload*)clientResponse->payload)->securityData, false);
+ ((OCSecurityPayload*)clientResponse->payload)->securityData);
if (NULL == ptrDoxm)
{
OC_LOG(INFO, TAG, "Ignoring malformed JSON");
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToCredJSON(cred, false);
+ secPayload->securityData = BinToCredJSON(cred);
if(NULL == secPayload->securityData)
{
OICFree(secPayload);
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToCrlJSON(crl, false);
+ secPayload->securityData = BinToCrlJSON(crl);
if (NULL == secPayload->securityData)
{
OICFree(secPayload);
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToCredJSON(cred, false);
+ secPayload->securityData = BinToCredJSON(cred);
if (NULL == secPayload->securityData)
{
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
- secPayload->securityData = BinToAclJSON(acl, false);
+ secPayload->securityData = BinToAclJSON(acl);
if(NULL == secPayload->securityData)
{
OICFree(secPayload);
* Note: Caller needs to invoke 'free' when finished done using
* return string.
*/
-char * BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName)
+char * BinToAclJSON(const OicSecAcl_t * acl)
{
cJSON *jsonRoot = NULL;
char *jsonStr = NULL;
if (acl)
{
+ jsonRoot = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
+
cJSON *jsonAclArray = NULL;
- if(isIncResName)
- {
- jsonRoot = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- cJSON_AddItemToObject (jsonRoot, OIC_JSON_ACL_NAME, jsonAclArray=cJSON_CreateArray());
- }
- else
- {
- jsonAclArray = cJSON_CreateArray();
- jsonRoot = jsonAclArray;
- }
+ cJSON_AddItemToObject (jsonRoot, OIC_JSON_ACL_NAME, jsonAclArray = cJSON_CreateArray());
VERIFY_NON_NULL(TAG, jsonAclArray, ERROR);
while(acl)
/*
* This internal method converts JSON ACL into binary ACL.
*/
-OicSecAcl_t * JSONToAclBin(const char * jsonStr, const bool isIncResName)
+OicSecAcl_t * JSONToAclBin(const char * jsonStr)
{
OCStackResult ret = OC_STACK_ERROR;
OicSecAcl_t * headAcl = NULL;
jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonAclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_ACL_NAME);
- }
- else
- {
- jsonAclArray = jsonRoot;
- }
+ jsonAclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_ACL_NAME);
VERIFY_NON_NULL(TAG, jsonAclArray, ERROR);
if (cJSON_Array == jsonAclArray->type)
static bool UpdatePersistentStorage(const OicSecAcl_t *acl)
{
// Convert ACL data into JSON for update to persistent storage
- char *jsonStr = BinToAclJSON(acl, true);
+ char *jsonStr = BinToAclJSON(acl);
if (jsonStr)
{
cJSON *jsonAcl = cJSON_Parse(jsonStr);
0 == strcmp(WILDCARD_RESOURCE_URI, currentAce->resources[n])))
{
// Convert ACL data into JSON for transmission
- jsonStr = BinToAclJSON(currentAce, false);
+ jsonStr = BinToAclJSON(currentAce);
goto exit;
}
}
else
{
// Convert ACL data into JSON for transmission
- jsonStr = BinToAclJSON(currentAce, false);
+ jsonStr = BinToAclJSON(currentAce);
goto exit;
}
}
else
{
// Convert ACL data into JSON for transmission
- jsonStr = BinToAclJSON(gAcl, false);
+ jsonStr = BinToAclJSON(gAcl);
}
exit:
OCEntityHandlerResult ehRet = OC_EH_ERROR;
// Convert JSON ACL data into binary. This will also validate the ACL data received.
- OicSecAcl_t* newAcl = JSONToAclBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
+ OicSecAcl_t* newAcl = JSONToAclBin(((OCSecurityPayload*)ehRequest->payload)->securityData);
if (newAcl)
{
if (jsonSVRDatabase)
{
// Convert JSON ACL into binary format
- gAcl = JSONToAclBin(jsonSVRDatabase, true);
+ gAcl = JSONToAclBin(jsonSVRDatabase);
OICFree(jsonSVRDatabase);
}
/*
}
-OCStackResult InstallNewACL(const char* newJsonStr, const bool isIncResName)
+OCStackResult InstallNewACL(const char* newJsonStr)
{
OCStackResult ret = OC_STACK_ERROR;
// Convert JSON ACL data into binary. This will also validate the ACL data received.
- OicSecAcl_t* newAcl = JSONToAclBin(newJsonStr, isIncResName);
+ OicSecAcl_t* newAcl = JSONToAclBin(newJsonStr);
if (newAcl)
{
LL_APPEND(gAcl, newAcl);
// Convert ACL data into JSON for update to persistent storage
- char *jsonStr = BinToAclJSON(gAcl, true);
+ char *jsonStr = BinToAclJSON(gAcl);
if (jsonStr)
{
cJSON *jsonAcl = cJSON_Parse(jsonStr);
*
* Note: Caller needs to invoke 'free' when finished using the return string.
*/
-char * BinToAmaclJSON(const OicSecAmacl_t * amacl, const bool isIncResName)
+char * BinToAmaclJSON(const OicSecAmacl_t * amacl)
{
cJSON *jsonRoot = NULL;
char *jsonStr = NULL;
if (amacl)
{
+ jsonRoot = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
+
cJSON *jsonAmaclArray = NULL;
- if(isIncResName)
- {
- jsonRoot = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- cJSON_AddItemToObject(jsonRoot, OIC_JSON_AMACL_NAME,
- jsonAmaclArray = cJSON_CreateArray());
- }
- else
- {
- jsonAmaclArray = cJSON_CreateArray();
- jsonRoot = jsonAmaclArray;
- }
+ cJSON_AddItemToObject (jsonRoot, OIC_JSON_AMACL_NAME, jsonAmaclArray = cJSON_CreateArray());
VERIFY_NON_NULL(TAG, jsonAmaclArray, ERROR);
while(amacl)
/*
* This internal method converts JSON AMACL into binary AMACL.
*/
-OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr, const bool isIncResName)
+OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr)
{
OCStackResult ret = OC_STACK_ERROR;
OicSecAmacl_t * headAmacl = NULL;
jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonAmaclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_AMACL_NAME);
- }
- else
- {
- jsonAmaclArray = jsonRoot;
- }
+ jsonAmaclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_AMACL_NAME);
VERIFY_NON_NULL(TAG, jsonAmaclArray, INFO);
if (cJSON_Array == jsonAmaclArray->type)
static OCEntityHandlerResult HandleAmaclGetRequest (const OCEntityHandlerRequest * ehRequest)
{
// Convert Amacl data into JSON for transmission
- char* jsonStr = BinToAmaclJSON(gAmacl, false);
+ char* jsonStr = BinToAmaclJSON(gAmacl);
OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
OCEntityHandlerResult ehRet = OC_EH_ERROR;
// Convert JSON Amacl data into binary. This will also validate the Amacl data received.
- OicSecAmacl_t* newAmacl = JSONToAmaclBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
+ OicSecAmacl_t* newAmacl = JSONToAmaclBin(((OCSecurityPayload*)ehRequest->payload)->securityData);
if (newAmacl)
{
LL_APPEND(gAmacl, newAmacl);
// Convert Amacl data into JSON for update to persistent storage
- char *jsonStr = BinToAmaclJSON(gAmacl, true);
+ char *jsonStr = BinToAmaclJSON(gAmacl);
if (jsonStr)
{
cJSON *jsonAmacl = cJSON_Parse(jsonStr);
if (jsonSVRDatabase)
{
// Convert JSON Amacl into binary format
- gAmacl = JSONToAmaclBin(jsonSVRDatabase, true);
+ gAmacl = JSONToAmaclBin(jsonSVRDatabase);
OICFree(jsonSVRDatabase);
}
OicSecDoxm_t *doxm = NULL;
OC_LOG_V(INFO, TAG, "Doxm DeviceId Discovery response = %s\n",
((OCSecurityPayload*)clientResponse->payload)->securityData);
- doxm = JSONToDoxmBin(((OCSecurityPayload*)clientResponse->payload)->securityData, false);
+ doxm = JSONToDoxmBin(((OCSecurityPayload*)clientResponse->payload)->securityData);
//As doxm is NULL amsmgr can't test if response from trusted AMS service
//so keep the transaction.
sizeof(context->amsMgrContext->amsDeviceId.id)) == 0)
{
OCStackResult ret =
- InstallNewACL(((OCSecurityPayload*)clientResponse->payload)->securityData, false);
+ InstallNewACL(((OCSecurityPayload*)clientResponse->payload)->securityData);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
OC_LOG_V(INFO, TAG, "%s : Calling checkPermission", __func__);
* Caller needs to invoke 'free' when done using
* returned string.
* @param cred pointer to instance of OicSecCred_t structure.
- * @param isIncResName Decide whether or not to include the resource name in output.
*
* @retval
* pointer to JSON credential representation - if credential for subjectId found
* NULL - if credential for subjectId not found
*/
-char * BinToCredJSON(const OicSecCred_t * cred, const bool isIncResName)
+char * BinToCredJSON(const OicSecCred_t * cred)
{
cJSON *jsonRoot = NULL;
char *jsonStr = NULL;
char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*)0)->id)) + 1] = {};
uint32_t outLen = 0;
B64Result b64Ret = B64_OK;
- cJSON *jsonCredArray = NULL;
- if(isIncResName)
- {
- jsonRoot = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRED_NAME,
- jsonCredArray = cJSON_CreateArray());
- }
- else
- {
- jsonCredArray = cJSON_CreateArray();
- jsonRoot = jsonCredArray;
- }
+ jsonRoot = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
+
+ cJSON *jsonCredArray = NULL;
+ cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRED_NAME,
+ jsonCredArray = cJSON_CreateArray());
VERIFY_NON_NULL(TAG, jsonCredArray, ERROR);
while(cred)
b64Ret = b64Encode(cred->subject.id, sizeof(cred->subject.id), base64Buff,
sizeof(base64Buff), &outLen);
VERIFY_SUCCESS(TAG, b64Ret == B64_OK, ERROR);
- cJSON_AddStringToObject(jsonCred, OIC_JSON_SUBJECTID_NAME, base64Buff);
+ cJSON_AddStringToObject(jsonCred, OIC_JSON_SUBJECT_NAME, base64Buff);
//Note: Need further clarification on roleID data type
#if 0
/*
* This internal method converts JSON cred into binary cred.
*/
-OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName)
+OicSecCred_t * JSONToCredBin(const char * jsonStr)
{
OCStackResult ret = OC_STACK_ERROR;
OicSecCred_t * headCred = NULL;
cJSON *jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonCredArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRED_NAME);
- }
- else
- {
- jsonCredArray = jsonRoot;
- }
+ jsonCredArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRED_NAME);
VERIFY_NON_NULL(TAG, jsonCredArray, ERROR);
-
if (cJSON_Array == jsonCredArray->type)
{
int numCred = cJSON_GetArraySize(jsonCredArray);
}
//subject -- Mandatory
- jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_SUBJECTID_NAME);
+ jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_SUBJECT_NAME);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
outLen = 0;
bool ret = false;
// Convert Cred data into JSON for update to persistent storage
- char *jsonStr = BinToCredJSON(cred, true);
+ char *jsonStr = BinToCredJSON(cred);
if (jsonStr)
{
cJSON *jsonCred = cJSON_Parse(jsonStr);
OCEntityHandlerResult ret = OC_EH_ERROR;
//Get binary representation of json
- OicSecCred_t * cred = JSONToCredBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
+ OicSecCred_t * cred = JSONToCredBin(((OCSecurityPayload*)ehRequest->payload)->securityData);
if(cred)
{
ParseQueryIterInit((unsigned char *)ehRequest->query, &parseIter);
while(GetNextQuery(&parseIter))
{
- if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECTID_NAME,
+ if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECT_NAME,
parseIter.attrLen) == 0)
{
unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
if (jsonSVRDatabase)
{
//Convert JSON Cred into binary format
- gCred = JSONToCredBin(jsonSVRDatabase, true);
+ gCred = JSONToCredBin(jsonSVRDatabase);
}
/*
* If SVR database in persistent storage got corrupted or
}
}
-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;
cJSON *jsonObj = cJSON_Parse(jsonCRL);
OicSecCrl_t *crl = NULL;
- crl = JSONToCrlBin(jsonCRL, false);
+ crl = JSONToCrlBin(jsonCRL);
if (!crl)
{
OC_LOG(ERROR, TAG, "Error JSONToCrlBin");
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
static OicSecOxm_t gOicSecDoxmJustWorks = OIC_JUST_WORKS;
static OicSecDoxm_t gDefaultDoxm =
{
+ NULL, /* OicUrn_t *oxmType */
+ 0, /* size_t oxmTypeLen */
&gOicSecDoxmJustWorks, /* uint16_t *oxm */
1, /* size_t oxmLen */
OIC_JUST_WORKS, /* uint16_t oxmSel */
{
if (doxm)
{
+ //Clean oxmType
+ for (size_t i = 0; i < doxm->oxmTypeLen; i++)
+ {
+ OICFree(doxm->oxmType[i]);
+ }
+ OICFree(doxm->oxmType);
+
//clean oxm
OICFree(doxm->oxm);
}
}
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName)
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
{
if (NULL == doxm)
{
cJSON *jsonRoot = cJSON_CreateObject();
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonDoxm = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
- cJSON_AddItemToObject(jsonRoot, OIC_JSON_DOXM_NAME, jsonDoxm );
- }
- else
+ jsonDoxm = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
+ cJSON_AddItemToObject(jsonRoot, OIC_JSON_DOXM_NAME, jsonDoxm );
+
+ //OxmType -- Not Mandatory
+ if(doxm->oxmTypeLen > 0)
{
- jsonDoxm = jsonRoot;
+ cJSON *jsonOxmTyArray = cJSON_CreateArray();
+ VERIFY_NON_NULL(TAG, jsonOxmTyArray, ERROR);
+ cJSON_AddItemToObject (jsonDoxm, OIC_JSON_OXM_TYPE_NAME, jsonOxmTyArray );
+ for (size_t i = 0; i < doxm->oxmTypeLen; i++)
+ {
+ cJSON_AddItemToArray (jsonOxmTyArray, cJSON_CreateString(doxm->oxmType[i]));
+ }
}
//Oxm -- Not Mandatory
b64Ret = b64Encode(doxm->owner.id, sizeof(doxm->owner.id), base64Buff,
sizeof(base64Buff), &outLen);
VERIFY_SUCCESS(TAG, b64Ret == B64_OK, ERROR);
- cJSON_AddStringToObject(jsonDoxm, OIC_JSON_DEV_OWNER_NAME, base64Buff);
-
- outLen = 0;
- b64Ret = b64Encode(doxm->owner.id, sizeof(doxm->owner.id), base64Buff,
- sizeof(base64Buff), &outLen);
- VERIFY_SUCCESS(TAG, b64Ret == B64_OK, ERROR);
-
- //Rowner -- Mandatory
cJSON_AddStringToObject(jsonDoxm, OIC_JSON_OWNER_NAME, base64Buff);
jsonStr = cJSON_PrintUnformatted(jsonRoot);
return jsonStr;
}
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName)
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
{
if (NULL == jsonStr)
cJSON *jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonDoxm = cJSON_GetObjectItem(jsonRoot, OIC_JSON_DOXM_NAME);
- VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
- }
- else
- {
- jsonDoxm = jsonRoot;
- }
+ jsonDoxm = cJSON_GetObjectItem(jsonRoot, OIC_JSON_DOXM_NAME);
+ VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
doxm = (OicSecDoxm_t*)OICCalloc(1, sizeof(OicSecDoxm_t));
VERIFY_NON_NULL(TAG, doxm, ERROR);
+ //OxmType -- not Mandatory
+ jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_TYPE_NAME);
+ if ((jsonObj) && (cJSON_Array == jsonObj->type))
+ {
+ doxm->oxmTypeLen = cJSON_GetArraySize(jsonObj);
+ VERIFY_SUCCESS(TAG, doxm->oxmTypeLen > 0, ERROR);
+
+ doxm->oxmType = (OicUrn_t *)OICCalloc(doxm->oxmTypeLen, sizeof(char *));
+ VERIFY_NON_NULL(TAG, (doxm->oxmType), ERROR);
+
+ for (size_t i = 0; i < doxm->oxmTypeLen ; i++)
+ {
+ cJSON *jsonOxmTy = cJSON_GetArrayItem(jsonObj, i);
+ VERIFY_NON_NULL(TAG, jsonOxmTy, ERROR);
+
+ jsonObjLen = strlen(jsonOxmTy->valuestring) + 1;
+ doxm->oxmType[i] = (char*)OICMalloc(jsonObjLen);
+ VERIFY_NON_NULL(TAG, doxm->oxmType[i], ERROR);
+ strncpy((char *)doxm->oxmType[i], (char *)jsonOxmTy->valuestring, jsonObjLen);
+ }
+ }
+
//Oxm -- not Mandatory
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_NAME);
if (jsonObj && cJSON_Array == jsonObj->type)
}
//Owner -- will be empty when device status is unowned.
- jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_DEV_OWNER_NAME);
+ jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OWNER_NAME);
if(true == doxm->owned)
{
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
if (NULL != doxm)
{
// Convert Doxm data into JSON for update to persistent storage
- char *jsonStr = BinToDoxmJSON(doxm, true);
+ char *jsonStr = BinToDoxmJSON(doxm);
if (jsonStr)
{
cJSON *jsonDoxm = cJSON_Parse(jsonStr);
* return valid doxm resource json.
*/
- jsonStr = (ehRet == OC_EH_OK) ? BinToDoxmJSON(gDoxm, false) : NULL;
+ jsonStr = (ehRet == OC_EH_OK) ? BinToDoxmJSON(gDoxm) : NULL;
// Send response payload to request originator
if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, jsonStr))
* Convert JSON Doxm data into binary. This will also validate
* the Doxm data received.
*/
- OicSecDoxm_t* newDoxm = JSONToDoxmBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
+ OicSecDoxm_t* newDoxm = JSONToDoxmBin(((OCSecurityPayload*)ehRequest->payload)->securityData);
if (newDoxm)
{
if(jsonSVRDatabase)
{
//Convert JSON DOXM into binary format
- gDoxm = JSONToDoxmBin(jsonSVRDatabase, true);
+ gDoxm = JSONToDoxmBin(jsonSVRDatabase);
}
/*
* If SVR database in persistent storage got corrupted or
}
}
-char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName)
+char * BinToPstatJSON(const OicSecPstat_t * pstat)
{
if(NULL == pstat)
{
char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*) 0)->id)) + 1] = {};
uint32_t outLen = 0;
B64Result b64Ret = B64_OK;
- cJSON *jsonRoot = NULL;
- if(isIncResName)
- {
- jsonRoot = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonRoot, INFO);
- cJSON_AddItemToObject(jsonRoot, OIC_JSON_PSTAT_NAME, jsonPstat = cJSON_CreateObject());
- }
- else
- {
- jsonPstat = cJSON_CreateObject();
- jsonRoot = jsonPstat;
- }
- VERIFY_NON_NULL(TAG, jsonPstat, INFO);
+ cJSON *jsonRoot = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonRoot, INFO);
+ cJSON_AddItemToObject(jsonRoot, OIC_JSON_PSTAT_NAME, jsonPstat=cJSON_CreateObject());
cJSON_AddBoolToObject(jsonPstat, OIC_JSON_ISOP_NAME, pstat->isOp);
b64Ret = b64Encode(pstat->deviceID.id,
return jsonStr;
}
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName)
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr)
{
if(NULL == jsonStr)
{
cJSON *jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, INFO);
- if(isIncResName)
- {
- jsonPstat = cJSON_GetObjectItem(jsonRoot, OIC_JSON_PSTAT_NAME);
- }
- else
- {
- jsonPstat = jsonRoot;
- }
+ jsonPstat = cJSON_GetObjectItem(jsonRoot, OIC_JSON_PSTAT_NAME);
VERIFY_NON_NULL(TAG, jsonPstat, INFO);
pstat = (OicSecPstat_t*)OICCalloc(1, sizeof(OicSecPstat_t));
{
OC_LOG (INFO, TAG, "HandlePstatGetRequest processing GET request");
// Convert ACL data into JSON for transmission
- char* jsonStr = BinToPstatJSON(gPstat, false);
+ char* jsonStr = BinToPstatJSON(gPstat);
// A device should always have a default pstat. Therefore, jsonStr should never be NULL.
OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
{
postJson = cJSON_Parse(((OCSecurityPayload*)ehRequest->payload)->securityData);
VERIFY_NON_NULL(TAG, postJson, INFO);
-
- cJSON *commitHashJson = cJSON_GetObjectItem(postJson, OIC_JSON_COMMIT_HASH_NAME);
+ cJSON *jsonPstat = cJSON_GetObjectItem(postJson, OIC_JSON_PSTAT_NAME);
+ VERIFY_NON_NULL(TAG, jsonPstat, INFO);
+ cJSON *commitHashJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_COMMIT_HASH_NAME);
uint16_t commitHash = 0;
if (commitHashJson)
{
commitHash = commitHashJson->valueint;
}
- cJSON *tmJson = cJSON_GetObjectItem(postJson, OIC_JSON_TM_NAME);
+ cJSON *tmJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_TM_NAME);
if (tmJson && gPstat)
{
gPstat->tm = (OicSecDpm_t)tmJson->valueint;
OC_LOG (INFO, TAG, "CommitHash is not valid");
}
}
- cJSON *omJson = cJSON_GetObjectItem(postJson, OIC_JSON_OM_NAME);
+ cJSON *omJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_OM_NAME);
if (omJson && gPstat)
{
/*
}
}
// Convert pstat data into JSON for update to persistent storage
- char *jsonStr = BinToPstatJSON(gPstat, true);
+ char *jsonStr = BinToPstatJSON(gPstat);
if (jsonStr)
{
cJSON *jsonPstat = cJSON_Parse(jsonStr);
if (jsonSVRDatabase)
{
// Convert JSON Pstat into binary format
- gPstat = JSONToPstatBin(jsonSVRDatabase, true);
+ gPstat = JSONToPstatBin(jsonSVRDatabase);
}
/*
* If SVR database in persistent storage got corrupted or
const char * OIC_RSRC_SVC_URI = "/oic/sec/svc";
const char * OIC_JSON_SVC_NAME = "svc";
-const char * OIC_JSON_SUBJECT_NAME = "subject";
-const char * OIC_JSON_RESOURCES_NAME = "resources";
+
+const char * OIC_JSON_SUBJECT_NAME = "sub";
+const char * OIC_JSON_RESOURCES_NAME = "rsrc";
const char * OIC_JSON_AMSS_NAME = "amss";
-const char * OIC_JSON_PERMISSION_NAME = "permission";
-const char * OIC_JSON_OWNER_NAME = "rowner";
-const char * OIC_JSON_OWNERS_NAME = "rowners";
-const char * OIC_JSON_DEV_OWNER_NAME = "devowner";
+const char * OIC_JSON_PERMISSION_NAME = "perms";
+const char * OIC_JSON_OWNERS_NAME = "ownrs";
+const char * OIC_JSON_OWNER_NAME = "ownr";
const char * OIC_JSON_OWNED_NAME = "owned";
const char * OIC_JSON_OXM_NAME = "oxm";
+const char * OIC_JSON_OXM_TYPE_NAME = "oxmtype";
const char * OIC_JSON_OXM_SEL_NAME = "oxmsel";
-const char * OIC_JSON_DEVICE_ID_FORMAT_NAME = "didformat";
+const char * OIC_JSON_DEVICE_ID_FORMAT_NAME = "dvcidfrmt";
const char * OIC_JSON_ISOP_NAME = "isop";
const char * OIC_JSON_COMMIT_HASH_NAME = "ch";
const char * OIC_JSON_DEVICE_ID_NAME = "deviceid";
const char * OIC_JSON_OM_NAME = "om";
const char * OIC_JSON_SM_NAME = "sm";
const char * OIC_JSON_CREDID_NAME = "credid";
-const char * OIC_JSON_SUBJECTID_NAME = "subjectid";
+const char * OIC_JSON_SUBJECTID_NAME = "subid";
const char * OIC_JSON_ROLEIDS_NAME = "roleid";
-const char * OIC_JSON_CREDTYPE_NAME = "credtype";
-const char * OIC_JSON_PUBLICDATA_NAME = "publicdata";
-const char * OIC_JSON_PRIVATEDATA_NAME = "privatedata";
-const char * OIC_JSON_SERVICE_DEVICE_ID = "svcid";
+const char * OIC_JSON_CREDTYPE_NAME = "credtyp";
+const char * OIC_JSON_PUBLICDATA_NAME = "pbdata";
+const char * OIC_JSON_PRIVATEDATA_NAME = "pvdata";
+const char * OIC_JSON_SERVICE_DEVICE_ID = "svcdid";
const char * OIC_JSON_SERVICE_TYPE = "svct";
-const char * OIC_JSON_PERIOD_NAME = "period";
-const char * OIC_JSON_PERIODS_NAME = "periods";
-const char * OIC_JSON_RECURRENCES_NAME = "recurrence";
+const char * OIC_JSON_PERIOD_NAME = "prd";
+const char * OIC_JSON_PERIODS_NAME = "prds";
+const char * OIC_JSON_RECURRENCES_NAME = "recurs";
const char * OIC_JSON_SUPPORTED_CRED_TYPE_NAME = "sct";
OicUuid_t WILDCARD_SUBJECT_ID = {"*"};
* Note: Caller needs to invoke 'free' when finished done using
* return string.
*/
-char * BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName)
+char * BinToSvcJSON(const OicSecSvc_t * svc)
{
cJSON *jsonRoot = NULL;
char *jsonStr = NULL;
if (svc)
{
- cJSON *jsonSvcArray = NULL;
- if(isIncResName)
- {
- jsonRoot = cJSON_CreateObject();
- VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
+ jsonRoot = cJSON_CreateObject();
+ VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- cJSON_AddItemToObject (jsonRoot, OIC_JSON_SVC_NAME, jsonSvcArray = cJSON_CreateArray());
- }
- else
- {
- jsonSvcArray = cJSON_CreateArray();
- jsonRoot = jsonSvcArray;
- }
+ cJSON *jsonSvcArray = NULL;
+ cJSON_AddItemToObject (jsonRoot, OIC_JSON_SVC_NAME, jsonSvcArray = cJSON_CreateArray());
VERIFY_NON_NULL(TAG, jsonSvcArray, ERROR);
while(svc)
/*
* This internal method converts JSON SVC into binary SVC.
*/
-OicSecSvc_t * JSONToSvcBin(const char * jsonStr, const bool isIncResName)
+OicSecSvc_t * JSONToSvcBin(const char * jsonStr)
{
OCStackResult ret = OC_STACK_ERROR;
OicSecSvc_t * headSvc = NULL;
jsonRoot = cJSON_Parse(jsonStr);
VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
- if(isIncResName)
- {
- jsonSvcArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
- }
- else
- {
- jsonSvcArray = jsonRoot;
- }
+ jsonSvcArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
VERIFY_NON_NULL(TAG, jsonSvcArray, INFO);
if (cJSON_Array == jsonSvcArray->type)
static OCEntityHandlerResult HandleSVCGetRequest (const OCEntityHandlerRequest * ehRequest)
{
// Convert SVC data into JSON for transmission
- char* jsonStr = BinToSvcJSON(gSvc, false);
+ char* jsonStr = BinToSvcJSON(gSvc);
OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
OCEntityHandlerResult ehRet = OC_EH_ERROR;
// Convert JSON SVC data into binary. This will also validate the SVC data received.
- OicSecSvc_t* newSvc = JSONToSvcBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
+ OicSecSvc_t* newSvc = JSONToSvcBin(((OCSecurityPayload*)ehRequest->payload)->securityData);
if (newSvc)
{
LL_APPEND(gSvc, newSvc);
// Convert SVC data into JSON for update to persistent storage
- char *jsonStr = BinToSvcJSON(gSvc, true);
+ char *jsonStr = BinToSvcJSON(gSvc);
if (jsonStr)
{
cJSON *jsonSvc = cJSON_Parse(jsonStr);
if (jsonSVRDatabase)
{
// Convert JSON SVC into binary format
- gSvc = JSONToSvcBin(jsonSVRDatabase, true);
+ gSvc = JSONToSvcBin(jsonSVRDatabase);
OICFree(jsonSVRDatabase);
}
srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
unittest_src_dir + 'oic_unittest_acl1.json'))
srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
- unittest_src_dir + 'oic_unittest_acl_payload.json'))
-srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
unittest_src_dir + 'oic_unittest_default_acl.json'))
env.AppendTarget('test')
extern "C" {
#endif
-extern char * BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName);
-extern OicSecAcl_t * JSONToAclBin(const char * jsonStr, const bool isIncResName);
+extern char * BinToAclJSON(const OicSecAcl_t * acl);
+extern OicSecAcl_t * JSONToAclBin(const char * jsonStr);
extern void DeleteACLList(OicSecAcl_t* acl);
OCStackResult GetDefaultACL(OicSecAcl_t** defaultAcl);
OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag,
const char* JSON_FILE_NAME = "oic_unittest.json";
const char* DEFAULT_ACL_JSON_FILE_NAME = "oic_unittest_default_acl.json";
const char* ACL1_JSON_FILE_NAME = "oic_unittest_acl1.json";
-const char* ACL_JSON_PAYLOAD_FILE_NAME = "oic_unittest_acl_payload.json";
-
#define NUM_ACE_FOR_WILDCARD_IN_ACL1_JSON (2)
}
jsonStr1[len + 1] = 0;
- OicSecAcl_t * acl = JSONToAclBin(jsonStr1, true);
+ OicSecAcl_t * acl = JSONToAclBin(jsonStr1);
EXPECT_TRUE(NULL != acl);
- char * jsonStr2 = BinToAclJSON(acl, true);
+ char * jsonStr2 = BinToAclJSON(acl);
EXPECT_TRUE(NULL != jsonStr2);
EXPECT_STREQ(jsonStr1, jsonStr2);
char *jsonStr = ReadFile(DEFAULT_ACL_JSON_FILE_NAME);
if (jsonStr)
{
- OicSecAcl_t * acl = JSONToAclBin(jsonStr, true);
+ OicSecAcl_t * acl = JSONToAclBin(jsonStr);
EXPECT_TRUE(NULL != acl);
// Invoke API to generate default ACL
OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
// Read an ACL from the file
- char *jsonStr = ReadFile(ACL_JSON_PAYLOAD_FILE_NAME);
+ char *jsonStr = ReadFile(ACL1_JSON_FILE_NAME);
if (jsonStr)
{
static OCPersistentStorage ps = OCPersistentStorage();
EXPECT_TRUE(OC_EH_ERROR == ehRet);
// Convert JSON into OicSecAcl_t for verification
- OicSecAcl_t * acl = JSONToAclBin(jsonStr, false);
+ OicSecAcl_t * acl = JSONToAclBin(jsonStr);
EXPECT_TRUE(NULL != acl);
// Verify if SRM contains ACL for the subject
extern OicSecAcl_t *gAcl;
// Read an ACL from the file
- char *jsonStr = ReadFile(ACL_JSON_PAYLOAD_FILE_NAME);
+ char *jsonStr = ReadFile(ACL1_JSON_FILE_NAME);
if (jsonStr)
{
- gAcl = JSONToAclBin(jsonStr, false);
+ gAcl = JSONToAclBin(jsonStr);
EXPECT_TRUE(NULL != gAcl);
// Verify that ACL file contains 2 ACE entries for 'WILDCARD' subject
VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 1)), ERROR);
//GET json POST payload
- jsonStr = BinToAclJSON(&acl, false);
+ jsonStr = BinToAclJSON(&acl);
VERIFY_NON_NULL(TAG, jsonStr, ERROR);
// Create Entity Handler POST request payload
VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 2)), ERROR);
//GET json POST payload
- jsonStr = BinToAclJSON(&acl, false);
+ jsonStr = BinToAclJSON(&acl);
VERIFY_NON_NULL(TAG, jsonStr, ERROR);
// Create Entity Handler POST request payload
ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq);
EXPECT_TRUE(OC_EH_ERROR == ehRet);
+ // Verify if SRM contains ACL for the subject but only with one resource
+ savePtr = NULL;
+ subjectAcl2 = GetACLResourceData(&acl.subject, &savePtr);
+ EXPECT_TRUE(NULL != subjectAcl2);
+ EXPECT_TRUE(subjectAcl2->resourcesLen == 1);
+
exit:
// Perform cleanup
if(NULL != subjectAcl1)
VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 1)), ERROR);
//GET json POST payload
- jsonStr = BinToAclJSON(&acl, false);
+ jsonStr = BinToAclJSON(&acl);
VERIFY_NON_NULL(TAG, jsonStr, ERROR);
//Create Entity Handler POST request payload
OCStackResult CreateCredResource();
OCEntityHandlerResult CredEntityHandler (OCEntityHandlerFlag flag,
OCEntityHandlerRequest * ehRequest);
-char * BinToCredJSON(const OicSecCred_t * pstat, const bool isIncResName);
-OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName);
+char * BinToCredJSON(const OicSecCred_t * pstat);
+OicSecCred_t * JSONToCredBin(const char * jsonStr);
void InitSecCredInstance(OicSecCred_t * cred);
void DeleteCredList(OicSecCred_t* cred);
const OicSecCred_t* GetCredResourceData(const OicUuid_t* subject);
OicSecCred_t *cred = getCredList();
VERIFY_NON_NULL(TAG, cred, ERROR);
- jsonStr = BinToCredJSON(cred, false);
+ jsonStr = BinToCredJSON(cred);
VERIFY_NON_NULL(TAG, jsonStr, ERROR);
// Create Entity Handler POST request payload
//BinToCredJSON Tests
TEST(BinToCredJSONTest, BinToCredJSONNullCred)
{
- char* value = BinToCredJSON(NULL, true);
+ char* value = BinToCredJSON(NULL);
EXPECT_TRUE(value == NULL);
}
char* json = NULL;
OicSecCred_t * cred = getCredList();
- json = BinToCredJSON(cred, true);
+ json = BinToCredJSON(cred);
OC_LOG_V(INFO, TAG, "BinToCredJSON:%s\n", json);
EXPECT_TRUE(json != NULL);
TEST(JSONToCredBinTest, JSONToCredBinValidJSON)
{
OicSecCred_t* cred1 = getCredList();
- char* json = BinToCredJSON(cred1, true);
+ char* json = BinToCredJSON(cred1);
EXPECT_TRUE(json != NULL);
- OicSecCred_t *cred2 = JSONToCredBin(json, true);
+ OicSecCred_t *cred2 = JSONToCredBin(json);
EXPECT_TRUE(cred2 != NULL);
DeleteCredList(cred1);
DeleteCredList(cred2);
TEST(JSONToCredBinTest, JSONToCredBinNullJSON)
{
- OicSecCred_t *cred = JSONToCredBin(NULL, true);
+ OicSecCred_t *cred = JSONToCredBin(NULL);
EXPECT_TRUE(cred == NULL);
}
OCStackResult CreateDoxmResource();
OCEntityHandlerResult DoxmEntityHandler (OCEntityHandlerFlag flag,
OCEntityHandlerRequest * ehRequest);
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName);
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName);
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm);
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr);
void InitSecDoxmInstance(OicSecDoxm_t * doxm);
OCEntityHandlerResult HandleDoxmPostRequest (const OCEntityHandlerRequest * ehRequest);
void DeleteDoxmBinData(OicSecDoxm_t* doxm);
{
return NULL;
}
- doxm->oxmLen = 1;
+ doxm->oxmTypeLen = 1;
+ doxm->oxmType = (OicUrn_t *)OICCalloc(doxm->oxmTypeLen, sizeof(char *));
+ if(!doxm->oxmType)
+ {
+ OICFree(doxm);
+ return NULL;
+ }
+ doxm->oxmType[0] = (char*)OICMalloc(strlen(OXM_JUST_WORKS) + 1);
+ if(!doxm->oxmType[0])
+ {
+ OICFree(doxm->oxmType);
+ OICFree(doxm);
+ return NULL;
+ }
+
+ strcpy(doxm->oxmType[0], OXM_JUST_WORKS);
+ doxm->oxmLen = 1;
doxm->oxm = (OicSecOxm_t *)OICCalloc(doxm->oxmLen, sizeof(OicSecOxm_t));
if(!doxm->oxm)
{
+ OICFree(doxm->oxmType[0]);
+ OICFree(doxm->oxmType);
OICFree(doxm);
return NULL;
}
//BinToDoxmJSON Tests
TEST(BinToDoxmJSONTest, BinToDoxmJSONNullDoxm)
{
- char* value = BinToDoxmJSON(NULL, true);
+ char* value = BinToDoxmJSON(NULL);
EXPECT_TRUE(value == NULL);
}
{
OicSecDoxm_t * doxm = getBinDoxm();
- char * json = BinToDoxmJSON(doxm, true);
+ char * json = BinToDoxmJSON(doxm);
OC_LOG_V(INFO, TAG, "BinToDoxmJSON:%s", json);
EXPECT_TRUE(json != NULL);
TEST(JSONToDoxmBinTest, JSONToDoxmBinValidJSON)
{
OicSecDoxm_t * doxm1 = getBinDoxm();
- char * json = BinToDoxmJSON(doxm1, true);
+ char * json = BinToDoxmJSON(doxm1);
EXPECT_TRUE(json != NULL);
- OicSecDoxm_t *doxm2 = JSONToDoxmBin(json, true);
+ OicSecDoxm_t *doxm2 = JSONToDoxmBin(json);
EXPECT_TRUE(doxm2 != NULL);
DeleteDoxmBinData(doxm1);
TEST(JSONToDoxmBinTest, JSONToDoxmBinNullJSON)
{
- OicSecDoxm_t *doxm = JSONToDoxmBin(NULL, true);
+ OicSecDoxm_t *doxm = JSONToDoxmBin(NULL);
EXPECT_TRUE(doxm == NULL);
}
svRequest.addressInfo.IP.port = 2345;
svRequest.connectivityType = CA_ETHERNET;
- ehRequest.reqJSONPayload = (unsigned char *) BinToDoxmJSON(doxm, true);
+ ehRequest.reqJSONPayload = (unsigned char *) BinToDoxmJSON(doxm);
ehRequest.requestHandle = (OCRequestHandle) &svRequest;
EXPECT_EQ(OC_EH_ERROR, HandleDoxmPostRequest(&ehRequest));
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
}
{
"acl": [
{
- "subject": "MTExMTExMTExMTExMTExMQ==",
- "resources": [
+ "sub": "MTExMTExMTExMTExMTExMQ==",
+ "rsrc": [
"/oic/light",
"/oic/fan"
],
- "permission": 255,
- "rowners" : [
+ "perms": 255,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "subject": "MzMzMzMzMzMzMzMzMzMzMw==",
- "resources": [
+ "sub": "MzMzMzMzMzMzMzMzMzMzMw==",
+ "rsrc": [
"/oic/light",
"/oic/garage"
],
- "permission": 255,
- "rowners" : [
+ "perms": 255,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg==",
"NDQ0NDQ0NDQ0NDQ0NDQ0NA=="
]
"amacl": [
{
- "resources": ["/a/led", "/a/fan"],
+ "rsrc": ["/a/led", "/a/fan"],
"amss": [
"NTU1NTU1NTU1NTU1NTU1NQ==",
"NjY2NjY2NjY2NjY2NjY2Ng=="
],
- "rowners" : [
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "resources": ["/b/led", "/b/fan"],
+ "rsrc": ["/b/led", "/b/fan"],
"amss": [
"NTU1NTU1NTU1NTU1NTU1NQ==",
"NjY2NjY2NjY2NjY2NjY2Ng=="
],
- "rowners" : [
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
}
"svc": [
{
- "svcid": "NTU1NTU1NTU1NTU1NTU1NQ==",
+ "svcdid": "NTU1NTU1NTU1NTU1NTU1NQ==",
"svct": 1,
- "rowners" : [
+ "ownrs" : [
"OTk5OTk5OTk5OTk5OTk5OQ=="
]
},
{
- "svcid": "NjY2NjY2NjY2NjY2NjY2Ng==",
+ "svcdid": "NjY2NjY2NjY2NjY2NjY2Ng==",
"svct": 1,
- "rowners" : [
+ "ownrs" : [
"OTk5OTk5OTk5OTk5OTk5OQ=="
]
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/ad",
"/oic/sec/acl"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 6,
- "rowners" : [
+ "perms": 6,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "subject": "MTExMTExMTExMTExMTExMQ==",
- "resources": [
+ "sub": "MTExMTExMTExMTExMTExMQ==",
+ "rsrc": [
"/oic/light",
"/oic/fan"
],
- "permission": 255,
- "rowners" : [
+ "perms": 255,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
},
{
- "subject": "MzMzMzMzMzMzMzMzMzMzMw==",
- "resources": [
+ "sub": "MzMzMzMzMzMzMzMzMzMzMw==",
+ "rsrc": [
"/oic/light",
"/oic/garage"
],
- "permission": 255,
- "rowners" : [
+ "perms": 255,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg==",
"NDQ0NDQ0NDQ0NDQ0NDQ0NA=="
]
+++ /dev/null
-[
- {
- "subject": "Kg==",
- "resources": [
- "/oic/res",
- "/oic/d",
- "/oic/p",
- "/oic/res/types/d",
- "/oic/ad",
- "/oic/sec/acl"
- ],
- "permission": 2,
- "rowners" : [
- "MjIyMjIyMjIyMjIyMjIyMg=="
- ]
- },
- {
- "subject": "Kg==",
- "resources": [
- "/oic/sec/doxm",
- "/oic/sec/pstat"
- ],
- "permission": 6,
- "rowners" : [
- "MjIyMjIyMjIyMjIyMjIyMg=="
- ]
- },
- {
- "subject": "MTExMTExMTExMTExMTExMQ==",
- "resources": [
- "/oic/light",
- "/oic/fan"
- ],
- "permission": 255,
- "rowners" : [
- "MjIyMjIyMjIyMjIyMjIyMg=="
- ]
- },
- {
- "subject": "MzMzMzMzMzMzMzMzMzMzMw==",
- "resources": [
- "/oic/light",
- "/oic/garage"
- ],
- "permission": 255,
- "rowners" : [
- "MjIyMjIyMjIyMjIyMjIyMg==",
- "NDQ0NDQ0NDQ0NDQ0NDQ0NA=="
- ]
- }
-]
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : [
+ "perms": 2,
+ "ownrs" : [
"MjIyMjIyMjIyMjIyMjIyMg=="
]
}
OCStackResult CreatePstatResource();
OCEntityHandlerResult PstatEntityHandler (OCEntityHandlerFlag flag,
OCEntityHandlerRequest * ehRequest);
-char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName);
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName);
+char * BinToPstatJSON(const OicSecPstat_t * pstat);
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr);
const char* UNIT_TEST_JSON_FILE_NAME = "oic_unittest.json";
#ifdef __cplusplus
}
//BinToJSON Tests
TEST(BinToJSONTest, BinToNullJSON)
{
- char* value = BinToPstatJSON(NULL, true);
+ char* value = BinToPstatJSON(NULL);
EXPECT_TRUE(value == NULL);
}
TEST(JSONToBinTest, NullJSONToBin)
{
- OicSecPstat_t *pstat1 = JSONToPstatBin(NULL, true);
+ OicSecPstat_t *pstat1 = JSONToPstatBin(NULL);
EXPECT_TRUE(pstat1 == NULL);
}
}
pstat.sm[0] = SINGLE_SERVICE_CLIENT_DRIVEN;
pstat.sm[1] = SINGLE_SERVICE_SERVER_DRIVEN;
- char* jsonPstat = BinToPstatJSON(&pstat, true);
+ char* jsonPstat = BinToPstatJSON(&pstat);
if(!jsonPstat)
{
OICFree(pstat.sm);
}
printf("BinToJSON Dump:\n%s\n\n", jsonPstat);
EXPECT_TRUE(jsonPstat != NULL);
- OicSecPstat_t *pstat1 = JSONToPstatBin(jsonPstat, true);
+ OicSecPstat_t *pstat1 = JSONToPstatBin(jsonPstat);
EXPECT_TRUE(pstat1 != NULL);
if(pstat1)
{
}
jsonStr1[len + 1] = 0;
- OicSecPstat_t* pstat = JSONToPstatBin(jsonStr1, true);
+ OicSecPstat_t* pstat = JSONToPstatBin(jsonStr1);
EXPECT_TRUE(NULL != pstat);
- char* jsonStr2 = BinToPstatJSON(pstat, true);
+ char* jsonStr2 = BinToPstatJSON(pstat);
EXPECT_STRNE(jsonStr1, jsonStr2);
OICFree(jsonStr1);
#ifdef __cplusplus
extern "C" {
#endif
-extern char * BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName);
-extern OicSecSvc_t * JSONToSvcBin(const char * jsonStr, const bool isIncResName);
+extern char * BinToSvcJSON(const OicSecSvc_t * svc);
+extern OicSecSvc_t * JSONToSvcBin(const char * jsonStr);
extern void DeleteSVCList(OicSecSvc_t* svc);
#ifdef __cplusplus
}
char *jsonStr1 = ReadFile(JSON_FILE_NAME);
if (jsonStr1)
{
- OicSecSvc_t * svc = JSONToSvcBin(jsonStr1, true);
+ OicSecSvc_t * svc = JSONToSvcBin(jsonStr1);
EXPECT_TRUE(NULL != svc);
int cnt = 0;
}
EXPECT_EQ(cnt, NUM_SVC_IN_JSON_DB);
- char * jsonStr2 = BinToSvcJSON(svc, true);
+ char * jsonStr2 = BinToSvcJSON(svc);
EXPECT_TRUE(NULL != jsonStr2);
OICFree(jsonStr1);
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/sec/acl",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 2,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 2,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
},
{
- "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
- "resources": ["/oic/sec/acl",
+ "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
+ "rsrc": ["/oic/sec/acl",
"/oic/sec/cred"],
- "permission": 8,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "perms": 8,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
- "subject": "NDQ0NDMzMzMyMjIyMTExMQ==",
- "resources": ["/a/led"],
- "permission": 6,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "NDQ0NDMzMzMyMjIyMTExMQ==",
+ "rsrc": ["/a/led"],
+ "perms": 6,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "MTkxOTE5MTkxOTE5MTkxOQ==",
- "devowner": "YWRtaW5EZXZpY2VVVUlEAA=="
+ "ownr": "YWRtaW5EZXZpY2VVVUlEAA=="
},
"cred": [{
"credid": 1,
- "subjectid": "MTExMTExMTExMTExMTExMQ==",
- "credtype": 1,
- "privatedata": "QkJCQkJCQkJCQkJCQkJCQg==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MTExMTExMTExMTExMTExMQ==",
+ "credtyp": 1,
+ "pvdata": "QkJCQkJCQkJCQkJCQkJCQg==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}]
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/sec/acl",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "perms": 2,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "perms": 2,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "MjIyMjIyMjIyMjIyMjIyMg==",
- "devowner": "MjIyMjIyMjIyMjIyMjIyMg=="
+ "ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
},
"cred": [{
"credid": 1,
- "subjectid": "MTExMTExMTExMTExMTExMQ==",
- "credtype": 1,
- "period": "20150630T060000/20990920T220000",
- "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MTExMTExMTExMTExMTExMQ==",
+ "credtyp": 1,
+ "prd": "20150630T060000/20990920T220000",
+ "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}]
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/sec/acl",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 2,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
+ "perms": 2,
+ "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
},
{
- "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
- "resources": ["/oic/sec/acl",
+ "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
+ "rsrc": ["/oic/sec/acl",
"/oic/sec/cred"],
- "permission": 8,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "perms": 8,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
- "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
- "resources": ["/a/led"],
- "permission": 6,
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
+ "rsrc": ["/a/led"],
+ "perms": 6,
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
- "subject": "MTExMTIyMjIzMzMzNDQ0NA==",
- "resources": ["/a/led"],
- "permission": 6,
- "periods" : ["20150630T060000/20150630T220000", "20150630T060000/20150630T200000"],
- "recurrence" : ["FREQ=DAILY; BYDAY=MO, WE, FR", "FREQ=DAILY; BYDAY=TU, TH; UNTIL=20160630"],
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MTExMTIyMjIzMzMzNDQ0NA==",
+ "rsrc": ["/a/led"],
+ "perms": 6,
+ "prds" : ["20150630T060000/20150630T220000", "20150630T060000/20150630T200000"],
+ "recurs" : ["FREQ=DAILY; BYDAY=MO, WE, FR", "FREQ=DAILY; BYDAY=TU, TH; UNTIL=20160630"],
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
- "subject": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
- "resources": ["/a/led"],
- "permission": 6,
- "periods" : ["20150630T060000/20150630T220000"],
- "recurrence" : ["FREQ=DAILY; UNTIL=20150630"],
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
+ "rsrc": ["/a/led"],
+ "perms": 6,
+ "prds" : ["20150630T060000/20150630T220000"],
+ "recurs" : ["FREQ=DAILY; UNTIL=20150630"],
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}
],
"amacl": [{
- "resources" : ["/a/led"],
+ "rsrc" : ["/a/led"],
"amss" : ["MTkxOTE5MTkxOTE5MTkxOQ=="],
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}],
"pstat": {
"isop": true,
"sct": 1,
"owned": true,
"deviceid": "MTExMTExMTExMTExMTExMQ==",
- "devowner": "YWRtaW5EZXZpY2VVVUlEAA=="
+ "ownr": "YWRtaW5EZXZpY2VVVUlEAA=="
},
"cred": [{
"credid": 1,
- "subjectid": "MjIyMjIyMjIyMjIyMjIyMg==",
- "credtype": 1,
- "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
+ "credtyp": 1,
+ "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
"credid": 2,
- "subjectid": "MTExMTIyMjIzMzMzNDQ0NA==",
- "credtype": 1,
- "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MTExMTIyMjIzMzMzNDQ0NA==",
+ "credtyp": 1,
+ "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
"credid": 3,
- "subjectid": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
- "credtype": 1,
- "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
+ "credtyp": 1,
+ "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
"credid": 4,
- "subjectid": "NDQ0NDMzMzMyMjIyMTExMQ==",
- "credtype": 1,
- "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "NDQ0NDMzMzMyMjIyMTExMQ==",
+ "credtyp": 1,
+ "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
},
{
"credid": 5,
- "subjectid": "MTkxOTE5MTkxOTE5MTkxOQ==",
- "credtype": 1,
- "privatedata": "QkJCQkJCQkJCQkJCQkJCQg==",
- "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+ "sub": "MTkxOTE5MTkxOTE5MTkxOQ==",
+ "credtyp": 1,
+ "pvdata": "QkJCQkJCQkJCQkJCQkJCQg==",
+ "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
}]
}
{
"acl": [
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
"/oic/ad",
"/oic/sec/amacl"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
},
{
- "subject": "Kg==",
- "resources": [
+ "sub": "Kg==",
+ "rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat"
],
- "permission": 2,
- "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+ "perms": 2,
+ "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
}
],
"pstat": {
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlEMA==",
- "devowner": "YWRtaW5EZXZpY2VVVUlEMA=="
+ "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
}
}