[IOT-3271] additional policyengine logging 32/29332/2
authorNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Thu, 14 Mar 2019 04:53:02 +0000 (21:53 -0700)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Tue, 19 Mar 2019 16:28:52 +0000 (16:28 +0000)
Added logging to policyengine and removed a corner-case match leftover
from pre-OCF-1.3 wildcard definitions.

Change-Id: I89df91f81ac28d82ad7bf84ab1895d6cb4b75cd5
Signed-off-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
resource/csdk/security/src/policyengine.c

index 90a01c1..aeded09 100644 (file)
@@ -596,12 +596,22 @@ static bool IsResourceInAce(SRMRequestContext_t *context, const OicSecAce_t *ace
     }
 
     OicSecRsrc_t* rsrc = NULL;
+    int debugLoggingResourceCounter = 0;
+
+    OIC_LOG_V(DEBUG, TAG, "%s: checking aceid %d for resource matching request for %s.",
+                        __func__, ace->aceid,context->resourceUri);
     LL_FOREACH(ace->resources, rsrc)
     {
+        OIC_LOG_V(DEBUG, TAG, "%s: checking resource %d in aceid %d.",
+                        __func__, debugLoggingResourceCounter, ace->aceid);
         if (NULL == rsrc->href)
         {
+            OIC_LOG_V(DEBUG, TAG, "%s: resource %d has null value in href.",
+                        __func__, debugLoggingResourceCounter);
             if (NO_WILDCARD != rsrc->wildcard)
             {
+                OIC_LOG_V(DEBUG, TAG, "%s: resource %d has wildcard = %d; see OicSecAceResourceWildcard enum.",
+                        __func__, debugLoggingResourceCounter, rsrc->wildcard);
                 if  (IsNonConfigurationResourceUri(context->resourceUri) &&
                         (
                             // "*" matches all NCRs
@@ -623,20 +633,27 @@ static bool IsResourceInAce(SRMRequestContext_t *context, const OicSecAce_t *ace
                         )
                     )
                 {
-                    OIC_LOG_V(DEBUG, TAG, "%s: found wc type %d matching resource.",
+                    OIC_LOG_V(DEBUG, TAG, "%s: found wc type %d matching Non-Configuration Resource.",
                         __func__, rsrc->wildcard);
                     return true;
                 }
             }
         }
-        else if (0 == strcmp(context->resourceUri, rsrc->href) ||
-                 0 == strcmp(WILDCARD_RESOURCE_URI, rsrc->href))
+        else if (0 == strcmp(context->resourceUri, rsrc->href))
         {
-            OIC_LOG_V(DEBUG, TAG, "%s: found href %s matching resource.",
-                        __func__, rsrc->href);
+            OIC_LOG_V(DEBUG, TAG, "%s: found href %s matching resource %s in resource %d from aceid %d.",
+                        __func__, rsrc->href, context->resourceUri, debugLoggingResourceCounter, ace->aceid);
             return true;
         }
+        else
+        {
+            OIC_LOG_V(DEBUG, TAG, "%s: resource %d does not match requested resource.",
+                        __func__, debugLoggingResourceCounter);
+        }
+        debugLoggingResourceCounter++;
     }
+    OIC_LOG_V(DEBUG, TAG, "%s: aceid %d does not contain a resource match for requested resource %s.",
+                        __func__, ace->aceid, context->resourceUri);
     return false;
 }