Revert "Update secure resource related modules(SRM,OTM,SRP,CKM,unit tests,samples...
authorDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Wed, 13 Jan 2016 09:18:20 +0000 (09:18 +0000)
committerDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Thu, 14 Jan 2016 07:25:19 +0000 (07:25 +0000)
Roll back the JSON changes for waiting until the Security Spec JSON definitions are released.

This reverts commit b578b61090303a71ae07126107c40c18238a02cd.

Change-Id: I8c520b0a99ca2dbae6c3e44ff93f5221288a4188
Signed-off-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4797
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
47 files changed:
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/amaclresource.h [changed mode: 0644->0755]
resource/csdk/security/include/internal/credresource.h
resource/csdk/security/include/internal/crlresource.h
resource/csdk/security/include/internal/doxmresource.h
resource/csdk/security/include/internal/pstatresource.h
resource/csdk/security/include/internal/srmresourcestrings.h [changed mode: 0644->0755]
resource/csdk/security/include/internal/svcresource.h
resource/csdk/security/include/securevirtualresourcetypes.h [changed mode: 0644->0755]
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_pt.json
resource/csdk/security/provisioning/ck_manager/unittest/test_data/CKMInfo.json
resource/csdk/security/provisioning/sample/oic_svr_db_client.json
resource/csdk/security/provisioning/sample/oic_svr_db_prov_tool.json [changed mode: 0644->0755]
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.json [changed mode: 0644->0755]
resource/csdk/security/provisioning/sample/oic_svr_db_unowned_server.json
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/oxmjustworks.c
resource/csdk/security/provisioning/src/oxmrandompin.c
resource/csdk/security/provisioning/src/pmutility.c [changed mode: 0644->0755]
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/amsmgr.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/crlresource.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/srmresourcestrings.c [changed mode: 0644->0755]
resource/csdk/security/src/svcresource.c
resource/csdk/security/unittest/SConscript
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/csdk/security/unittest/doxmresource.cpp
resource/csdk/security/unittest/oic_svr_db.json
resource/csdk/security/unittest/oic_unittest.json
resource/csdk/security/unittest/oic_unittest_acl1.json
resource/csdk/security/unittest/oic_unittest_acl_payload.json [deleted file]
resource/csdk/security/unittest/oic_unittest_default_acl.json
resource/csdk/security/unittest/pstatresource.cpp
resource/csdk/security/unittest/svcresourcetest.cpp
resource/csdk/stack/samples/linux/secure/oic_amss_db.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_client.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_server.json
resource/provisioning/examples/oic_svr_db_client.json

index 600b1f4..564d23f 100644 (file)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 1672f9e..9c37a0e
@@ -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
 }
index 06636c8..74ea373 100644 (file)
@@ -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.
index fbe8086..75178d8 100644 (file)
@@ -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.
index b5b62e1..e0f2fc9 100644 (file)
@@ -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.
index d4b719f..40c41ab 100644 (file)
@@ -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.
  *
old mode 100644 (file)
new mode 100755 (executable)
index e263bd7..1ac3fb0
@@ -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;
index 9afabfd..9db42c5 100644 (file)
@@ -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
 }
old mode 100644 (file)
new mode 100755 (executable)
index 6896ce7..83dc60f
@@ -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
index 5d127e5..8bcb39f 100644 (file)
@@ -1,29 +1,29 @@
 {
     "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,
index a4836b6..048384b 100644 (file)
@@ -1,29 +1,29 @@
 {
     "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,
index f63bca6..dd5dec4 100644 (file)
@@ -1,27 +1,27 @@
 {
     "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=="
        }
 }
index 8e05fdd..d036473 100644 (file)
@@ -1,27 +1,27 @@
 {
     "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"
     }
 }
index 9bec918..1219d6a 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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":        {
@@ -38,6 +38,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlEMA==",
-               "devowner":     "YWRtaW5EZXZpY2VVVUlEMA=="
+               "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
        }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 8282e63..7172a01
@@ -1,27 +1,27 @@
 {
     "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"
        }
 }
