Update secure resource related modules(SRM,OTM,SRP,CKM,unit tests,samples)
authorleechul <chuls.lee@samsung.com>
Thu, 24 Dec 2015 08:13:37 +0000 (17:13 +0900)
committerDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Tue, 5 Jan 2016 09:08:41 +0000 (09:08 +0000)
according to spec B.

* NOTE : https://gerrit.iotivity.org/gerrit/#/c/4733/ required,
         in order to provisioning tool works in debug mode.

1. Change the security resource name according to spec B.

2. Remove unnecessary security resource according to spec B.

3. Remove the entity of resource name from coap/coaps payload as follows :
  [Before]
  {
    "doxm":
    {
      "oxm":[0],
      "oxmsel":0,
      "sct":1,
      "owned":true,
      "deviceid":"anVzdHdvcmtzRGV2VVVJRA==",
      "devowner":"YWRtaW5EZXZpY2VVVUlEMA==",
      "rowner":"YWRtaW5EZXZpY2VVVUlEMA=="
    }
  }

  [After]
  {
    "oxm":[0],
    "oxmsel":0,
    "sct":1,
    "owned":true,
    "deviceid":"anVzdHdvcmtzRGV2VVVJRA==",
    "devowner":"YWRtaW5EZXZpY2VVVUlEMA==",
    "rowner":"YWRtaW5EZXZpY2VVVUlEMA=="
  }

4. Modify the sample SVR DB(.json) according to above modifications.

5. Modify the unittest according to above modifications.

[Patch #1] Initial upload
[Patch #2] Update commit message
[Patch #3] Retrigger
[Patch #4] Upload missing file.
[Patch #5,#6] Modify according to comments.
[Patch #7,#8] Update commit message.

Change-Id: Ic6842af77c7098f30e7823597f807bb8a55d4541
Signed-off-by: leechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4725
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: sangsu choi <sangsu.choi@samsung.com>
Reviewed-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
47 files changed:
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/amaclresource.h [changed mode: 0755->0644]
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: 0755->0644]
resource/csdk/security/include/internal/svcresource.h
resource/csdk/security/include/securevirtualresourcetypes.h [changed mode: 0755->0644]
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: 0755->0644]
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.json [changed mode: 0755->0644]
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: 0755->0644]
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: 0755->0644]
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 [new file with mode: 0644]
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 564d23f..600b1f4 100644 (file)
@@ -57,10 +57,11 @@ 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);
+char* BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName);
 
 
 /**
@@ -74,10 +75,11 @@ 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);
+OCStackResult InstallNewACL(const char* newJsonStr, const bool isIncResName);
 
 
 #ifdef __cplusplus
old mode 100755 (executable)
new mode 100644 (file)
index 9c37a0e..1672f9e
@@ -67,10 +67,11 @@ 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);
+char* BinToAmaclJSON(const OicSecAmacl_t * amacl, const bool isIncResName);
 
 #ifdef __cplusplus
 }
index 74ea373..06636c8 100644 (file)
@@ -65,12 +65,13 @@ 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);
+char* BinToCredJSON(const OicSecCred_t* cred, const bool isIncResName);
 
 /**
  * This function generates the bin credential data.
index 75178d8..fbe8086 100644 (file)
@@ -51,16 +51,16 @@ char* GetBase64CRL();
 void  GetDerCrl(ByteArray crlArray);
 
 /**
- * This function get CRL from SRM
+ * This method converts JSON CRL into binary CRL.
+ * The JSON CRL can be from persistent database or received as PUT/POST request.
  *
- * @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.
+ * @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.
  *
- * @returns OC_STACK_OK if success and errorcode otherwise.
- * @note Caller responsible for crl buffer memory (use OICFree to free it)
+ * @note Caller needs to invoke OCFree after done using the return pointer
  */
