[IOT-1366] coaps request for secure resource
authorRandeep Singh <randeep.s@samsung.com>
Thu, 6 Oct 2016 15:12:19 +0000 (20:42 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 7 Oct 2016 06:44:01 +0000 (06:44 +0000)
handled pending review comments

Change-Id: Iacde7395b7a5da53caff7f175beb3d3e17dd9894
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12907
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashwini Kumar <k.ashwini@samsung.com>
resource/csdk/security/src/secureresourcemanager.c

index 1d6b0f2..694c646 100644 (file)
@@ -148,10 +148,11 @@ void SRMRequestHandler(const CAEndpoint_t *endPoint, const CARequestInfo_t *requ
 
     // Copy the subjectID
     OicUuid_t subjectId = {.id = {0}};
+    OicUuid_t nullSubjectId = {.id = {0}};
     memcpy(subjectId.id, requestInfo->info.identity.id, sizeof(subjectId.id));
 
     // if subject id is null that means request is sent thru coap.
-    if (NULL != subjectId.id)
+    if (memcmp(subjectId.id, nullSubjectId.id, sizeof(subjectId.id)) != 0)
     {
         OIC_LOG(INFO, TAG, "request over secure channel");
         isRequestOverSecureChannel = true;
@@ -189,8 +190,9 @@ void SRMRequestHandler(const CAEndpoint_t *endPoint, const CARequestInfo_t *requ
     OCResource *resPtr = FindResourceByUri(newUri);
     if (NULL != resPtr)
     {
-        // check whether request is for secure resource or not
-        if (((resPtr->resourceProperties) & OC_SECURE))
+        // check whether request is for secure resource or not and it should not be a SVR resource
+        if (((resPtr->resourceProperties) & OC_SECURE)
+                            && (g_policyEngineContext.resourceType == NOT_A_SVR_RESOURCE))
         {
            // if resource is secure and request is over insecure channel
             if (!isRequestOverSecureChannel)