index aef44d3..bde9010 100644 (file)
@@ -1,28 +1,28 @@
 {
     "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,
old mode 100644 (file)
new mode 100755 (executable)
index 62a27b2..a79a2b2
@@ -1,28 +1,28 @@
 {
     "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,
index 42d37c4..fa804dd 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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":        {
index 8c0407d..7adeb46 100644 (file)
@@ -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);
+    secPayload->securityData = BinToAclJSON(&defaultAcl);
     OICFree(defaultAcl.owners);
     if(!secPayload->securityData)
     {
index 5968ed9..7a0d561 100644 (file)
@@ -40,7 +40,7 @@ char* CreateJustWorksSelectOxmPayload(OTMContext_t* otmCtx)
     }
 
     otmCtx->selectedDeviceInfo->doxm->oxmSel = OIC_JUST_WORKS;
-    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
+    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
 }
 
 char* CreateJustWorksOwnerTransferPayload(OTMContext_t* otmCtx)
@@ -60,7 +60,7 @@ 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)
index d521631..8e9ad1e 100644 (file)
@@ -55,7 +55,7 @@ char* CreatePinBasedSelectOxmPayload(OTMContext_t* otmCtx)
     }
     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)
@@ -75,7 +75,7 @@ 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)
old mode 100644 (file)
new mode 100755 (executable)
index b496c6c..60daa64
@@ -33,7 +33,6 @@
 #include "cJSON.h"
 #include "utlist.h"
 #include "ocpayload.h"
-#include "payload_logging.h"
 
 #include "securevirtualresourcetypes.h"
 #include "srmresourcestrings.h" //@note: SRM's internal header
@@ -207,6 +206,7 @@ OCProvisionDev_t* PMCloneOCProvisionDev(const OCProvisionDev_t* src)
 
         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;
     }
 