-OicSecCrl_t * JSONToCrlBin(const char * jsonStr);
+OicSecCrl_t * JSONToCrlBin(const char * jsonStr, const bool isIncResName);
 
 /**
  * Initialize CLR resource by loading data from persistent storage.
index e0f2fc9..b5b62e1 100644 (file)
@@ -54,12 +54,13 @@ 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);
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName);
 
 /**
  * This method converts DOXM data into JSON format.
@@ -67,12 +68,13 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr);
  * 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);
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName);
 
 /**
  * This method returns the SRM device ID for this device.
index 40c41ab..d4b719f 100644 (file)
@@ -43,17 +43,19 @@ 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);
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName);
 
 /**
  * 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);
+char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName);
 
 /** This function deallocates the memory for OicSecPstat_t.
  *
old mode 100755 (executable)
new mode 100644 (file)
index 1ac3fb0..e263bd7
@@ -68,12 +68,14 @@ 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 9db42c5..9afabfd 100644 (file)
@@ -44,10 +44,11 @@ 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);
+char* BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName);
 
 #ifdef __cplusplus
 }
old mode 100755 (executable)
new mode 100644 (file)
index 83dc60f..6896ce7
@@ -369,8 +369,6 @@ 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 8bcb39f..5d127e5 100644 (file)
@@ -1,29 +1,29 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/res/d",
                 "/oic/res/types/d",
                 "/oic/presence"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "ZG9vckRldmljZVVVSUQwMA=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/crl",
                 "/oic/sec/cred"
              ],
-             "perms": 6,
-             "ownrs" : [
+             "permission": 6,
+             "rowners" : [
                  "ZG9vckRldmljZVVVSUQwMA=="
              ]
         }
@@ -31,7 +31,7 @@
        "pstat":        {
                "isop": false,
                "deviceid":     "ZG9vckRldmljZVVVSUQwMA==",
-               "commithash": 0,
+               "ch": 0,
                "cm":   0,
                "tm":   0,
                "om":   3,
index 048384b..a4836b6 100644 (file)
@@ -1,29 +1,29 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/res/d",
                 "/oic/res/types/d",
                 "/oic/presence"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "bGlnaHREZXZpY2VVVUlEMA=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/crl",
                 "/oic/sec/cred"
              ],
-             "perms": 6,
-             "ownrs" : [
+             "permission": 6,
+             "rowners" : [
                  "bGlnaHREZXZpY2VVVUlEMA=="
              ]
         }
@@ -31,7 +31,7 @@
        "pstat":        {
                "isop": false,
                "deviceid":     "bGlnaHREZXZpY2VVVUlEMA==",
-               "commithash": 0,
+               "ch": 0,
                "cm":   0,
                "tm":   0,
                "om":   3,
index dd5dec4..f63bca6 100644 (file)
@@ -1,27 +1,27 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/res/types/d",
                 "/oic/ad"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+                       "permission": 2,
+                       "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/cred"
              ],
-             "perms": 7,
-             "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+             "permission": 7,
+             "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
         }
        ],
        "pstat":        {
@@ -39,6 +39,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlEMA==",
-               "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
+               "devowner":     "YWRtaW5EZXZpY2VVVUlEMA=="
        }
 }
index d036473..8e05fdd 100644 (file)
@@ -1,27 +1,27 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/res/types/d",
                 "/oic/ad"
             ],
-            "perms": 2,
-            "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
+            "permission": 2,
+            "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
         },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/cred"
              ],
-             "perms": 7,
-             "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
+             "permission": 7,
+             "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
         }
     ],
     "crl": {
@@ -43,6 +43,6 @@
         "oxmsel": 0,
         "owned": true,
         "deviceid": "YWRtaW5EZXZpY2VVVUlE",
-        "ownr": "YWRtaW5EZXZpY2VVVUlE"
+        "devowner": "YWRtaW5EZXZpY2VVVUlE"
     }
 }
index 1219d6a..9bec918 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/ad",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+                       "permission": 2,
+                       "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 2,
-             "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+             "permission": 2,
+             "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
         }
        ],
        "pstat":        {
@@ -38,6 +38,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlEMA==",
-               "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
+               "devowner":     "YWRtaW5EZXZpY2VVVUlEMA=="
        }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 7172a01..8282e63
@@ -1,27 +1,27 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/res/types/d",
                 "/oic/ad"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
+                       "permission": 2,
+                       "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/cred"
              ],
-             "perms": 7,
-             "ownrs" : ["YWRtaW5EZXZpY2VVVUlE"]
+             "permission": 7,
+             "rowners" : ["YWRtaW5EZXZpY2VVVUlE"]
         }
        ],
        "pstat":        {
@@ -39,6 +39,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlE",
-               "ownr": "YWRtaW5EZXZpY2VVVUlE"
+               "devowner":     "YWRtaW5EZXZpY2VVVUlE"
        }
 }
index bde9010..aef44d3 100644 (file)
@@ -1,28 +1,28 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/res/d",
                 "/oic/res/types/d",
                 "/oic/presence"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "anVzdHdvcmtzRGV2VVVJRA=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/cred"
              ],
-             "perms": 6,
-             "ownrs" : [
+             "permission": 6,
+             "rowners" : [
                  "anVzdHdvcmtzRGV2VVVJRA=="
              ]
         }
@@ -30,7 +30,7 @@
        "pstat":        {
                "isop": false,
                "deviceid":     "anVzdHdvcmtzRGV2VVVJRA==",
-               "commithash": 0,
+               "ch": 0,
                "cm":   0,
                "tm":   0,
                "om":   3,
old mode 100755 (executable)
new mode 100644 (file)
index a79a2b2..62a27b2
@@ -1,28 +1,28 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/res/d",
                 "/oic/res/types/d",
                 "/oic/presence"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "cmFuZG9tUGluRGV2VVVJRA=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl",
                 "/oic/sec/cred"
              ],
-             "perms": 6,
-             "ownrs" : [
+             "permission": 6,
+             "rowners" : [
                  "cmFuZG9tUGluRGV2VVVJRA=="
              ]
         }
@@ -30,7 +30,7 @@
        "pstat":        {
                "isop": false,
                "deviceid":     "cmFuZG9tUGluRGV2VVVJRA==",
-               "commithash": 0,
+               "ch": 0,
                "cm":   0,
                "tm":   0,
                "om":   3,
index fa804dd..42d37c4 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/sec/svc",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+                       "permission": 2,
+                       "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 6,
-             "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+             "permission": 6,
+             "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
         }
     ],
        "pstat":        {
index 7adeb46..8c0407d 100644 (file)
@@ -515,7 +515,7 @@ static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
         }
 
         OicSecPstat_t* pstat = JSONToPstatBin(
-                ((OCSecurityPayload*)clientResponse->payload)->securityData);
+                ((OCSecurityPayload*)clientResponse->payload)->securityData, false);
         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);
+    secPayload->securityData = BinToPstatJSON(deviceInfo->pstat, false);
     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);
+        secPayload->securityData = BinToPstatJSON(otmCtx->selectedDeviceInfo->pstat, false);
         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);
+    secPayload->securityData = BinToAclJSON(&defaultAcl, false);
     OICFree(defaultAcl.owners);
     if(!secPayload->securityData)
     {
index 7a0d561..5968ed9 100644 (file)
@@ -40,7 +40,7 @@ char* CreateJustWorksSelectOxmPayload(OTMContext_t* otmCtx)
     }
 
     otmCtx->selectedDeviceInfo->doxm->oxmSel = OIC_JUST_WORKS;
-    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm);
+    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
 }
 
 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);
+    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
 }
 
 OCStackResult LoadSecretJustWorksCallback(OTMContext_t* UNUSED_PARAM)
index 8e9ad1e..d521631 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);
+    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
 }
 
 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);
+    return BinToDoxmJSON(otmCtx->selectedDeviceInfo->doxm, false);
 }
 
 OCStackResult InputPinCodeCallback(OTMContext_t* otmCtx)
old mode 100755 (executable)
new mode 100644 (file)
index 60daa64..b496c6c
@@ -33,6 +33,7 @@
 #include "cJSON.h"
 #include "utlist.h"
 #include "ocpayload.h"
+#include "payload_logging.h"
 
 #include "securevirtualresourcetypes.h"
 #include "srmresourcestrings.h" //@note: SRM's internal header
@@ -206,7 +207,6 @@ 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,6 +411,8 @@ 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");
@@ -484,13 +486,15 @@ 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);
+                            ((OCSecurityPayload*)clientResponse->payload)->securityData, false);
             if (NULL == ptrDoxm)
             {
                 OC_LOG(INFO, TAG, "Ignoring malformed JSON");
index e7c12fb..20857c8 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);
+    secPayload->securityData = BinToCredJSON(cred, false);
     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);
+    secPayload->securityData = BinToCrlJSON(crl, false);
     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);
+    secPayload->securityData = BinToCredJSON(cred, false);
 
     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);
+    secPayload->securityData = BinToAclJSON(acl, false);
     if(NULL == secPayload->securityData)
     {
         OICFree(secPayload);
index 6d20938..19e0e00 100644 (file)
@@ -112,18 +112,25 @@ void DeleteACLList(OicSecAcl_t* acl)
  * Note: Caller needs to invoke 'free' when finished done using
  * return string.
  */
-char * BinToAclJSON(const OicSecAcl_t * acl)
+char * BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName)
 {
     cJSON *jsonRoot = NULL;
     char *jsonStr = NULL;
 
     if (acl)
     {
-        jsonRoot = cJSON_CreateObject();
-        VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
-
         cJSON *jsonAclArray = NULL;
-        cJSON_AddItemToObject (jsonRoot, OIC_JSON_ACL_NAME, jsonAclArray = cJSON_CreateArray());
+        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;
+        }
         VERIFY_NON_NULL(TAG, jsonAclArray, ERROR);
 
         while(acl)
@@ -224,7 +231,7 @@ exit:
 /*
  * This internal method converts JSON ACL into binary ACL.
  */
-OicSecAcl_t * JSONToAclBin(const char * jsonStr)
+OicSecAcl_t * JSONToAclBin(const char * jsonStr, const bool isIncResName)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OicSecAcl_t * headAcl = NULL;
@@ -237,7 +244,14 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr)
     jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonAclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_ACL_NAME);
+    if(isIncResName)
+    {
+        jsonAclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_ACL_NAME);
+    }
+    else
+    {
+        jsonAclArray = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonAclArray, ERROR);
 
     if (cJSON_Array == jsonAclArray->type)
@@ -408,7 +422,7 @@ exit:
 static bool UpdatePersistentStorage(const OicSecAcl_t *acl)
 {
     // Convert ACL data into JSON for update to persistent storage
-    char *jsonStr = BinToAclJSON(acl);
+    char *jsonStr = BinToAclJSON(acl, true);
     if (jsonStr)
     {
         cJSON *jsonAcl = cJSON_Parse(jsonStr);
@@ -632,7 +646,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
                              0 == strcmp(WILDCARD_RESOURCE_URI, currentAce->resources[n])))
                     {
                         // Convert ACL data into JSON for transmission
-                        jsonStr = BinToAclJSON(currentAce);
+                        jsonStr = BinToAclJSON(currentAce, false);
                         goto exit;
                     }
                 }
@@ -640,7 +654,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
             else
             {
                 // Convert ACL data into JSON for transmission
-                jsonStr = BinToAclJSON(currentAce);
+                jsonStr = BinToAclJSON(currentAce, false);
                 goto exit;
             }
         }
@@ -648,7 +662,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest *
     else
     {
         // Convert ACL data into JSON for transmission
-        jsonStr = BinToAclJSON(gAcl);
+        jsonStr = BinToAclJSON(gAcl, false);
     }
 
 exit:
