Commit 4072ddde authored by Dmitriy Zhuravlev's avatar Dmitriy Zhuravlev

Revert "Update secure resource related modules(SRM,OTM,SRP,CKM,unit...

Revert "Update secure resource related modules(SRM,OTM,SRP,CKM,unit tests,samples) according to spec B."

Roll back the JSON changes for waiting until the Security Spec JSON definitions are released.

This reverts commit b578b610.

Change-Id: I8c520b0a99ca2dbae6c3e44ff93f5221288a4188
Signed-off-by: default avatarDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4797Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Nathan Heldt-Sheller's avatarNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Reviewed-by: default avatarChul Lee <chuls.lee@samsung.com>
parent 296901f0
......@@ -57,11 +57,10 @@ const OicSecAcl_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAcl_t **
* 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);
/**
......@@ -75,11 +74,10 @@ void DeleteACLList(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
......
......@@ -67,11 +67,10 @@ OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
* 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
}
......
......@@ -65,13 +65,12 @@ const OicSecCred_t* GetCredResourceData(const OicUuid_t* subjectId);
* 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.
......
......@@ -51,16 +51,16 @@ char* GetBase64CRL();
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.
......
......@@ -54,13 +54,12 @@ const OicSecDoxm_t* GetDoxmResourceData();
* 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.
......@@ -68,13 +67,12 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName);
* 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.
......
......@@ -43,19 +43,17 @@ OCStackResult DeInitPstatResource();
* 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.
*
......
......@@ -68,14 +68,12 @@ extern const char * OIC_JSON_AMSS_NAME;
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;
......
......@@ -44,11 +44,10 @@ void DeInitSVCResource();
* 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
}
......
......@@ -369,6 +369,8 @@ struct OicSecCred
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=="
]
}
......@@ -31,7 +31,7 @@
"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=="
]
}
......@@ -31,7 +31,7 @@
"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": {
......@@ -39,6 +39,6 @@
"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": {
......@@ -43,6 +43,6 @@
"oxmsel": 0,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlE",
"devowner": "YWRtaW5EZXZpY2VVVUlE"
"ownr": "YWRtaW5EZXZpY2VVVUlE"
}
}
{
"acl": [
{
"subject": "Kg==",
"resources": [
"sub": "Kg==",
"rsrc": [
"/oic/res",
"/oic/d",
"/oic/p",
......@@ -10,17 +10,17 @@
"/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": {
......@@ -38,6 +38,6 @@
"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": {
......@@ -39,6 +39,6 @@
"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=="
]
}
......@@ -30,7 +30,7 @@
"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=="
]
}
......@@ -30,7 +30,7 @@
"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",
......@@ -12,17 +12,17 @@
"/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": {
......
......@@ -515,7 +515,7 @@ static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
}
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");
......@@ -881,7 +881,7 @@ static OCStackResult PutUpdateOperationMode(OTMContext_t* otmCtx,
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);
......@@ -1120,7 +1120,7 @@ static OCStackApplicationResult ProvisionDefaultACLCB(void *ctx, OCDoHandle UNUS
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);
......@@ -1223,7 +1223,7 @@ OCStackResult FinalizeProvisioning(OTMContext_t* otmCtx)
return OC_STACK_NO_MEMORY;
}
secPayload->base.type = PAYLOAD_TYPE_SECURITY;
secPayload->securityData = BinToAclJSON(&defaultAcl, false);