@@ -411,8 +411,6 @@ static OCStackApplicationResult SecurePortDiscoveryHandler(void *ctx, OCDoHandle
         }
         else
         {
-            OC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
-
             if (PAYLOAD_TYPE_DISCOVERY != clientResponse->payload->type)
             {
                 OC_LOG(INFO, TAG, "Wrong payload type");
@@ -486,15 +484,13 @@ static OCStackApplicationResult DeviceDiscoveryHandler(void *ctx, OCDoHandle UNU
         }
         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");
index 20857c8..e7c12fb 100644 (file)
@@ -289,7 +289,7 @@ static OCStackResult provisionCredentials(const OicSecCred_t *cred,
         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);
@@ -441,7 +441,7 @@ OCStackResult SRPProvisionCRL(void *ctx, const OCProvisionDev_t *selectedDeviceI
     }
 
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-    secPayload->securityData = BinToCrlJSON(crl, false);
+    secPayload->securityData = BinToCrlJSON(crl);
     if (NULL == secPayload->securityData)
     {
         OICFree(secPayload);
@@ -527,7 +527,7 @@ static OCStackResult provisionCertCred(const OicSecCred_t *cred,
         return OC_STACK_NO_MEMORY;
     }
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-    secPayload->securityData = BinToCredJSON(cred, false);
+    secPayload->securityData = BinToCredJSON(cred);
 
     if (NULL == secPayload->securityData)
     {
@@ -834,7 +834,7 @@ OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceI
         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);
index 19e0e00..6d20938 100644 (file)
@@ -112,25 +112,18 @@ void DeleteACLList(OicSecAcl_t* acl)
  * 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)
@@ -231,7 +224,7 @@ exit:
 /*
  * 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;
@@ -244,14 +237,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr, const bool isIncResName)
     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)
@@ -422,7 +408,7 @@ exit:
 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);
@@ -646,7 +632,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
                              0 == strcmp(WILDCARD_RESOURCE_URI, currentAce->resources[n])))
                     {
                         // Convert ACL data into JSON for transmission
-                        jsonStr = BinToAclJSON(currentAce, false);
+                        jsonStr = BinToAclJSON(currentAce);
                         goto exit;
                     }
                 }
@@ -654,7 +640,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
             else
             {
                 // Convert ACL data into JSON for transmission
-                jsonStr = BinToAclJSON(currentAce, false);
+                jsonStr = BinToAclJSON(currentAce);
                 goto exit;
             }
         }
@@ -662,7 +648,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
     else
     {
         // Convert ACL data into JSON for transmission
-        jsonStr = BinToAclJSON(gAcl, false);
+        jsonStr = BinToAclJSON(gAcl);
     }
 
 exit:
@@ -682,7 +668,7 @@ static OCEntityHandlerResult HandleACLPostRequest (const OCEntityHandlerRequest
     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)
     {
@@ -899,7 +885,7 @@ OCStackResult InitACLResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON ACL into binary format
-        gAcl = JSONToAclBin(jsonSVRDatabase, true);
+        gAcl = JSONToAclBin(jsonSVRDatabase);
         OICFree(jsonSVRDatabase);
     }
     /*
@@ -1000,12 +986,12 @@ const OicSecAcl_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAcl_t **
 }
 
 
-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)
     {
@@ -1013,7 +999,7 @@ OCStackResult InstallNewACL(const char* newJsonStr, const bool isIncResName)
         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);
index 5f550ec..9d1d668 100644 (file)
@@ -76,26 +76,18 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
  *
  * 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)
@@ -170,7 +162,7 @@ exit:
 /*
  * 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;
@@ -183,14 +175,7 @@ OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr, const bool isIncResName)
     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)
@@ -265,7 +250,7 @@ exit:
 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);
 
@@ -283,7 +268,7 @@ static OCEntityHandlerResult HandleAmaclPostRequest (const OCEntityHandlerReques
     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)
     {
@@ -291,7 +276,7 @@ static OCEntityHandlerResult HandleAmaclPostRequest (const OCEntityHandlerReques
         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);
@@ -389,7 +374,7 @@ OCStackResult InitAmaclResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON Amacl into binary format
-        gAmacl = JSONToAmaclBin(jsonSVRDatabase, true);
+        gAmacl = JSONToAmaclBin(jsonSVRDatabase);
         OICFree(jsonSVRDatabase);
     }
 
index 94cd7d2..5ec9fb4 100644 (file)
@@ -116,7 +116,7 @@ static OCStackApplicationResult AmsMgrDiscoveryCallback(void *ctx, OCDoHandle ha
     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.
@@ -306,7 +306,7 @@ static OCStackApplicationResult AmsMgrAclReqCallback(void *ctx, OCDoHandle handl
                        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__);
index 8594242..660164b 100644 (file)
@@ -99,13 +99,12 @@ void DeleteCredList(OicSecCred_t* cred)
  * 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;
@@ -115,20 +114,13 @@ char * BinToCredJSON(const OicSecCred_t * cred, const bool isIncResName)
         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)
@@ -145,7 +137,7 @@ char * BinToCredJSON(const OicSecCred_t * cred, const bool isIncResName)
             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
@@ -242,7 +234,7 @@ exit:
 /*
  * 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;
@@ -252,16 +244,8 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName)
     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);
@@ -297,7 +281,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName)
             }
 
             //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;
@@ -499,7 +483,7 @@ static bool UpdatePersistentStorage(const OicSecCred_t *cred)
     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);
@@ -679,7 +663,7 @@ static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * eh
     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)
     {
@@ -710,7 +694,7 @@ static OCEntityHandlerResult HandleDeleteRequest(const OCEntityHandlerRequest *e
    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)] = {};
@@ -817,7 +801,7 @@ OCStackResult InitCredResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON Cred into binary format
-        gCred = JSONToCredBin(jsonSVRDatabase, true);
+        gCred = JSONToCredBin(jsonSVRDatabase);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index 8514e33..c226c9d 100644 (file)
@@ -69,7 +69,7 @@ void DeleteCrlBinData(OicSecCrl_t *crl)
     }
 }
 
-char *BinToCrlJSON(const OicSecCrl_t *crl, const bool isIncResName)
+char *BinToCrlJSON(const OicSecCrl_t *crl)
 {
     if (NULL == crl)
     {
@@ -81,21 +81,12 @@ char *BinToCrlJSON(const OicSecCrl_t *crl, const bool isIncResName)
     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);
@@ -130,7 +121,7 @@ exit:
     return jsonStr;
 }
 
-OicSecCrl_t *JSONToCrlBin(const char * jsonStr, const bool isIncResName)
+OicSecCrl_t *JSONToCrlBin(const char * jsonStr)
 {
     if (NULL == jsonStr)
     {
@@ -150,16 +141,8 @@ OicSecCrl_t *JSONToCrlBin(const char * jsonStr, const bool isIncResName)
     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);
 
@@ -261,7 +244,7 @@ OCStackResult UpdateCRLResource(const OicSecCrl_t *crl)
     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;
@@ -294,7 +277,7 @@ static OCEntityHandlerResult HandleCRLPostRequest(const OCEntityHandlerRequest *
 
         cJSON *jsonObj = cJSON_Parse(jsonCRL);
         OicSecCrl_t *crl = NULL;
-        crl = JSONToCrlBin(jsonCRL, false);
+        crl = JSONToCrlBin(jsonCRL);
         if (!crl)
         {
             OC_LOG(ERROR, TAG, "Error JSONToCrlBin");
@@ -437,7 +420,7 @@ OCStackResult InitCRLResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON CRL into binary format
-        gCrl = JSONToCrlBin(jsonSVRDatabase, true);
+        gCrl = JSONToCrlBin(jsonSVRDatabase);
     }
     /*
      * If SVR database in persistent storage got corrupted or
@@ -475,7 +458,7 @@ OicSecCrl_t *GetCRLResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON CRL into binary format
-        crl = JSONToCrlBin(jsonSVRDatabase, true);
+        crl = JSONToCrlBin(jsonSVRDatabase);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index b693c87..6acb7e3 100644 (file)
@@ -55,6 +55,8 @@ static OCResourceHandle    gDoxmHandle = NULL;
 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 */
@@ -68,6 +70,13 @@ void DeleteDoxmBinData(OicSecDoxm_t* doxm)
 {
     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);
 
@@ -76,7 +85,7 @@ void DeleteDoxmBinData(OicSecDoxm_t* doxm)
     }
 }
 
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName)
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
 {
     if (NULL == doxm)
     {
@@ -92,15 +101,20 @@ char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName)
     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
@@ -142,14 +156,6 @@ char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName)
     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);