@@ -668,7 +682,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);
+    OicSecAcl_t* newAcl = JSONToAclBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
 
     if (newAcl)
     {
@@ -885,7 +899,7 @@ OCStackResult InitACLResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON ACL into binary format
-        gAcl = JSONToAclBin(jsonSVRDatabase);
+        gAcl = JSONToAclBin(jsonSVRDatabase, true);
         OICFree(jsonSVRDatabase);
     }
     /*
@@ -986,12 +1000,12 @@ const OicSecAcl_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAcl_t **
 }
 
 
-OCStackResult InstallNewACL(const char* newJsonStr)
+OCStackResult InstallNewACL(const char* newJsonStr, const bool isIncResName)
 {
     OCStackResult ret = OC_STACK_ERROR;
 
     // Convert JSON ACL data into binary. This will also validate the ACL data received.
-    OicSecAcl_t* newAcl = JSONToAclBin(newJsonStr);
+    OicSecAcl_t* newAcl = JSONToAclBin(newJsonStr, isIncResName);
 
     if (newAcl)
     {
@@ -999,7 +1013,7 @@ OCStackResult InstallNewACL(const char* newJsonStr)
         LL_APPEND(gAcl, newAcl);
 
         // Convert ACL data into JSON for update to persistent storage
-        char *jsonStr = BinToAclJSON(gAcl);
+        char *jsonStr = BinToAclJSON(gAcl, true);
         if (jsonStr)
         {
             cJSON *jsonAcl = cJSON_Parse(jsonStr);
index 9d1d668..5f550ec 100644 (file)
@@ -76,18 +76,26 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
  *
  * Note: Caller needs to invoke 'free' when finished using the return string.
  */
-char * BinToAmaclJSON(const OicSecAmacl_t * amacl)
+char * BinToAmaclJSON(const OicSecAmacl_t * amacl, const bool isIncResName)
 {
     cJSON *jsonRoot = NULL;
     char *jsonStr = NULL;
 
     if (amacl)
     {
-        jsonRoot = cJSON_CreateObject();
-        VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
-
         cJSON *jsonAmaclArray = NULL;
-        cJSON_AddItemToObject (jsonRoot, OIC_JSON_AMACL_NAME, jsonAmaclArray = cJSON_CreateArray());
+        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;
+        }
         VERIFY_NON_NULL(TAG, jsonAmaclArray, ERROR);
 
         while(amacl)
@@ -162,7 +170,7 @@ exit:
 /*
  * This internal method converts JSON AMACL into binary AMACL.
  */
-OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr)
+OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr, const bool isIncResName)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OicSecAmacl_t * headAmacl = NULL;
@@ -175,7 +183,14 @@ OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr)
     jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonAmaclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_AMACL_NAME);
+    if(isIncResName)
+    {
+        jsonAmaclArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_AMACL_NAME);
+    }
+    else
+    {
+        jsonAmaclArray = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonAmaclArray, INFO);
 
     if (cJSON_Array == jsonAmaclArray->type)
@@ -250,7 +265,7 @@ exit:
 static OCEntityHandlerResult HandleAmaclGetRequest (const OCEntityHandlerRequest * ehRequest)
 {
     // Convert Amacl data into JSON for transmission
-    char* jsonStr = BinToAmaclJSON(gAmacl);
+    char* jsonStr = BinToAmaclJSON(gAmacl, false);
 
     OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
 
@@ -268,7 +283,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);
+    OicSecAmacl_t* newAmacl = JSONToAmaclBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
 
     if (newAmacl)
     {
@@ -276,7 +291,7 @@ static OCEntityHandlerResult HandleAmaclPostRequest (const OCEntityHandlerReques
         LL_APPEND(gAmacl, newAmacl);
 
         // Convert Amacl data into JSON for update to persistent storage
-        char *jsonStr = BinToAmaclJSON(gAmacl);
+        char *jsonStr = BinToAmaclJSON(gAmacl, true);
         if (jsonStr)
         {
             cJSON *jsonAmacl = cJSON_Parse(jsonStr);
@@ -374,7 +389,7 @@ OCStackResult InitAmaclResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON Amacl into binary format
-        gAmacl = JSONToAmaclBin(jsonSVRDatabase);
+        gAmacl = JSONToAmaclBin(jsonSVRDatabase, true);
         OICFree(jsonSVRDatabase);
     }
 
index 5ec9fb4..94cd7d2 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);
+    doxm = JSONToDoxmBin(((OCSecurityPayload*)clientResponse->payload)->securityData, false);
 
     //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);
+                InstallNewACL(((OCSecurityPayload*)clientResponse->payload)->securityData, false);
         VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
 
         OC_LOG_V(INFO, TAG, "%s : Calling checkPermission", __func__);
index 660164b..8594242 100644 (file)
@@ -99,12 +99,13 @@ 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)
+char * BinToCredJSON(const OicSecCred_t * cred, const bool isIncResName)
 {
     cJSON *jsonRoot = NULL;
     char *jsonStr = NULL;
@@ -114,13 +115,20 @@ char * BinToCredJSON(const OicSecCred_t * cred)
         char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*)0)->id)) + 1] = {};
         uint32_t outLen = 0;
         B64Result b64Ret = B64_OK;
-
-        jsonRoot = cJSON_CreateObject();
-        VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
-
         cJSON *jsonCredArray = NULL;
-        cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRED_NAME,
-                jsonCredArray = cJSON_CreateArray());
+
+        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;
+        }
         VERIFY_NON_NULL(TAG, jsonCredArray, ERROR);
 
         while(cred)
@@ -137,7 +145,7 @@ char * BinToCredJSON(const OicSecCred_t * cred)
             b64Ret = b64Encode(cred->subject.id, sizeof(cred->subject.id), base64Buff,
                    sizeof(base64Buff), &outLen);
             VERIFY_SUCCESS(TAG, b64Ret == B64_OK, ERROR);
-            cJSON_AddStringToObject(jsonCred, OIC_JSON_SUBJECT_NAME, base64Buff);
+            cJSON_AddStringToObject(jsonCred, OIC_JSON_SUBJECTID_NAME, base64Buff);
 
             //Note: Need further clarification on roleID data type
 #if 0
@@ -234,7 +242,7 @@ exit:
 /*
  * This internal method converts JSON cred into binary cred.
  */
-OicSecCred_t * JSONToCredBin(const char * jsonStr)
+OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OicSecCred_t * headCred = NULL;
@@ -244,8 +252,16 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
     cJSON *jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonCredArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRED_NAME);
+    if(isIncResName)
+    {
+        jsonCredArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRED_NAME);
+    }
+    else
+    {
+        jsonCredArray = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonCredArray, ERROR);
+
     if (cJSON_Array == jsonCredArray->type)
     {
         int numCred = cJSON_GetArraySize(jsonCredArray);
@@ -281,7 +297,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
             }
 
             //subject -- Mandatory
-            jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_SUBJECT_NAME);
+            jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_SUBJECTID_NAME);
             VERIFY_NON_NULL(TAG, jsonObj, ERROR);
             VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
             outLen = 0;
@@ -483,7 +499,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);
+    char *jsonStr = BinToCredJSON(cred, true);
     if (jsonStr)
     {
         cJSON *jsonCred = cJSON_Parse(jsonStr);
@@ -663,7 +679,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);
+    OicSecCred_t * cred  = JSONToCredBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
 
     if(cred)
     {
@@ -694,7 +710,7 @@ static OCEntityHandlerResult HandleDeleteRequest(const OCEntityHandlerRequest *e
    ParseQueryIterInit((unsigned char *)ehRequest->query, &parseIter);
    while(GetNextQuery(&parseIter))
    {
-       if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECT_NAME,
+       if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECTID_NAME,
                parseIter.attrLen) == 0)
        {
            unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
@@ -801,7 +817,7 @@ OCStackResult InitCredResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON Cred into binary format
-        gCred = JSONToCredBin(jsonSVRDatabase);
+        gCred = JSONToCredBin(jsonSVRDatabase, true);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index c226c9d..8514e33 100644 (file)
@@ -69,7 +69,7 @@ void DeleteCrlBinData(OicSecCrl_t *crl)
     }
 }
 
