security: Example support SVR ACL v2 and fix PS 89/21489/9
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Tue, 29 Aug 2017 15:11:59 +0000 (17:11 +0200)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Fri, 15 Sep 2017 23:28:18 +0000 (23:28 +0000)
Update json file to support ACL from CSDK, inspired by:
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_devowner.json
resource/csdk/stack/samples/linux/secure/oic_svr_db_server.json

Also add persistent storage to overload security dat file.

Make example working again using:

  ./simpleserver 2

  ./simpleclient
  Observe registration action is successful
  OBSERVE RESULT:
        SequenceNumber: 0
        state: true
        power: 55
        name: John's light

Note those .dat files were generated from master branch
using json2cbor tool automatically,
1.3-rel does not have the scanner generator yet.

Bug: https://jira.iotivity.org/browse/IOT-2443
Change-Id: Id457fedd74bf7540c2a223e4ab079076af1f2134
Origin: https://gerrit.iotivity.org/gerrit/#/c/21487/
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
resource/examples/oic_svr_db_client.dat
resource/examples/oic_svr_db_client.json
resource/examples/oic_svr_db_server.dat
resource/examples/oic_svr_db_server.json
resource/examples/simpleserver.cpp

index 2d3f18c..dc9fd24 100644 (file)
Binary files a/resource/examples/oic_svr_db_client.dat and b/resource/examples/oic_svr_db_client.dat differ
index 3684991..f853b45 100644 (file)
@@ -1,90 +1,61 @@
-{\r
-    "acl": {\r
-        "aclist": {\r
-            "aces": [\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/res",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.res"],\r
-                            "if": ["oic.if.ll"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/d",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.d"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/p",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.p"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/acl",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.acl"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/sec/doxm",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.doxm"],\r
-                            "if": ["oic.if.baseline"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/pstat",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.pstat"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                }\r
-            ]\r
-        },\r
-        "rowneruuid" : "32323232-3232-3232-3232-323232323232"\r
-    },\r
-    "pstat": {\r
-        "dos": {"s": 3, "p": false},\r
-        "isop": true,\r
-        "deviceuuid": "32323232-3232-3232-3232-323232323232",\r
-        "rowneruuid": "32323232-3232-3232-3232-323232323232",\r
-        "cm": 0,\r
-        "tm": 0,\r
-        "om": 4,\r
-        "sm": 4\r
-        },\r
-    "doxm": {\r
-        "oxms": [0],\r
-        "oxmsel": 0,\r
-        "sct": 9,\r
-        "owned": true,\r
-        "deviceuuid": "32323232-3232-3232-3232-323232323232",\r
-        "devowneruuid": "32323232-3232-3232-3232-323232323232",\r
-        "rowneruuid": "32323232-3232-3232-3232-323232323232"\r
-    },\r
-    "cred": {\r
-        "creds": [\r
-            {\r
-                "credid": 1,\r
-                "subjectuuid": "31313131-3131-3131-3131-313131313131",\r
-                "credtype": 1,\r
-                "privatedata": {\r
-                    "data": "AAAAAAAAAAAAAAAA",\r
-                    "encoding": "oic.sec.encoding.raw"\r
-                }\r
-            }\r
-        ],\r
-        "rowneruuid": "32323232-3232-3232-3232-323232323232"\r
-    }\r
-}
\ No newline at end of file
+{
+    "acl": {
+        "aclist2": [
+            {
+                "aceid": 1,
+                "subject": { "conntype": "anon-clear" },
+                "resources": [
+                    { "href": "/oic/res" },
+                    { "href": "/oic/d" },
+                    { "href": "/oic/p" },
+                    { "href": "/oic/sec/doxm" }
+                ],
+                "permission": 2
+            },
+            {
+                "aceid": 2,
+                "subject": { "conntype": "auth-crypt" },
+                "resources": [
+                    { "href": "/oic/res" },
+                    { "href": "/oic/d" },
+                    { "href": "/oic/p" },
+                    { "href": "/oic/sec/doxm" }
+                ],
+                "permission": 2
+            }
+        ],
+        "rowneruuid" : "32323232-3232-3232-3232-323232323232"
+    },
+    "pstat": {
+        "dos": {"s": 3, "p": false},
+        "isop": true,
+        "rowneruuid": "32323232-3232-3232-3232-323232323232",
+        "cm": 0,
+        "tm": 0,
+        "om": 4,
+        "sm": 4
+        },
+    "doxm": {
+        "oxms": [0],
+        "oxmsel": 0,
+        "sct": 9,
+        "owned": true,
+        "deviceuuid": "32323232-3232-3232-3232-323232323232",
+        "devowneruuid": "32323232-3232-3232-3232-323232323232",
+        "rowneruuid": "32323232-3232-3232-3232-323232323232"
+    },
+    "cred": {
+        "creds": [
+            {
+                "credid": 1,
+                "subjectuuid": "31313131-3131-3131-3131-313131313131",
+                "credtype": 1,
+                "privatedata": {
+                    "data": "AAAAAAAAAAAAAAAA",
+                    "encoding": "oic.sec.encoding.raw"
+                }
+            }
+        ],
+        "rowneruuid": "32323232-3232-3232-3232-323232323232"
+    }
+}
index ccae7d3..ca853b3 100644 (file)
Binary files a/resource/examples/oic_svr_db_server.dat and b/resource/examples/oic_svr_db_server.dat differ
index e4ce270..440023c 100644 (file)
-{\r
-    "acl": {\r
-        "aclist": {\r
-            "aces": [\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/res",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.res"],\r
-                            "if": ["oic.if.ll"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/d",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.d"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/p",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.p"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/acl",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.acl"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/sec/doxm",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.doxm"],\r
-                            "if": ["oic.if.baseline"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/pstat",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.pstat"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/a/light",\r
-                            "rel": "",\r
-                            "rt": ["oic.core"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 7\r
-                }\r
-            ]\r
-        },\r
-        "rowneruuid" : "31313131-3131-3131-3131-313131313131"\r
-    },\r
-    "pstat": {\r
-        "dos": {"s": 3, "p": false},\r
-        "isop": true,\r
-        "deviceuuid": "31313131-3131-3131-3131-313131313131",\r
-        "rowneruuid": "31313131-3131-3131-3131-313131313131",\r
-        "cm": 0,\r
-        "tm": 0,\r
-        "om": 4,\r
-        "sm": 4\r
-        },\r
-    "doxm": {\r
-        "oxms": [0],\r
-        "oxmsel": 0,\r
-        "sct": 9,\r
-        "owned": true,\r
-        "deviceuuid": "31313131-3131-3131-3131-313131313131",\r
-        "devowneruuid": "32323232-3232-3232-3232-323232323232",\r
-        "rowneruuid": "31313131-3131-3131-3131-313131313131"\r
-    },\r
-    "cred": {\r
-        "creds": [\r
-            {\r
-                "credid": 1,\r
-                "subjectuuid": "32323232-3232-3232-3232-323232323232",\r
-                "credtype": 1,\r
-                "privatedata": {\r
-                    "data": "AAAAAAAAAAAAAAAA",\r
-                    "encoding": "oic.sec.encoding.raw"\r
-                }\r
-            }\r
-        ],\r
-        "rowneruuid": "31313131-3131-3131-3131-313131313131"\r
-    }\r
-}
\ No newline at end of file
+{
+    "acl": {
+        "aclist2": [
+            {
+                "aceid": 1,
+                "subject": { "conntype": "anon-clear" },
+                "resources": [
+                    { "href": "/oic/res" },
+                    { "href": "/oic/d" },
+                    { "href": "/oic/p" },
+                    { "href": "/oic/sec/doxm" }
+                ],
+                "permission": 2
+            },
+            {
+                "aceid": 2,
+                "subject": { "conntype": "auth-crypt" },
+                "resources": [
+                    { "href": "/oic/res" },
+                    { "href": "/oic/d" },
+                    { "href": "/oic/p" },
+                    { "href": "/oic/sec/doxm" }
+                ],
+                "permission": 2
+            },
+            {
+                "aceid": 3,
+                "subject": { "uuid": "32323232-3232-3232-3232-323232323232" },
+                "resources": [{ "wc": "*" }],
+                "permission": 7
+            },
+            {
+                "aceid": 4,
+                "subject": { "uuid": "31393139-3139-3139-3139-313931393139" },
+                "resources": [{ "href": "/a/light" }],
+                "permission": 7
+            }
+        ],
+        "rowneruuid" : "31313131-3131-3131-3131-313131313131"
+    },
+    "pstat": {
+        "dos": {"s": 3, "p": false},
+        "isop": true,
+        "rowneruuid": "31313131-3131-3131-3131-313131313131",
+        "cm": 0,
+        "tm": 0,
+        "om": 4,
+        "sm": 4
+        },
+    "doxm": {
+        "oxms": [0],
+        "oxmsel": 0,
+        "sct": 9,
+        "owned": true,
+        "deviceuuid": "31313131-3131-3131-3131-313131313131",
+        "devowneruuid": "32323232-3232-3232-3232-323232323232",
+        "rowneruuid": "31313131-3131-3131-3131-313131313131"
+    },
+    "cred": {
+        "creds": [
+            {
+                "credid": 1,
+                "subjectuuid": "32323232-3232-3232-3232-323232323232",
+                "credtype": 1,
+                "period": "20150630T060000/20990920T220000",
+                "privatedata": {
+                    "data": "AAAAAAAAAAAAAAAA",
+                    "encoding": "oic.sec.encoding.raw"
+                }
+            },
+            {
+                "credid": 2,
+                "subjectuuid": "31393139-3139-3139-3139-313931393139",
+                "credtype": 1,
+                "period": "20150630T060000/20990920T220000",
+                "privatedata": {
+                    "data": "BBBBBBBBBBBBBBBB",
+                    "encoding": "oic.sec.encoding.raw"
+                }
+            }
+        ],
+        "rowneruuid": "32323232-3232-3232-3232-323232323232"
+    }
+}
index 0553b23..f87cd7f 100644 (file)
@@ -619,14 +619,16 @@ void PrintUsage()
 
 static FILE* client_open(const char* path, const char* mode)
 {
-    if (strcmp(path, OC_INTROSPECTION_FILE_NAME) == 0)
+    char const * filename = path;
+    if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))
     {
-        return fopen("light_introspection.json", mode);
+        filename = SVR_DB_FILE_NAME;
     }
-    else
+    else if (0 == strcmp(path, OC_INTROSPECTION_FILE_NAME))
     {
-        return fopen(SVR_DB_FILE_NAME, mode);
+        filename = "light_introspection.json";
     }
+    return fopen(filename, mode);
 }
 
 int main(int argc, char* argv[])