@@ -162,7 +168,7 @@ exit:
     return jsonStr;
 }
 
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName)
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
 {
 
     if (NULL == jsonStr)
@@ -183,19 +189,34 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName)
     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)
@@ -279,7 +300,7 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName)
     }
 
     //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);
@@ -318,7 +339,7 @@ static bool UpdatePersistentStorage(OicSecDoxm_t * doxm)
     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);
@@ -426,7 +447,7 @@ static OCEntityHandlerResult HandleDoxmGetRequest (const OCEntityHandlerRequest
      * 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))
@@ -496,7 +517,7 @@ static OCEntityHandlerResult HandleDoxmPutRequest (const OCEntityHandlerRequest
      * 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)
     {
@@ -810,7 +831,7 @@ OCStackResult InitDoxmResource()
     if(jsonSVRDatabase)
     {
         //Convert JSON DOXM into binary format
-        gDoxm = JSONToDoxmBin(jsonSVRDatabase, true);
+        gDoxm = JSONToDoxmBin(jsonSVRDatabase);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index 36e9eb8..979073c 100644 (file)
@@ -63,7 +63,7 @@ void DeletePstatBinData(OicSecPstat_t* pstat)
     }
 }
 
-char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName)
+char * BinToPstatJSON(const OicSecPstat_t * pstat)
 {
     if(NULL == pstat)
     {
@@ -76,21 +76,11 @@ char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName)
     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,
@@ -119,7 +109,7 @@ exit:
     return jsonStr;
 }
 
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName)
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr)
 {
     if(NULL == jsonStr)
     {
@@ -138,14 +128,7 @@ OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName)
     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));