-char *BinToCrlJSON(const OicSecCrl_t *crl)
+char *BinToCrlJSON(const OicSecCrl_t *crl, const bool isIncResName)
 {
     if (NULL == crl)
     {
@@ -81,12 +81,21 @@ char *BinToCrlJSON(const OicSecCrl_t *crl)
     uint32_t base64CRLLen = 0;
     B64Result b64Ret = B64_OK;
     char *jsonStr = NULL;
+
     cJSON *jsonRoot = cJSON_CreateObject();
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
-    cJSON *jsonCrl = cJSON_CreateObject();
-    VERIFY_NON_NULL(TAG, jsonCrl, ERROR);
 
-    cJSON_AddItemToObject(jsonRoot, OIC_JSON_CRL_NAME, jsonCrl);
+    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;
+    }
 
     //CRLId -- Mandatory
     cJSON_AddNumberToObject(jsonCrl, OIC_JSON_CRL_ID, (int)crl->CrlId);
@@ -121,7 +130,7 @@ exit:
     return jsonStr;
 }
 
-OicSecCrl_t *JSONToCrlBin(const char * jsonStr)
+OicSecCrl_t *JSONToCrlBin(const char * jsonStr, const bool isIncResName)
 {
     if (NULL == jsonStr)
     {
@@ -141,8 +150,16 @@ OicSecCrl_t *JSONToCrlBin(const char * jsonStr)
     cJSON *jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonCrl = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRL_NAME);
+    if(isIncResName)
+    {
+        jsonCrl = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRL_NAME);
+    }
+    else
+    {
+        jsonCrl = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonCrl, ERROR);
+
     crl = (OicSecCrl_t *)OICCalloc(1, sizeof(OicSecCrl_t));
     VERIFY_NON_NULL(TAG, crl, ERROR);
 
@@ -244,7 +261,7 @@ OCStackResult UpdateCRLResource(const OicSecCrl_t *crl)
     char *jsonStr = NULL;
     OCStackResult res = OC_STACK_ERROR;
 
-    jsonStr = BinToCrlJSON((OicSecCrl_t *) crl);
+    jsonStr = BinToCrlJSON((OicSecCrl_t *) crl, true);
     if (!jsonStr)
     {
         return OC_STACK_ERROR;
@@ -277,7 +294,7 @@ static OCEntityHandlerResult HandleCRLPostRequest(const OCEntityHandlerRequest *
 
         cJSON *jsonObj = cJSON_Parse(jsonCRL);
         OicSecCrl_t *crl = NULL;
-        crl = JSONToCrlBin(jsonCRL);
+        crl = JSONToCrlBin(jsonCRL, false);
         if (!crl)
         {
             OC_LOG(ERROR, TAG, "Error JSONToCrlBin");
@@ -420,7 +437,7 @@ OCStackResult InitCRLResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON CRL into binary format
-        gCrl = JSONToCrlBin(jsonSVRDatabase);
+        gCrl = JSONToCrlBin(jsonSVRDatabase, true);
     }
     /*
      * If SVR database in persistent storage got corrupted or
@@ -458,7 +475,7 @@ OicSecCrl_t *GetCRLResource()
     if (jsonSVRDatabase)
     {
         //Convert JSON CRL into binary format
-        crl = JSONToCrlBin(jsonSVRDatabase);
+        crl = JSONToCrlBin(jsonSVRDatabase, true);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index 6acb7e3..b693c87 100644 (file)
@@ -55,8 +55,6 @@ 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 */
@@ -70,13 +68,6 @@ 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);
 
@@ -85,7 +76,7 @@ void DeleteDoxmBinData(OicSecDoxm_t* doxm)
     }
 }
 
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName)
 {
     if (NULL == doxm)
     {
@@ -101,20 +92,15 @@ char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
     cJSON *jsonRoot = cJSON_CreateObject();
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonDoxm = cJSON_CreateObject();
-    VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
-    cJSON_AddItemToObject(jsonRoot, OIC_JSON_DOXM_NAME, jsonDoxm );
-
-    //OxmType -- Not Mandatory
-    if(doxm->oxmTypeLen > 0)
+    if(isIncResName)
     {
-        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]));
-        }
+        jsonDoxm = cJSON_CreateObject();
+        VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
+        cJSON_AddItemToObject(jsonRoot, OIC_JSON_DOXM_NAME, jsonDoxm );
+    }
+    else
+    {
+        jsonDoxm = jsonRoot;
     }
 
     //Oxm -- Not Mandatory
@@ -156,6 +142,14 @@ char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
     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);
@@ -168,7 +162,7 @@ exit:
     return jsonStr;
 }
 
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName)
 {
 
     if (NULL == jsonStr)
@@ -189,34 +183,19 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
     cJSON *jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonDoxm = cJSON_GetObjectItem(jsonRoot, OIC_JSON_DOXM_NAME);
-    VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
+    if(isIncResName)
+   {
+        jsonDoxm = cJSON_GetObjectItem(jsonRoot, OIC_JSON_DOXM_NAME);
+        VERIFY_NON_NULL(TAG, jsonDoxm, ERROR);
+    }
+    else
+    {
+        jsonDoxm = jsonRoot;
+    }
 
     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)
@@ -300,7 +279,7 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
     }
 
     //Owner -- will be empty when device status is unowned.
