Update pstat init API to fill device id of pstat as doxm's uuid
authorleechul <chuls.lee@samsung.com>
Mon, 28 Mar 2016 07:16:00 +0000 (16:16 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 29 Mar 2016 06:19:35 +0000 (06:19 +0000)
in case of pstat's device id is empty.

If you want test with empty device uuid,
please use the resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat

Patch #1 : Intial upload
Patch #2 : Add json file according to Mr.JongSung Lee's comment.

Change-Id: I9c791074cd5abe179c2c4cccbb66e0d95d044399
Signed-off-by: leechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7383
Reviewed-by: Kyungsun Cho <goodsun.cho@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat [new file with mode: 0644]
resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.json [new file with mode: 0644]
resource/csdk/security/src/pstatresource.c

index 1f811cf..a4f645d 100644 (file)
@@ -80,8 +80,10 @@ justworksdat = provisioning_env.Install(sec_provisioning_build_dir,
                                     sec_provisioning_src_dir + 'oic_svr_db_server_justworks.dat')
 randompindat = provisioning_env.Install(sec_provisioning_build_dir,
                                     sec_provisioning_src_dir+ 'oic_svr_db_server_randompin.dat')
+randompin_with_emptyuuid_dat = provisioning_env.Install(sec_provisioning_build_dir,
+                                    sec_provisioning_src_dir+ 'oic_svr_db_randompin_with_empty_deviceid.dat')
 
-Alias("samples", [provisioningclient, sampleserver_justworks, sampleserver_randompin, clientdat, justworksdat, randompindat])
+Alias("samples", [provisioningclient, sampleserver_justworks, sampleserver_randompin, clientdat, justworksdat, randompindat, randompin_with_emptyuuid_dat])
 
 provisioning_env.AppendTarget('samples')
 
diff --git a/resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat b/resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat
new file mode 100644 (file)
index 0000000..3f27f59
Binary files /dev/null and b/resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.dat differ
diff --git a/resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.json b/resource/csdk/security/provisioning/sample/oic_svr_db_randompin_with_empty_deviceid.json
new file mode 100644 (file)
index 0000000..0f73d7d
--- /dev/null
@@ -0,0 +1,118 @@
+{
+    "acl": {
+        "aclist": {
+            "aces": [
+                {
+                    "subjectuuid": "*",
+                    "resources": [
+                        {
+                            "href": "/oic/res",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/res/d",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/res/types/d",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/presence",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        }
+                    ],
+                    "permission": 2
+                },
+                {
+                    "subjectuuid": "*",
+                    "resources": [
+                        {
+                            "href": "/oic/sec/doxm",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/sec/pstat",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/sec/acl",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/sec/cred",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        }
+                    ],
+                    "permission": 6
+                },
+                {
+                    "subjectuuid": "*",
+                    "resources": [
+                        {
+                            "href": "/oic/sec/pconf",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        },
+                        {
+                            "href": "/oic/sec/dpairing",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        }
+                    ],
+                    "permission": 6
+                },
+                {
+                    "subjectuuid": "*",
+                    "resources": [
+                        {
+                            "href": "/oic/sec/ver",
+                            "rel": "",
+                            "rt": "",
+                            "if": ""
+                        }
+                    ],
+                    "permission": 2
+                }
+            ]
+        },
+        "rowneruuid" : ""
+    },
+    "pstat": {
+        "isop": false,
+        "deviceuuid": "",
+        "rowneruuid": "",
+        "cm": 2,
+        "tm": 0,
+        "om": 3,
+        "sm": 3
+        },
+    "doxm": {
+        "oxms": [0, 1],
+        "oxmsel": 0,
+        "sct": 1,
+        "owned": false,
+        "deviceuuid": "",
+        "devowneruuid": "",
+        "rowneruuid": "",
+        "dpc": true
+    }
+}
index f13bb1b..25f143c 100644 (file)
@@ -499,9 +499,21 @@ OCStackResult InitPstatResource()
     }
     if (data)
     {
+        OicUuid_t emptyUuid = {.id={0}};
+
         // Read ACL resource from PS
         ret = CBORPayloadToPstat(data, size, &gPstat);
         OICFree(data);
+
+        //In case of PStat's device id is empty, fill the device id as doxm's device id.
+        if(memcmp(&gPstat->deviceID, &emptyUuid, sizeof(OicUuid_t)) == 0)
+        {
+            OicUuid_t doxmUuid = {.id={0}};
+            if(OC_STACK_OK == GetDoxmDeviceID(&doxmUuid))
+            {
+                memcpy(&gPstat->deviceID, &doxmUuid, sizeof(OicUuid_t));
+            }
+        }
     }
     /*
      * If SVR database in persistent storage got corrupted or