@@ -214,7 +197,7 @@ static OCEntityHandlerResult HandlePstatGetRequest (const OCEntityHandlerRequest
 {
     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);
@@ -241,14 +224,15 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
     {
         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;
@@ -263,7 +247,7 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
                 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)
         {
             /*
@@ -280,7 +264,7 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
             }
         }
         // 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);
@@ -385,7 +369,7 @@ OCStackResult InitPstatResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON Pstat into binary format
-        gPstat = JSONToPstatBin(jsonSVRDatabase, true);
+        gPstat = JSONToPstatBin(jsonSVRDatabase);
     }
     /*
      * If SVR database in persistent storage got corrupted or
old mode 100644 (file)
new mode 100755 (executable)
index 8a456b7..be72bf3
@@ -58,17 +58,18 @@ const char * OIC_RSRC_TYPE_SEC_SVC = "oic.sec.svc";
 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";
@@ -77,16 +78,16 @@ const char * OIC_JSON_TM_NAME = "tm";
 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 = {"*"};
index d399fb2..28a8c59 100644 (file)
@@ -61,26 +61,18 @@ void DeleteSVCList(OicSecSvc_t* svc)
  * 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)
@@ -135,7 +127,7 @@ exit:
 /*
  * 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;
@@ -148,14 +140,7 @@ OicSecSvc_t * JSONToSvcBin(const char * jsonStr, const bool isIncResName)
     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)
@@ -245,7 +230,7 @@ exit:
 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);
 
@@ -263,7 +248,7 @@ static OCEntityHandlerResult HandleSVCPostRequest (const OCEntityHandlerRequest
     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)
     {
@@ -271,7 +256,7 @@ static OCEntityHandlerResult HandleSVCPostRequest (const OCEntityHandlerRequest
         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);
@@ -366,7 +351,7 @@ OCStackResult InitSVCResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON SVC into binary format
-        gSvc = JSONToSvcBin(jsonSVRDatabase, true);
+        gSvc = JSONToSvcBin(jsonSVRDatabase);
         OICFree(jsonSVRDatabase);
     }
 
index 8dc9aef..be35bb3 100644 (file)
@@ -90,8 +90,6 @@ srmtest_env.Alias("install", srmtest_env.Install( unittest_build_dir,
 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')
index e2ace8f..08e7d26 100644 (file)
@@ -45,8 +45,8 @@ using namespace std;
 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,
@@ -58,8 +58,6 @@ 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)
 
@@ -82,10 +80,10 @@ TEST(ACLResourceTest, JSONMarshallingTests)
         }
         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);
@@ -103,7 +101,7 @@ TEST(ACLResourceTest, GetDefaultACLTests)
     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
@@ -142,7 +140,7 @@ TEST(ACLResourceTest, ACLPostTest)
     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();
@@ -157,7 +155,7 @@ TEST(ACLResourceTest, ACLPostTest)
         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
@@ -181,10 +179,10 @@ TEST(ACLResourceTest, GetACLResourceTests)
     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
@@ -255,7 +253,7 @@ TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
     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
@@ -312,7 +310,7 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     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
@@ -336,6 +334,12 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     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)
@@ -364,7 +368,7 @@ TEST(ACLResourceTest, ACLGetWithQueryTest)
     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
index f840955..4c5b6b4 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
 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);
@@ -194,7 +194,7 @@ TEST(CredEntityHandlerTest, CredEntityHandlerDeleteTest)
     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
@@ -235,7 +235,7 @@ exit:
 //BinToCredJSON Tests
 TEST(BinToCredJSONTest, BinToCredJSONNullCred)
 {
-    char* value = BinToCredJSON(NULL, true);
+    char* value = BinToCredJSON(NULL);
     EXPECT_TRUE(value == NULL);
 }
 
@@ -244,7 +244,7 @@ TEST(BinToCredJSONTest, BinToCredJSONValidCred)
     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);
@@ -256,10 +256,10 @@ TEST(BinToCredJSONTest, BinToCredJSONValidCred)
 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);
@@ -268,7 +268,7 @@ TEST(JSONToCredBinTest, JSONToCredBinValidJSON)
 
 TEST(JSONToCredBinTest, JSONToCredBinNullJSON)
 {
-    OicSecCred_t *cred = JSONToCredBin(NULL, true);
+    OicSecCred_t *cred = JSONToCredBin(NULL);
     EXPECT_TRUE(cred == NULL);
 }
 
index 6c9f33a..f2de1dd 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
 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);
@@ -56,10 +56,28 @@ OicSecDoxm_t * getBinDoxm()
     {
         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;
     }
@@ -138,7 +156,7 @@ TEST(DoxmEntityHandlerTest, DoxmEntityHandlerDeviceIdQuery)
 //BinToDoxmJSON Tests
 TEST(BinToDoxmJSONTest, BinToDoxmJSONNullDoxm)
 {
-    char* value = BinToDoxmJSON(NULL, true);
+    char* value = BinToDoxmJSON(NULL);
     EXPECT_TRUE(value == NULL);
 }
 
@@ -146,7 +164,7 @@ TEST(BinToDoxmJSONTest, BinToDoxmJSONValidDoxm)
 {
     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);
 
@@ -158,10 +176,10 @@ TEST(BinToDoxmJSONTest, BinToDoxmJSONValidDoxm)
 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);
@@ -171,7 +189,7 @@ TEST(JSONToDoxmBinTest, JSONToDoxmBinValidJSON)
 
 TEST(JSONToDoxmBinTest, JSONToDoxmBinNullJSON)
 {
-    OicSecDoxm_t *doxm = JSONToDoxmBin(NULL, true);
+    OicSecDoxm_t *doxm = JSONToDoxmBin(NULL);
     EXPECT_TRUE(doxm == NULL);
 }
 
@@ -188,7 +206,7 @@ TEST(HandleDoxmPostRequestTest, HandleDoxmPostRequestValidInput)
     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));
index c48fdd6..0b0a4a6 100644 (file)
@@ -1,28 +1,28 @@
 {
     "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=="
              ]
         }
index 6abc526..54cd36a 100644 (file)
@@ -1,24 +1,24 @@
 {
     "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=="
                        ]
                }
index 0514f92..a179c2c 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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=="
                        ]
diff --git a/resource/csdk/security/unittest/oic_unittest_acl_payload.json b/resource/csdk/security/unittest/oic_unittest_acl_payload.json
deleted file mode 100644 (file)
index 334103c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-[
-    {
-        "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=="
-               ]
-       }
-]
index 5cef3c4..7f3d449 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "subject": "Kg==",
-            "resources": [
+            "sub": "Kg==",
+            "rsrc": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
@@ -12,8 +12,8 @@
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
                        ],
-                       "permission": 2,
-                       "rowners" : [
+                       "perms": 2,
+                       "ownrs" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                }
index 6a43742..03c8a68 100644 (file)
@@ -37,8 +37,8 @@ extern "C" {
 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
 }
@@ -88,13 +88,13 @@ TEST(PstatEntityHandlerTest, PstatEntityHandlerInvalidRequest)
 //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);
 }
 
@@ -119,7 +119,7 @@ TEST(MarshalingAndUnMarshalingTest, BinToPstatJSONAndJSONToPstatBin)
     }
     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);
@@ -128,7 +128,7 @@ TEST(MarshalingAndUnMarshalingTest, BinToPstatJSONAndJSONToPstatBin)
     }
     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)
     {
@@ -157,10 +157,10 @@ TEST(PstatTests, JSONMarshalliingTests)
         }
         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);
index 18948d7..5c3f75e 100644 (file)
@@ -38,8 +38,8 @@ using namespace std;
 #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
 }
@@ -56,7 +56,7 @@ TEST(SVCResourceTest, JSONMarshallingTests)
     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;
@@ -70,7 +70,7 @@ TEST(SVCResourceTest, JSONMarshallingTests)
         }
         EXPECT_EQ(cnt, NUM_SVC_IN_JSON_DB);
 
-        char * jsonStr2 = BinToSvcJSON(svc, true);
+        char * jsonStr2 = BinToSvcJSON(svc);
         EXPECT_TRUE(NULL != jsonStr2);
 
         OICFree(jsonStr1);
index b3dc715..9543a87 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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=="]
        }]
 }
index 7d80de5..ca8fed4 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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=="]
        }]
 }
index 01b18f2..9456b41 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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=="]
        }]
 }
index 9bec918..1219d6a 100644 (file)
@@ -1,8 +1,8 @@
 {
     "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":        {
@@ -38,6 +38,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlEMA==",
-               "devowner":     "YWRtaW5EZXZpY2VVVUlEMA=="
+               "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
        }
 }