-    jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OWNER_NAME);
+    jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_DEV_OWNER_NAME);
     if(true == doxm->owned)
     {
         VERIFY_NON_NULL(TAG, jsonObj, ERROR);
@@ -339,7 +318,7 @@ static bool UpdatePersistentStorage(OicSecDoxm_t * doxm)
     if (NULL != doxm)
     {
         // Convert Doxm data into JSON for update to persistent storage
-        char *jsonStr = BinToDoxmJSON(doxm);
+        char *jsonStr = BinToDoxmJSON(doxm, true);
         if (jsonStr)
         {
             cJSON *jsonDoxm = cJSON_Parse(jsonStr);
@@ -447,7 +426,7 @@ static OCEntityHandlerResult HandleDoxmGetRequest (const OCEntityHandlerRequest
      * return valid doxm resource json.
      */
 
-    jsonStr = (ehRet == OC_EH_OK) ? BinToDoxmJSON(gDoxm) : NULL;
+    jsonStr = (ehRet == OC_EH_OK) ? BinToDoxmJSON(gDoxm, false) : NULL;
 
     // Send response payload to request originator
     if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, jsonStr))
@@ -517,7 +496,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);
+    OicSecDoxm_t* newDoxm = JSONToDoxmBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
 
     if (newDoxm)
     {
@@ -831,7 +810,7 @@ OCStackResult InitDoxmResource()
     if(jsonSVRDatabase)
     {
         //Convert JSON DOXM into binary format
-        gDoxm = JSONToDoxmBin(jsonSVRDatabase);
+        gDoxm = JSONToDoxmBin(jsonSVRDatabase, true);
     }
     /*
      * If SVR database in persistent storage got corrupted or
index 979073c..36e9eb8 100644 (file)
@@ -63,7 +63,7 @@ void DeletePstatBinData(OicSecPstat_t* pstat)
     }
 }
 
-char * BinToPstatJSON(const OicSecPstat_t * pstat)
+char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName)
 {
     if(NULL == pstat)
     {
@@ -76,11 +76,21 @@ char * BinToPstatJSON(const OicSecPstat_t * pstat)
     char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*) 0)->id)) + 1] = {};
     uint32_t outLen = 0;
     B64Result b64Ret = B64_OK;
+    cJSON *jsonRoot = NULL;
 
-    cJSON *jsonRoot = cJSON_CreateObject();
-    VERIFY_NON_NULL(TAG, jsonRoot, INFO);
+    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_AddItemToObject(jsonRoot, OIC_JSON_PSTAT_NAME, jsonPstat=cJSON_CreateObject());
     cJSON_AddBoolToObject(jsonPstat, OIC_JSON_ISOP_NAME, pstat->isOp);
 
     b64Ret = b64Encode(pstat->deviceID.id,
@@ -109,7 +119,7 @@ exit:
     return jsonStr;
 }
 
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr)
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName)
 {
     if(NULL == jsonStr)
     {
@@ -128,7 +138,14 @@ OicSecPstat_t * JSONToPstatBin(const char * jsonStr)
     cJSON *jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, INFO);
 
-    jsonPstat = cJSON_GetObjectItem(jsonRoot, OIC_JSON_PSTAT_NAME);
+    if(isIncResName)
+    {
+        jsonPstat = cJSON_GetObjectItem(jsonRoot, OIC_JSON_PSTAT_NAME);
+    }
+    else
+    {
+        jsonPstat = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonPstat, INFO);
 
     pstat = (OicSecPstat_t*)OICCalloc(1, sizeof(OicSecPstat_t));
@@ -197,7 +214,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);
+    char* jsonStr = BinToPstatJSON(gPstat, false);
 
     // A device should always have a default pstat. Therefore, jsonStr should never be NULL.
     OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
@@ -224,15 +241,14 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
     {
         postJson = cJSON_Parse(((OCSecurityPayload*)ehRequest->payload)->securityData);
         VERIFY_NON_NULL(TAG, postJson, INFO);
-        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);
+
+        cJSON *commitHashJson = cJSON_GetObjectItem(postJson, OIC_JSON_COMMIT_HASH_NAME);
         uint16_t commitHash = 0;
         if (commitHashJson)
         {
             commitHash = commitHashJson->valueint;
         }
-        cJSON *tmJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_TM_NAME);
+        cJSON *tmJson = cJSON_GetObjectItem(postJson, OIC_JSON_TM_NAME);
         if (tmJson && gPstat)
         {
             gPstat->tm = (OicSecDpm_t)tmJson->valueint;
@@ -247,7 +263,7 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
                 OC_LOG (INFO, TAG, "CommitHash is not valid");
             }
         }
-        cJSON *omJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_OM_NAME);
+        cJSON *omJson = cJSON_GetObjectItem(postJson, OIC_JSON_OM_NAME);
         if (omJson && gPstat)
         {
             /*
@@ -264,7 +280,7 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
             }
         }
         // Convert pstat data into JSON for update to persistent storage
-        char *jsonStr = BinToPstatJSON(gPstat);
+        char *jsonStr = BinToPstatJSON(gPstat, true);
         if (jsonStr)
         {
             cJSON *jsonPstat = cJSON_Parse(jsonStr);
@@ -369,7 +385,7 @@ OCStackResult InitPstatResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON Pstat into binary format
-        gPstat = JSONToPstatBin(jsonSVRDatabase);
+        gPstat = JSONToPstatBin(jsonSVRDatabase, true);
     }
     /*
      * If SVR database in persistent storage got corrupted or
old mode 100755 (executable)
new mode 100644 (file)
index be72bf3..8a456b7
@@ -58,18 +58,17 @@ 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 = "sub";
-const char * OIC_JSON_RESOURCES_NAME = "rsrc";
+const char * OIC_JSON_SUBJECT_NAME = "subject";
+const char * OIC_JSON_RESOURCES_NAME = "resources";
 const char * OIC_JSON_AMSS_NAME = "amss";
-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_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_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 = "dvcidfrmt";
+const char * OIC_JSON_DEVICE_ID_FORMAT_NAME = "didformat";
 const char * OIC_JSON_ISOP_NAME = "isop";
 const char * OIC_JSON_COMMIT_HASH_NAME = "ch";
 const char * OIC_JSON_DEVICE_ID_NAME = "deviceid";
@@ -78,16 +77,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 = "subid";
+const char * OIC_JSON_SUBJECTID_NAME = "subjectid";
 const char * OIC_JSON_ROLEIDS_NAME = "roleid";
-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_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_SERVICE_TYPE = "svct";
-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_PERIOD_NAME = "period";
+const char * OIC_JSON_PERIODS_NAME = "periods";
+const char * OIC_JSON_RECURRENCES_NAME = "recurrence";
 const char * OIC_JSON_SUPPORTED_CRED_TYPE_NAME = "sct";
 
 OicUuid_t WILDCARD_SUBJECT_ID = {"*"};
index 28a8c59..d399fb2 100644 (file)
@@ -61,18 +61,26 @@ void DeleteSVCList(OicSecSvc_t* svc)
  * Note: Caller needs to invoke 'free' when finished done using
  * return string.
  */
-char * BinToSvcJSON(const OicSecSvc_t * svc)
+char * BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName)
 {
     cJSON *jsonRoot = NULL;
     char *jsonStr = NULL;
 
     if (svc)
     {
-        jsonRoot = cJSON_CreateObject();
-        VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
-
         cJSON *jsonSvcArray = NULL;
-        cJSON_AddItemToObject (jsonRoot, OIC_JSON_SVC_NAME, jsonSvcArray = cJSON_CreateArray());
+        if(isIncResName)
+        {
+            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;
+        }
         VERIFY_NON_NULL(TAG, jsonSvcArray, ERROR);
 
         while(svc)
@@ -127,7 +135,7 @@ exit:
 /*
  * This internal method converts JSON SVC into binary SVC.
  */
-OicSecSvc_t * JSONToSvcBin(const char * jsonStr)
+OicSecSvc_t * JSONToSvcBin(const char * jsonStr, const bool isIncResName)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OicSecSvc_t * headSvc = NULL;
@@ -140,7 +148,14 @@ OicSecSvc_t * JSONToSvcBin(const char * jsonStr)
     jsonRoot = cJSON_Parse(jsonStr);
     VERIFY_NON_NULL(TAG, jsonRoot, ERROR);
 
-    jsonSvcArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
+    if(isIncResName)
+    {
+        jsonSvcArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
+    }
+    else
+    {
+        jsonSvcArray = jsonRoot;
+    }
     VERIFY_NON_NULL(TAG, jsonSvcArray, INFO);
 
     if (cJSON_Array == jsonSvcArray->type)
@@ -230,7 +245,7 @@ exit:
 static OCEntityHandlerResult HandleSVCGetRequest (const OCEntityHandlerRequest * ehRequest)
 {
     // Convert SVC data into JSON for transmission
-    char* jsonStr = BinToSvcJSON(gSvc);
+    char* jsonStr = BinToSvcJSON(gSvc, false);
 
     OCEntityHandlerResult ehRet = (jsonStr ? OC_EH_OK : OC_EH_ERROR);
 
@@ -248,7 +263,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);
+    OicSecSvc_t* newSvc = JSONToSvcBin(((OCSecurityPayload*)ehRequest->payload)->securityData, false);
 
     if (newSvc)
     {
@@ -256,7 +271,7 @@ static OCEntityHandlerResult HandleSVCPostRequest (const OCEntityHandlerRequest
         LL_APPEND(gSvc, newSvc);
 
         // Convert SVC data into JSON for update to persistent storage
-        char *jsonStr = BinToSvcJSON(gSvc);
+        char *jsonStr = BinToSvcJSON(gSvc, true);
         if (jsonStr)
         {
             cJSON *jsonSvc = cJSON_Parse(jsonStr);
@@ -351,7 +366,7 @@ OCStackResult InitSVCResource()
     if (jsonSVRDatabase)
     {
         // Convert JSON SVC into binary format
-        gSvc = JSONToSvcBin(jsonSVRDatabase);
+        gSvc = JSONToSvcBin(jsonSVRDatabase, true);
         OICFree(jsonSVRDatabase);
     }
 
index be35bb3..8dc9aef 100644 (file)
@@ -90,6 +90,8 @@ 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 08e7d26..e2ace8f 100644 (file)
@@ -45,8 +45,8 @@ using namespace std;
 extern "C" {
 #endif
 
-extern char * BinToAclJSON(const OicSecAcl_t * acl);
-extern OicSecAcl_t * JSONToAclBin(const char * jsonStr);
+extern char * BinToAclJSON(const OicSecAcl_t * acl, const bool isIncResName);
+extern OicSecAcl_t * JSONToAclBin(const char * jsonStr, const bool isIncResName);
 extern void DeleteACLList(OicSecAcl_t* acl);
 OCStackResult  GetDefaultACL(OicSecAcl_t** defaultAcl);
 OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag,
@@ -58,6 +58,8 @@ 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)
 
@@ -80,10 +82,10 @@ TEST(ACLResourceTest, JSONMarshallingTests)
         }
         jsonStr1[len + 1] = 0;
 
-        OicSecAcl_t * acl = JSONToAclBin(jsonStr1);
+        OicSecAcl_t * acl = JSONToAclBin(jsonStr1, true);
         EXPECT_TRUE(NULL != acl);
 
-        char * jsonStr2 = BinToAclJSON(acl);
+        char * jsonStr2 = BinToAclJSON(acl, true);
         EXPECT_TRUE(NULL != jsonStr2);
 
         EXPECT_STREQ(jsonStr1, jsonStr2);
@@ -101,7 +103,7 @@ TEST(ACLResourceTest, GetDefaultACLTests)
     char *jsonStr = ReadFile(DEFAULT_ACL_JSON_FILE_NAME);
     if (jsonStr)
     {
-        OicSecAcl_t * acl = JSONToAclBin(jsonStr);
+        OicSecAcl_t * acl = JSONToAclBin(jsonStr, true);
         EXPECT_TRUE(NULL != acl);
 
         // Invoke API to generate default ACL
@@ -140,7 +142,7 @@ TEST(ACLResourceTest, ACLPostTest)
     OCEntityHandlerRequest ehReq =  OCEntityHandlerRequest();
 
     // Read an ACL from the file
-    char *jsonStr = ReadFile(ACL1_JSON_FILE_NAME);
+    char *jsonStr = ReadFile(ACL_JSON_PAYLOAD_FILE_NAME);
     if (jsonStr)
     {
         static OCPersistentStorage ps = OCPersistentStorage();
@@ -155,7 +157,7 @@ TEST(ACLResourceTest, ACLPostTest)
         EXPECT_TRUE(OC_EH_ERROR == ehRet);
 
         // Convert JSON into OicSecAcl_t for verification
-        OicSecAcl_t * acl = JSONToAclBin(jsonStr);
+        OicSecAcl_t * acl = JSONToAclBin(jsonStr, false);
         EXPECT_TRUE(NULL != acl);
 
         // Verify if SRM contains ACL for the subject
@@ -179,10 +181,10 @@ TEST(ACLResourceTest, GetACLResourceTests)
     extern OicSecAcl_t  *gAcl;
 
     // Read an ACL from the file
-    char *jsonStr = ReadFile(ACL1_JSON_FILE_NAME);
+    char *jsonStr = ReadFile(ACL_JSON_PAYLOAD_FILE_NAME);
     if (jsonStr)
     {
-        gAcl = JSONToAclBin(jsonStr);
+        gAcl = JSONToAclBin(jsonStr, false);
         EXPECT_TRUE(NULL != gAcl);
 
         // Verify that ACL file contains 2 ACE entries for 'WILDCARD' subject
@@ -253,7 +255,7 @@ TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
     VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 1)), ERROR);
 
     //GET json POST payload
-    jsonStr = BinToAclJSON(&acl);
+    jsonStr = BinToAclJSON(&acl, false);
     VERIFY_NON_NULL(TAG, jsonStr, ERROR);
 
     // Create Entity Handler POST request payload
@@ -310,7 +312,7 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 2)), ERROR);
 
     //GET json POST payload
-    jsonStr = BinToAclJSON(&acl);
+    jsonStr = BinToAclJSON(&acl, false);
     VERIFY_NON_NULL(TAG, jsonStr, ERROR);
 
     // Create Entity Handler POST request payload
@@ -334,12 +336,6 @@ 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)
@@ -368,7 +364,7 @@ TEST(ACLResourceTest, ACLGetWithQueryTest)
     VERIFY_SUCCESS(TAG, (OC_STACK_OK == populateAcl(&acl, 1)), ERROR);
 
     //GET json POST payload
-    jsonStr = BinToAclJSON(&acl);
+    jsonStr = BinToAclJSON(&acl, false);
     VERIFY_NON_NULL(TAG, jsonStr, ERROR);
 
     //Create Entity Handler POST request payload
index 4c5b6b4..f840955 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
 OCStackResult CreateCredResource();
 OCEntityHandlerResult CredEntityHandler (OCEntityHandlerFlag flag,
                 OCEntityHandlerRequest * ehRequest);
-char * BinToCredJSON(const OicSecCred_t * pstat);
-OicSecCred_t * JSONToCredBin(const char * jsonStr);
+char * BinToCredJSON(const OicSecCred_t * pstat, const bool isIncResName);
+OicSecCred_t * JSONToCredBin(const char * jsonStr, const bool isIncResName);
 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);
