Set ACL Rowner to PT's Device ID in SRPProvisionACL
authorJongmin Choi <jminl.choi@samsung.com>
Mon, 10 Oct 2016 10:58:57 +0000 (19:58 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 13 Oct 2016 04:27:01 +0000 (04:27 +0000)
If Rowner of ACL to be provisioned in SRPProvisionACL is empty,
Set it to PT's Device ID

Patch #1: Initial upload
Patch #2: Jongsung's recommendation applied
Patch #3: Fix typo
Patch #4-5: GetDoxmDeviceID failure taken care of

Change-Id: I38886d32fd35f39370d4e5e46e39b66edfc0f003
Signed-off-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13037
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/src/secureresourceprovider.c

index d68e4da..3a8f242 100644 (file)
@@ -867,6 +867,25 @@ OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceI
     VERIFY_NON_NULL(TAG, acl, ERROR,  OC_STACK_INVALID_PARAM);
     VERIFY_NON_NULL(TAG, resultCallback, ERROR,  OC_STACK_INVALID_CALLBACK);
 
+    // if rowneruuid is empty, set it to device ID
+    OicUuid_t emptyOwner = {.id = {0} };
+    if (memcmp(&(acl->rownerID.id), &emptyOwner, UUID_IDENTITY_SIZE) == 0)
+    {
+        OIC_LOG(DEBUG, TAG, "Set Rowner to PT's deviceId, because Rowner of ACL is empty");
+        OicUuid_t oicUuid;
+
+        if (OC_STACK_OK == GetDoxmDeviceID(&oicUuid))
+        {
+            memcpy(&(acl->rownerID.id), &oicUuid, UUID_IDENTITY_SIZE);
+        }
+        else
+        {
+            OIC_LOG(DEBUG, TAG, "Failed to set Rowner to PT's deviceID\
+                becuase it failed to retrieve Doxm DeviceID");
+            return OC_STACK_ERROR;
+        }
+    }
+
     OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
     if(!secPayload)
     {
@@ -2366,7 +2385,7 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
         goto error;
     }
     OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-    
+
     OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
     OCMethod method = OC_REST_POST;
     OCDoHandle handle = NULL;