From e3a136f22d2c08a237b7b949d914a9f299fea3d8 Mon Sep 17 00:00:00 2001 From: Jongmin Choi Date: Mon, 10 Oct 2016 19:58:57 +0900 Subject: [PATCH] Set ACL Rowner to PT's Device ID in SRPProvisionACL 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/13037 Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh --- .../provisioning/src/secureresourceprovider.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/resource/csdk/security/provisioning/src/secureresourceprovider.c b/resource/csdk/security/provisioning/src/secureresourceprovider.c index d68e4da..3a8f242 100644 --- a/resource/csdk/security/provisioning/src/secureresourceprovider.c +++ b/resource/csdk/security/provisioning/src/secureresourceprovider.c @@ -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; -- 2.7.4