+    jsonStr = BinToCredJSON(cred, false);
     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);
+    char* value = BinToCredJSON(NULL, true);
     EXPECT_TRUE(value == NULL);
 }
 
@@ -244,7 +244,7 @@ TEST(BinToCredJSONTest, BinToCredJSONValidCred)
     char* json = NULL;
     OicSecCred_t * cred = getCredList();
 
-    json = BinToCredJSON(cred);
+    json = BinToCredJSON(cred, true);
 
     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);
+    char* json = BinToCredJSON(cred1, true);
 
     EXPECT_TRUE(json != NULL);
-    OicSecCred_t *cred2 = JSONToCredBin(json);
+    OicSecCred_t *cred2 = JSONToCredBin(json, true);
     EXPECT_TRUE(cred2 != NULL);
     DeleteCredList(cred1);
     DeleteCredList(cred2);
@@ -268,7 +268,7 @@ TEST(JSONToCredBinTest, JSONToCredBinValidJSON)
 
 TEST(JSONToCredBinTest, JSONToCredBinNullJSON)
 {
-    OicSecCred_t *cred = JSONToCredBin(NULL);
+    OicSecCred_t *cred = JSONToCredBin(NULL, true);
     EXPECT_TRUE(cred == NULL);
 }
 
index f2de1dd..6c9f33a 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
 OCStackResult CreateDoxmResource();
 OCEntityHandlerResult DoxmEntityHandler (OCEntityHandlerFlag flag,
                 OCEntityHandlerRequest * ehRequest);
-char * BinToDoxmJSON(const OicSecDoxm_t * doxm);
-OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr);
+char * BinToDoxmJSON(const OicSecDoxm_t * doxm, const bool isIncResName);
+OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr, const bool isIncResName);
 void InitSecDoxmInstance(OicSecDoxm_t * doxm);
 OCEntityHandlerResult HandleDoxmPostRequest (const OCEntityHandlerRequest * ehRequest);
 void DeleteDoxmBinData(OicSecDoxm_t* doxm);
@@ -56,28 +56,10 @@ OicSecDoxm_t * getBinDoxm()
     {
         return NULL;
     }
-    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->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;
     }
@@ -156,7 +138,7 @@ TEST(DoxmEntityHandlerTest, DoxmEntityHandlerDeviceIdQuery)
 //BinToDoxmJSON Tests
 TEST(BinToDoxmJSONTest, BinToDoxmJSONNullDoxm)
 {
-    char* value = BinToDoxmJSON(NULL);
+    char* value = BinToDoxmJSON(NULL, true);
     EXPECT_TRUE(value == NULL);
 }
 
@@ -164,7 +146,7 @@ TEST(BinToDoxmJSONTest, BinToDoxmJSONValidDoxm)
 {
     OicSecDoxm_t * doxm =  getBinDoxm();
 
-    char * json = BinToDoxmJSON(doxm);
+    char * json = BinToDoxmJSON(doxm, true);
     OC_LOG_V(INFO, TAG, "BinToDoxmJSON:%s", json);
     EXPECT_TRUE(json != NULL);
 
@@ -176,10 +158,10 @@ TEST(BinToDoxmJSONTest, BinToDoxmJSONValidDoxm)
 TEST(JSONToDoxmBinTest, JSONToDoxmBinValidJSON)
 {
     OicSecDoxm_t * doxm1 =  getBinDoxm();
-    char * json = BinToDoxmJSON(doxm1);
+    char * json = BinToDoxmJSON(doxm1, true);
     EXPECT_TRUE(json != NULL);
 
-    OicSecDoxm_t *doxm2 = JSONToDoxmBin(json);
+    OicSecDoxm_t *doxm2 = JSONToDoxmBin(json, true);
     EXPECT_TRUE(doxm2 != NULL);
 
     DeleteDoxmBinData(doxm1);
@@ -189,7 +171,7 @@ TEST(JSONToDoxmBinTest, JSONToDoxmBinValidJSON)
 
 TEST(JSONToDoxmBinTest, JSONToDoxmBinNullJSON)
 {
-    OicSecDoxm_t *doxm = JSONToDoxmBin(NULL);
+    OicSecDoxm_t *doxm = JSONToDoxmBin(NULL, true);
     EXPECT_TRUE(doxm == NULL);
 }
 
@@ -206,7 +188,7 @@ TEST(HandleDoxmPostRequestTest, HandleDoxmPostRequestValidInput)
     svRequest.addressInfo.IP.port = 2345;
     svRequest.connectivityType = CA_ETHERNET;
 
-    ehRequest.reqJSONPayload = (unsigned char *) BinToDoxmJSON(doxm);
+    ehRequest.reqJSONPayload = (unsigned char *) BinToDoxmJSON(doxm, true);
     ehRequest.requestHandle = (OCRequestHandle) &svRequest;
 
     EXPECT_EQ(OC_EH_ERROR, HandleDoxmPostRequest(&ehRequest));
index 0b0a4a6..c48fdd6 100644 (file)
@@ -1,28 +1,28 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/res/types/d",
                 "/oic/ad"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat",
                 "/oic/sec/acl"
            ],
-             "perms": 6,
-             "ownrs" : [
+             "permission": 6,
+             "rowners" : [
                  "MjIyMjIyMjIyMjIyMjIyMg=="
              ]
         }
index 54cd36a..6abc526 100644 (file)
@@ -1,24 +1,24 @@
 {
     "acl": [
         {
-            "sub": "MTExMTExMTExMTExMTExMQ==",
-            "rsrc": [
+            "subject": "MTExMTExMTExMTExMTExMQ==",
+            "resources": [
                                "/oic/light",
                                "/oic/fan"
                        ],
-                       "perms": 255,
-                       "ownrs" : [
+                       "permission": 255,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
                {
-            "sub": "MzMzMzMzMzMzMzMzMzMzMw==",
-            "rsrc": [
+            "subject": "MzMzMzMzMzMzMzMzMzMzMw==",
+            "resources": [
                                "/oic/light",
                                "/oic/garage"
                        ],
-                       "perms": 255,
-                       "ownrs" : [
+                       "permission": 255,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg==",
                 "NDQ0NDQ0NDQ0NDQ0NDQ0NA=="
                        ]
 
     "amacl": [
         {
-            "rsrc": ["/a/led", "/a/fan"],
+            "resources": ["/a/led", "/a/fan"],
             "amss": [
                 "NTU1NTU1NTU1NTU1NTU1NQ==", 
                 "NjY2NjY2NjY2NjY2NjY2Ng=="
             ],
-                       "ownrs" : [
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
         {
-            "rsrc": ["/b/led", "/b/fan"],
+            "resources": ["/b/led", "/b/fan"],
             "amss": [
                 "NTU1NTU1NTU1NTU1NTU1NQ==", 
                 "NjY2NjY2NjY2NjY2NjY2Ng=="
             ],
-                       "ownrs" : [
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                }
 
 "svc": [
         {
-            "svcdid": "NTU1NTU1NTU1NTU1NTU1NQ==",
+            "svcid": "NTU1NTU1NTU1NTU1NTU1NQ==",
                        "svct": 1,
-                       "ownrs" : [
+                       "rowners" : [
                                "OTk5OTk5OTk5OTk5OTk5OQ=="
                        ]
                },
         {
-            "svcdid": "NjY2NjY2NjY2NjY2NjY2Ng==",
+            "svcid": "NjY2NjY2NjY2NjY2NjY2Ng==",
                        "svct": 1,
-                       "ownrs" : [
+                       "rowners" : [
                                "OTk5OTk5OTk5OTk5OTk5OQ=="
                        ]
                }
index a179c2c..0514f92 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/ad",
                 "/oic/sec/acl"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
                        ],
-                       "perms": 6,
-                       "ownrs" : [
+                       "permission": 6,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
         {
-            "sub": "MTExMTExMTExMTExMTExMQ==",
-            "rsrc": [
+            "subject": "MTExMTExMTExMTExMTExMQ==",
+            "resources": [
                                "/oic/light",
                                "/oic/fan"
                        ],
-                       "perms": 255,
-                       "ownrs" : [
+                       "permission": 255,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                },
                {
-            "sub": "MzMzMzMzMzMzMzMzMzMzMw==",
-            "rsrc": [
+            "subject": "MzMzMzMzMzMzMzMzMzMzMw==",
+            "resources": [
                                "/oic/light",
                                "/oic/garage"
                        ],
-                       "perms": 255,
-                       "ownrs" : [
+                       "permission": 255,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg==",
                 "NDQ0NDQ0NDQ0NDQ0NDQ0NA=="
                        ]
diff --git a/resource/csdk/security/unittest/oic_unittest_acl_payload.json b/resource/csdk/security/unittest/oic_unittest_acl_payload.json
new file mode 100644 (file)
index 0000000..334103c
--- /dev/null
@@ -0,0 +1,51 @@
+[
+    {
+        "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 7f3d449..5cef3c4 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
@@ -12,8 +12,8 @@
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
                        ],
-                       "perms": 2,
-                       "ownrs" : [
+                       "permission": 2,
+                       "rowners" : [
                                "MjIyMjIyMjIyMjIyMjIyMg=="
                        ]
                }
index 03c8a68..6a43742 100644 (file)
@@ -37,8 +37,8 @@ extern "C" {
 OCStackResult CreatePstatResource();
 OCEntityHandlerResult PstatEntityHandler (OCEntityHandlerFlag flag,
                                         OCEntityHandlerRequest * ehRequest);
-char * BinToPstatJSON(const OicSecPstat_t * pstat);
-OicSecPstat_t * JSONToPstatBin(const char * jsonStr);
+char * BinToPstatJSON(const OicSecPstat_t * pstat, const bool isIncResName);
+OicSecPstat_t * JSONToPstatBin(const char * jsonStr, const bool isIncResName);
 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);
+    char* value = BinToPstatJSON(NULL, true);
     EXPECT_TRUE(value == NULL);
 }
 
 TEST(JSONToBinTest, NullJSONToBin)
 {
-    OicSecPstat_t *pstat1 = JSONToPstatBin(NULL);
+    OicSecPstat_t *pstat1 = JSONToPstatBin(NULL, true);
     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);
+    char* jsonPstat = BinToPstatJSON(&pstat, true);
     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);
+    OicSecPstat_t *pstat1 = JSONToPstatBin(jsonPstat, true);
     EXPECT_TRUE(pstat1 != NULL);
     if(pstat1)
     {
@@ -157,10 +157,10 @@ TEST(PstatTests, JSONMarshalliingTests)
         }
         jsonStr1[len + 1] = 0;
 
-        OicSecPstat_t* pstat = JSONToPstatBin(jsonStr1);
+        OicSecPstat_t* pstat = JSONToPstatBin(jsonStr1, true);
         EXPECT_TRUE(NULL != pstat);
 
-        char* jsonStr2 = BinToPstatJSON(pstat);
+        char* jsonStr2 = BinToPstatJSON(pstat, true);
         EXPECT_STRNE(jsonStr1, jsonStr2);
 
         OICFree(jsonStr1);
index 5c3f75e..18948d7 100644 (file)
@@ -38,8 +38,8 @@ using namespace std;
 #ifdef __cplusplus
 extern "C" {
 #endif
-extern char * BinToSvcJSON(const OicSecSvc_t * svc);
-extern OicSecSvc_t * JSONToSvcBin(const char * jsonStr);
+extern char * BinToSvcJSON(const OicSecSvc_t * svc, const bool isIncResName);
+extern OicSecSvc_t * JSONToSvcBin(const char * jsonStr, const bool isIncResName);
 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);
+        OicSecSvc_t * svc = JSONToSvcBin(jsonStr1, true);
         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);
+        char * jsonStr2 = BinToSvcJSON(svc, true);
         EXPECT_TRUE(NULL != jsonStr2);
 
         OICFree(jsonStr1);
index 9543a87..b3dc715 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/sec/acl",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+                       "permission": 2,
+                       "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 2,
-             "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+             "permission": 2,
+             "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
         },
         {
-            "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
-            "rsrc": ["/oic/sec/acl",
+            "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
+            "resources": ["/oic/sec/acl",
                       "/oic/sec/cred"],
-            "perms": 8,
-            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+            "permission": 8,
+            "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
         },
         {
-            "sub": "NDQ0NDMzMzMyMjIyMTExMQ==",
-            "rsrc": ["/a/led"],
-            "perms": 6,
-            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+            "subject": "NDQ0NDMzMzMyMjIyMTExMQ==",
+            "resources": ["/a/led"],
+            "permission": 6,
+            "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
         }
        ],
        "pstat":        {
                "sct": 1,
                "owned": true,
                "deviceid":     "MTkxOTE5MTkxOTE5MTkxOQ==",
-               "ownr": "YWRtaW5EZXZpY2VVVUlEAA=="
+               "devowner":     "YWRtaW5EZXZpY2VVVUlEAA=="
        },
        "cred": [{
                "credid": 1,
-               "sub": "MTExMTExMTExMTExMTExMQ==",
-               "credtyp": 1,
-               "pvdata": "QkJCQkJCQkJCQkJCQkJCQg==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+               "subjectid": "MTExMTExMTExMTExMTExMQ==",
+               "credtype": 1,
+               "privatedata": "QkJCQkJCQkJCQkJCQkJCQg==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        }]
 }
index ca8fed4..7d80de5 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/sec/acl",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+                       "permission": 2,
+                       "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 2,
-             "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+             "permission": 2,
+             "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
         }
        ],
        "pstat":        {
                "sct": 1,
                "owned": true,
                "deviceid":     "MjIyMjIyMjIyMjIyMjIyMg==",
-               "ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
+               "devowner":     "MjIyMjIyMjIyMjIyMjIyMg=="
        },
     "cred":    [{
                "credid": 1,
-               "sub": "MTExMTExMTExMTExMTExMQ==",
-               "credtyp": 1,
-               "prd": "20150630T060000/20990920T220000",
-               "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+               "subjectid": "MTExMTExMTExMTExMTExMQ==",
+               "credtype": 1,
+               "period": "20150630T060000/20990920T220000",
+               "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        }]
 }
index 9456b41..01b18f2 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/sec/acl",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+                       "permission": 2,
+                       "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 2,
-             "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
+             "permission": 2,
+             "rowners" : ["MTExMTExMTExMTExMTExMQ=="]
         },
         {
-            "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
-            "rsrc": ["/oic/sec/acl",
+            "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
+            "resources": ["/oic/sec/acl",
                       "/oic/sec/cred"],
-            "perms": 8,
-            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+            "permission": 8,
+            "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
         },
         {
-            "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
-            "rsrc": ["/a/led"],
-            "perms": 6,
-            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+            "subject": "MjIyMjIyMjIyMjIyMjIyMg==",
+            "resources": ["/a/led"],
+            "permission": 6,
+            "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": "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": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
-            "rsrc": ["/a/led"],
-            "perms": 6,
-            "prds" : ["20150630T060000/20150630T220000"],
-            "recurs" : ["FREQ=DAILY; UNTIL=20150630"],
-            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+            "subject": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
+            "resources": ["/a/led"],
+            "permission": 6,
+            "periods" : ["20150630T060000/20150630T220000"],
+            "recurrence" : ["FREQ=DAILY; UNTIL=20150630"],
+            "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
         }
        ],
        "amacl": [{
-               "rsrc" : ["/a/led"],
+               "resources" : ["/a/led"],
                "amss" : ["MTkxOTE5MTkxOTE5MTkxOQ=="],
-               "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+               "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        }],
        "pstat":        {
                "isop": true,
                "sct": 1,
                "owned": true,
                "deviceid":     "MTExMTExMTExMTExMTExMQ==",
-               "ownr": "YWRtaW5EZXZpY2VVVUlEAA=="
+               "devowner":     "YWRtaW5EZXZpY2VVVUlEAA=="
        },
     "cred":    [{
                "credid": 1,
-               "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
-               "credtyp": 1,
-               "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+               "subjectid": "MjIyMjIyMjIyMjIyMjIyMg==",
+               "credtype": 1,
+               "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        },
        {
            "credid": 2,
-           "sub": "MTExMTIyMjIzMzMzNDQ0NA==",
-           "credtyp": 1,
-           "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+           "subjectid": "MTExMTIyMjIzMzMzNDQ0NA==",
+           "credtype": 1,
+           "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        },
        {
            "credid": 3,
-           "sub": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
-           "credtyp": 1,
-           "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+           "subjectid": "Nzc3Nzc3Nzc3Nzc3Nzc3Nw==",
+           "credtype": 1,
+           "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        },
        {
            "credid": 4,
-           "sub": "NDQ0NDMzMzMyMjIyMTExMQ==",
-           "credtyp": 1,
-           "pvdata": "QUFBQUFBQUFBQUFBQUFBQQ==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+           "subjectid": "NDQ0NDMzMzMyMjIyMTExMQ==",
+           "credtype": 1,
+           "privatedata": "QUFBQUFBQUFBQUFBQUFBQQ==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        },
        {
            "credid": 5,
-           "sub": "MTkxOTE5MTkxOTE5MTkxOQ==",
-           "credtyp": 1,
-           "pvdata": "QkJCQkJCQkJCQkJCQkJCQg==",
-        "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+           "subjectid": "MTkxOTE5MTkxOTE5MTkxOQ==",
+           "credtype": 1,
+           "privatedata": "QkJCQkJCQkJCQkJCQkJCQg==",
+        "rowners" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
        }]
 }
index 1219d6a..9bec918 100644 (file)
@@ -1,8 +1,8 @@
 {
     "acl": [
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/res",
                 "/oic/d",
                 "/oic/p",
                 "/oic/ad",
                 "/oic/sec/amacl"
                        ],
-                       "perms": 2,
-                       "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+                       "permission": 2,
+                       "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
                },
         {
-            "sub": "Kg==",
-            "rsrc": [
+            "subject": "Kg==",
+            "resources": [
                 "/oic/sec/doxm",
                 "/oic/sec/pstat"
              ],
-             "perms": 2,
-             "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
+             "permission": 2,
+             "rowners" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
         }
        ],
        "pstat":        {
@@ -38,6 +38,6 @@
                "sct": 1,
                "owned": true,
                "deviceid":     "YWRtaW5EZXZpY2VVVUlEMA==",
-               "ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
+               "devowner":     "YWRtaW5EZXZpY2VVVUlEMA=="
        }
 }