Fix Cloud ACL CSdk issues
authorAndrii Shtompel <a.shtompel@samsung.com>
Fri, 10 Mar 2017 12:33:42 +0000 (14:33 +0200)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 29 Mar 2017 04:14:34 +0000 (04:14 +0000)
1. Rename:
   OCCloudAclIndividualDelete    -> OCCloudAclAcesDelete
   OCCloudAclIndividualDeleteAce -> OCCloudAclIndividualAceDelete
   OCCloudAclIndividualUpdateAce -> OCCloudAclIndividualAclUpdate
   OCCloudAclIndividualUpdate    -> OCCloudAclIndividualAceUpdate

2. Pass OCClientResponse *response to application layer to print
   received payload for every response in release mode

3. Create OIC_LOG_ACL/OIC_LOG_CRL macro instead of printACL/printCRL functions
   (they will print log in modules where TB_LOG enabled)

Change-Id: I2bff159c1cc7ad3620da21a0c2722a3445608a77
Signed-off-by: Andrii Shtompel <a.shtompel@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17825
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-by: Oleksii Beketov <ol.beketov@samsung.com>
Reviewed-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
17 files changed:
resource/csdk/security/include/internal/acl_logging.h [new file with mode: 0644]
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/crl_logging.h [new file with mode: 0644]
resource/csdk/security/include/internal/crlresource.h
resource/csdk/security/provisioning/include/cloud/occloudprovisioning.h
resource/csdk/security/provisioning/sample/cloud/cloudCommon.c
resource/csdk/security/provisioning/sample/cloud/cloudWrapper.c
resource/csdk/security/provisioning/src/cloud/aclid.c
resource/csdk/security/provisioning/src/cloud/utils.c
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/crlresource.c
resource/csdk/stack/octbstack_product_with_tcp.def
resource/include/OCCloudProvisioning.hpp
resource/provisioning/examples/cloudAuth.cpp
resource/provisioning/examples/cloudClient.cpp
resource/provisioning/examples/cloudWrapper.cpp
resource/provisioning/src/OCCloudProvisioning.cpp

diff --git a/resource/csdk/security/include/internal/acl_logging.h b/resource/csdk/security/include/internal/acl_logging.h
new file mode 100644 (file)
index 0000000..5d26284
--- /dev/null
@@ -0,0 +1,137 @@
+//******************************************************************
+//
+// Copyright 2017 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef ACL_LOGGING_H_
+#define ACL_LOGGING_H_
+
+#include "logger.h"
+#include "oic_malloc.h"
+#include "ocrandom.h"
+#include "utlist.h"
+#include "securevirtualresourcetypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define ACL_TAG "ACL_LOG"
+
+#ifdef TB_LOG
+    #define OIC_LOG_ACL(level, acl) printACL((level),(acl))
+    #define OIC_LOG_ACE(level, ace) printACE((level),(ace))
+
+INLINE_API void printACE(LogLevel level, const OicSecAce_t *ace)
+{
+    OIC_LOG(level, ACL_TAG, "=================================================");
+    OIC_LOG_V(level, ACL_TAG, "ACE @ %p", ace);
+
+    if (NULL == ace)
+    {
+        return;
+    }
+
+    OIC_LOG_V(level, ACL_TAG, "    permission = %#x", (uint32_t)ace->permission);
+
+    // Log the subjectuuid.
+    char uuidString[UUID_STRING_SIZE] = { 0 };
+    bool convertedUUID = OCConvertUuidToString(ace->subjectuuid.id, uuidString);
+    OIC_LOG_V(level, ACL_TAG, "    subjectuuid = %s", convertedUUID ? uuidString : "incorrect format");
+
+    // Log all resources this ACE applies to.
+    OicSecRsrc_t *resource = NULL;
+    size_t resourceCount = 0;
+    LL_FOREACH(ace->resources, resource)
+    {
+        OIC_LOG_V(level, ACL_TAG, "    resources[%" PRIuPTR "]:", resourceCount);
+        OIC_LOG_V(level, ACL_TAG, "        href = %s", resource->href ? resource->href : "null");
+
+        for (size_t i = 0; i < resource->typeLen; i++)
+        {
+            OIC_LOG_V(level, ACL_TAG, "        types[%" PRIuPTR "] = %s", i,
+                resource->types[i] ? resource->types[i] : "null");
+        }
+
+        for (size_t i = 0; i < resource->interfaceLen; i++)
+        {
+            OIC_LOG_V(level, ACL_TAG, "        interfaces[%" PRIuPTR "] = %s", i,
+                resource->interfaces[i] ? resource->interfaces[i] : "null");
+        }
+
+        resourceCount++;
+    }
+
+    // Log the validities.
+    OicSecValidity_t *validity = NULL;
+    size_t validityCount = 0;
+    LL_FOREACH(ace->validities, validity)
+    {
+        OIC_LOG_V(level, ACL_TAG, "    validities[%" PRIuPTR "]:", validityCount);
+        OIC_LOG_V(level, ACL_TAG, "        period = %s", validity->period);
+        for (size_t i = 0; i < validity->recurrenceLen; i++)
+        {
+            OIC_LOG_V(level, ACL_TAG, "    recurrences[%" PRIuPTR "] = %s", i,
+                validity->recurrences[i] ? validity->recurrences[i] : "null");
+        }
+        validityCount++;
+    }
+
+    OIC_LOG(level, ACL_TAG, "=================================================");
+}
+
+INLINE_API void printACL(LogLevel level, const OicSecAcl_t* acl)
+{
+    OIC_LOG_V(level, ACL_TAG, "Print ACL @ %p:", acl);
+
+    if (NULL == acl)
+    {
+        return;
+    }
+
+    char rowner[UUID_STRING_SIZE] = { 0 };
+    if (OCConvertUuidToString(acl->rownerID.id, rowner))
+    {
+        OIC_LOG_V(level, ACL_TAG, "rowner id = %s", rowner);
+    }
+    else
+    {
+        OIC_LOG(ERROR, ACL_TAG, "Can't convert rowner uuid to string");
+    }
+
+    const OicSecAce_t *ace = acl->aces;
+    size_t ace_count = 0;
+    while (ace)
+    {
+        OIC_LOG_V(level, ACL_TAG, "Print ace[%" PRIuPTR "]:", ace_count);
+        printACE(level, ace);
+        ace = ace->next;
+        ace_count++;
+    }
+}
+#else
+    #define OIC_LOG_ACL(level, acl)
+    #define OIC_LOG_ACE(level, ace)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index dec810a..4d29a77 100644 (file)
@@ -176,14 +176,6 @@ OCStackResult GetAclRownerId(OicUuid_t *rowneruuid);
  */
 OicSecAcl_t* CBORPayloadToAcl2(const uint8_t *cborPayload, const size_t size);
 
-/**
- * This function prints ACL to stdin
- * For debug purposes only
- *
- * @param acl  acl to print
- */
-void printACL(const OicSecAcl_t* acl);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/resource/csdk/security/include/internal/crl_logging.h b/resource/csdk/security/include/internal/crl_logging.h
new file mode 100644 (file)
index 0000000..c60b76f
--- /dev/null
@@ -0,0 +1,63 @@
+//******************************************************************
+//
+// Copyright 2017 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef CRL_LOGGING_H_
+#define CRL_LOGGING_H_
+
+#include "logger.h"
+#include "securevirtualresourcetypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define CRL_TAG "CRL_LOG"
+
+#ifdef TB_LOG
+    #define OIC_LOG_CRL(level, crl) printCRL((level),(crl))
+
+INLINE_API void printCRL(LogLevel level, const OicSecCrl_t *crl)
+{
+    OIC_LOG_V(level, CRL_TAG, "Print CRL @ %p:", crl);
+
+    if (NULL == crl)
+    {
+        return;
+    }
+
+    OIC_LOG(level, CRL_TAG, "CRL object contains:");
+    OIC_LOG_V(level, CRL_TAG, "id = %d", crl->CrlId);
+    OIC_LOG_V(level, CRL_TAG, "this update = %s", crl->ThisUpdate.data);
+
+    OIC_LOG(level, CRL_TAG, "crl:");
+    OIC_LOG_V(level, CRL_TAG, "encoding = %d", crl->CrlData.encoding);
+    OIC_LOG_V(level, CRL_TAG, "data (length = %" PRIuPTR "):", crl->CrlData.len);
+    OIC_LOG_BUFFER(level, CRL_TAG, crl->CrlData.data, crl->CrlData.len);
+}
+#else
+    #define OIC_LOG_CRL(level, crl)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 20acfe4..ce1d415 100644 (file)
@@ -120,13 +120,6 @@ void DeleteCrl(OicSecCrl_t *crl);
  */
 OCStackResult getLastUpdateFromDB(char **lastUpdate);
 
-/**
- * This function prints OicSecCrl_t object
- *
- * @param crl  crl object
- */
-void printCrl(const OicSecCrl_t *crl);
-
 #ifdef __cplusplus
 }
 #endif
index 6e2da24..8747e09 100644 (file)
@@ -27,7 +27,7 @@
 extern "C" {
 #endif // __cplusplus
 
-typedef void (*OCCloudResponseCB )(void* ctx, OCStackResult result, void* data);
+typedef void (*OCCloudResponseCB )(void* ctx, OCClientResponse* response, void* data);
 
 typedef struct cloudAce cloudAce_t;
 
@@ -168,7 +168,7 @@ OCStackResult OCCloudAclIndividualGetInfo(void* ctx,
  * @param[in] callback          optional result callback, can be NULL if not required
  * @return  OCStackResult application result
  */
-OCStackResult OCCloudAclIndividualUpdateAce(void* ctx,
+OCStackResult OCCloudAclIndividualAclUpdate(void* ctx,
                                             const char *aclId,
                                             const cloudAce_t *aces,
                                             const OCDevAddr *endPoint,
@@ -185,7 +185,7 @@ OCStackResult OCCloudAclIndividualUpdateAce(void* ctx,
  * @param[in] callback          optional result callback, can be NULL if not required
  * @return  OCStackResult application result
  */
-OCStackResult OCCloudAclIndividualUpdate(void* ctx,
+OCStackResult OCCloudAclIndividualAceUpdate(void* ctx,
                                             const char *aclId,
                                             const char *aceId,
                                             const cloudAce_t *aces,
@@ -201,7 +201,7 @@ OCStackResult OCCloudAclIndividualUpdate(void* ctx,
  * @param[in] callback          optional result callback, can be NULL if not required
  * @return  OCStackResult application result
  */
-OCStackResult OCCloudAclIndividualDelete(void* ctx,
+OCStackResult OCCloudAclAcesDelete(void* ctx,
                                          const char *aclId,
                                          const OCDevAddr *endPoint,
                                          OCCloudResponseCB callback);
@@ -216,7 +216,7 @@ OCStackResult OCCloudAclIndividualDelete(void* ctx,
  * @param[in] callback          optional result callback, can be NULL if not required
  * @return  OCStackResult application result
  */
-OCStackResult OCCloudAclIndividualDeleteAce(void* ctx,
+OCStackResult OCCloudAclIndividualAceDelete(void* ctx,
                                          const char *aclId,
                                          const char *aceId,
                                          const OCDevAddr *endPoint,
index 278d8d6..a0ed58d 100644 (file)
@@ -28,6 +28,8 @@
 #include "ocpayload.h"
 #include "payload_logging.h"
 #include "aclresource.h"
+#include "acl_logging.h"
+#include "crl_logging.h"
 #include "crlresource.h"
 #include "ocprovisioningmanager.h"
 #include "casecurityinterface.h"
@@ -221,12 +223,25 @@ void unlockMenu(void *data)
  * @param[in] result       result
  * @param[in] data         data
  */
-static void handleCB(void* ctx, OCStackResult result, void* data)
+static void handleCB(void* ctx, OCClientResponse *response, void* data)
 {
     OC_UNUSED(ctx);
     OC_UNUSED(data);
 
-    OIC_LOG_V(INFO, TAG, "%s: Received result = %d", __func__, result);
+    if (response)
+    {
+        OIC_LOG_V(INFO, TAG, "%s: Received result = %d", __func__, response->result);
+
+        if (response->payload)
+        {
+            OIC_LOG(INFO, TAG, "Payload received:");
+            OIC_LOG_PAYLOAD(INFO, response->payload);
+        }
+    }
+    else
+    {
+        OIC_LOG_V(ERROR, TAG, "%s: Received NULL response", __func__);
+    }
 
     unlockMenu(NULL);
 }
@@ -238,10 +253,10 @@ static void handleCB(void* ctx, OCStackResult result, void* data)
  * @param[in] result       result
  * @param[in] aclId        acl id
  */
-static void handleAclIdCB(void* ctx, OCStackResult result, void* aclId)
+static void handleAclIdCB(void* ctx, OCClientResponse *response, void* aclId)
 {
     OIC_LOG_V(INFO, TAG, "Received Acl id = %s", (char *)aclId);
-    handleCB(ctx, result, aclId);
+    handleCB(ctx, response, aclId);
     OICFree(aclId);
 }
 
@@ -252,10 +267,10 @@ static void handleAclIdCB(void* ctx, OCStackResult result, void* aclId)
  * @param[in] result       result
  * @param[in] groupId      group id
  */
-static void handleAclCreateGroupCB(void* ctx, OCStackResult result, void* groupId)
+static void handleAclCreateGroupCB(void* ctx, OCClientResponse *response, void* groupId)
 {
     OIC_LOG_V(INFO, TAG, "Received gid = %s", (char *)groupId);
-    handleCB(ctx, result, groupId);
+    handleCB(ctx, response, groupId);
     OICFree(groupId);
 }
 
@@ -266,10 +281,10 @@ static void handleAclCreateGroupCB(void* ctx, OCStackResult result, void* groupI
  * @param[in] result       result
  * @param[in] gp           group policy
  */
-static void handleAclPolicyCheckCB(void* ctx, OCStackResult result, void* gp)
+static void handleAclPolicyCheckCB(void* ctx, OCClientResponse *response, void* gp)
 {
     OIC_LOG_V(INFO, TAG, "Received gp = %s", (char *)gp);
-    handleCB(ctx, result, gp);
+    handleCB(ctx, response, gp);
     OICFree(gp);
 }
 
@@ -280,10 +295,10 @@ static void handleAclPolicyCheckCB(void* ctx, OCStackResult result, void* gp)
  * @param[in] result       result
  * @param[in] acl          acl
  */
-static void handleAclIndividualGetInfoCB(void* ctx, OCStackResult result, void* acl)
+static void handleAclIndividualGetInfoCB(void* ctx, OCClientResponse *response, void* acl)
 {
-    printACL((OicSecAcl_t* )acl);
-    handleCB(ctx, result, acl);
+    OIC_LOG_ACL(INFO, acl);
+    handleCB(ctx, response, acl);
     //can't delete acl here because its ACE's were added to gAcl
     //TODO: changes in aclresources.c required to fix that
 }
@@ -295,10 +310,10 @@ static void handleAclIndividualGetInfoCB(void* ctx, OCStackResult result, void*
  * @param[in] result       result
  * @param[in] gidList      group id list
  */
-static void handleAclFindMyGroupCB(void* ctx, OCStackResult result, void* gidList)
+static void handleAclFindMyGroupCB(void* ctx, OCClientResponse *response, void* gidList)
 {
     printStringArray((stringArray_t *)gidList);
-    handleCB(ctx, result, gidList);
+    handleCB(ctx, response, gidList);
     clearStringArray((stringArray_t *)gidList);
 }
 
@@ -309,10 +324,10 @@ static void handleAclFindMyGroupCB(void* ctx, OCStackResult result, void* gidLis
  * @param[in] result       result
  * @param[in] crl          crl
  */
-static void handleGetCrlCB(void* ctx, OCStackResult result, void* crl)
+static void handleGetCrlCB(void* ctx, OCClientResponse *response, void* crl)
 {
-    printCrl((OicSecCrl_t *)crl);
-    handleCB(ctx, result, crl);
+    OIC_LOG_CRL(INFO, crl);
+    handleCB(ctx, response, crl);
     DeleteCrl((OicSecCrl_t *)crl);
 }
 
@@ -323,10 +338,10 @@ static void handleGetCrlCB(void* ctx, OCStackResult result, void* crl)
  * @param[in] result       result
  * @param[in] invite       invitation response (it has inviteResponse_t* type)
  */
-static void handleAclGetInvitationCB(void* ctx, OCStackResult result, void* invite)
+static void handleAclGetInvitationCB(void* ctx, OCClientResponse *response, void* invite)
 {
     printInviteResponse((inviteResponse_t *)invite);
-    handleCB(ctx, result, invite);
+    handleCB(ctx, response, invite);
     clearInviteResponse((inviteResponse_t *)invite);
     OICFree(invite);
 }
index 0892862..7196dd0 100644 (file)
@@ -498,7 +498,7 @@ OCStackResult OCWrapperAclIndividualUpdateAce(const OCDevAddr *endPoint, OCCloud
         }
     }
 
-    result = OCCloudAclIndividualUpdateAce(NULL, aclid, aces, endPoint, callback);
+    result = OCCloudAclIndividualAclUpdate(NULL, aclid, aces, endPoint, callback);
 exit:
     deleteCloudAceList(aces);
     return result;
@@ -565,7 +565,7 @@ OCStackResult OCWrapperAclIndividualUpdate(const OCDevAddr *endPoint, OCCloudRes
     }
 
 
-    result = OCCloudAclIndividualUpdate(NULL, aclid,aceid, ace, endPoint, callback);
+    result = OCCloudAclIndividualAceUpdate(NULL, aclid,aceid, ace, endPoint, callback);
 exit:
     return result;
 }
@@ -576,7 +576,7 @@ OCStackResult OCWrapperAclIndividualDelete(const OCDevAddr *endPoint, OCCloudRes
 
     readString(aclid, sizeof(aclid), "acl id", ACL_ID_EXAMPLE);
 
-    return OCCloudAclIndividualDelete(NULL, aclid, endPoint, callback);
+    return OCCloudAclAcesDelete(NULL, aclid, endPoint, callback);
 }
 
 OCStackResult OCWrapperAclIndividualDeleteAce(const OCDevAddr *endPoint, OCCloudResponseCB callback)
@@ -587,7 +587,7 @@ OCStackResult OCWrapperAclIndividualDeleteAce(const OCDevAddr *endPoint, OCCloud
     readString(aclid, sizeof(aclid), "acl id", ACL_ID_EXAMPLE);
     readString(aceid, sizeof(aceid), "ace id", ACE_ID_EXAMPLE);
 
-    return OCCloudAclIndividualDeleteAce(NULL, aclid, aceid, endPoint, callback);
+    return OCCloudAclIndividualAceDelete(NULL, aclid, aceid, endPoint, callback);
 }
 
 OCStackResult OCWrapperAclCreateGroup(const OCDevAddr *endPoint, OCCloudResponseCB callback)
index acbfb57..54e0a6c 100644 (file)
@@ -28,6 +28,7 @@
 #include "cacommonutil.h"
 #include "aclresource.h"
 #include "ocpayloadcbor.h"
+#include "acl_logging.h"
 #include "payload_logging.h"
 #include "utlist.h"
 
@@ -191,7 +192,7 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe
         goto exit;
     }
 
-    printACL(acl);
+    OIC_LOG_ACL(INFO, acl);
 
     result = InstallACL(acl);
     if (result != OC_STACK_OK)
@@ -225,7 +226,7 @@ OCStackResult OCCloudAclIndividualGetInfo(void* ctx,
                         CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
 }
 
-OCStackResult OCCloudAclIndividualUpdateAce(void* ctx,
+OCStackResult OCCloudAclIndividualAclUpdate(void* ctx,
                                             const char *aclId,
                                             const cloudAce_t *aces,
                                             const OCDevAddr *endPoint,
@@ -367,7 +368,7 @@ no_memory:
     return OC_STACK_NO_MEMORY;
 }
 
-OCStackResult OCCloudAclIndividualUpdate(void* ctx,
+OCStackResult OCCloudAclIndividualAceUpdate(void* ctx,
                                             const char *aclId,
                                             const char *aceId,
                                             const cloudAce_t *aces,
@@ -504,7 +505,7 @@ no_memory:
 
 
 
-OCStackResult OCCloudAclIndividualDelete(void* ctx,
+OCStackResult OCCloudAclAcesDelete(void* ctx,
                                          const char *aclId,
                                          const OCDevAddr *endPoint,
                                          OCCloudResponseCB callback)
@@ -524,7 +525,7 @@ OCStackResult OCCloudAclIndividualDelete(void* ctx,
                         CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
 }
 
-OCStackResult OCCloudAclIndividualDeleteAce(void* ctx,
+OCStackResult OCCloudAclIndividualAceDelete(void* ctx,
                                          const char *aclId,
                                          const char *aceId,
                                          const OCDevAddr *endPoint,
index 9bcde50..74083e6 100644 (file)
@@ -68,39 +68,30 @@ void setCoapPrefix(bool secure)
  */
 static OCStackApplicationResult handleResponse(void *ctx,
                                               OCDoHandle handle,
-                                              OCClientResponse *clientResponse)
+                                              OCClientResponse *response)
 {
     OC_UNUSED(handle);
 
-    if (NULL == clientResponse)
+    if (NULL == response)
     {
         OIC_LOG_V(ERROR, TAG, "Received null response from client");
         return OC_STACK_DELETE_TRANSACTION;
     }
 
-    OIC_LOG_V(DEBUG, TAG, "Received callback with response code: %d", clientResponse->result);
-
-    if (clientResponse->payload)
-    {
-        OIC_LOG(DEBUG, TAG, "Payload received:");
-        OIC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
-    }
-
     if (ctx)
     {
-        OCStackResult result = clientResponse->result;
         void *data = NULL;
 
         ContextInfo_t *info = (ContextInfo_t *)ctx;
 
         if (info->fn)
         {
-            result = ((UserFunctionCB)info->fn)(info->params, &data, clientResponse);
+            response->result = ((UserFunctionCB)info->fn)(info->params, &data, response);
         }
 
         if (info->cb)
         {
-            ((OCCloudResponseCB)info->cb)(info->ctx, result, data);
+            ((OCCloudResponseCB)info->cb)(info->ctx, response, data);
         }
     }
 
index 369c33e..a567c2b 100644 (file)
@@ -35,6 +35,7 @@
 #include "ocrandom.h"
 #include "ocpayload.h"
 #include "utlist.h"
+#include "acl_logging.h"
 #include "payload_logging.h"
 #include "srmresourcestrings.h"
 #include "aclresource.h"
@@ -1751,96 +1752,6 @@ static bool IsSameACE(OicSecAce_t* ace1, OicSecAce_t* ace2)
     return false;
 }
 
-static void printACE(const OicSecAce_t *ace)
-{
-#ifndef TB_LOG
-    OC_UNUSED(ace);
-#else
-    OIC_LOG(INFO, TAG, "=================================================");
-    OIC_LOG_V(INFO, TAG, "ACE @ %p", ace);
-    OIC_LOG_V(INFO, TAG, "    permission = %#x", (uint32_t)ace->permission);
-
-    // Log the subjectuuid.
-    char uuidString[UUID_STRING_SIZE];
-    bool convertedUUID = OCConvertUuidToString(ace->subjectuuid.id, uuidString);
-    OIC_LOG_V(INFO, TAG, "    subjectuuid = %s", convertedUUID ? uuidString : "incorrect format");
-
-    // Log all resources this ACE applies to.
-    OicSecRsrc_t *resource = NULL;
-    uint32_t resourceCount = 0;
-    LL_FOREACH(ace->resources, resource)
-    {
-        OIC_LOG_V(INFO, TAG, "    resources[%u]:", resourceCount);
-        OIC_LOG_V(INFO, TAG, "        href = %s", resource->href ? resource->href : "null");
-
-        for (size_t i = 0; i < resource->typeLen; i++)
-        {
-            OIC_LOG_V(INFO, TAG, "        types[%" PRIuPTR "] = %s", i,
-                resource->types[i] ? resource->types[i] : "null");
-        }
-
-        for (size_t i = 0; i < resource->interfaceLen; i++)
-        {
-            OIC_LOG_V(INFO, TAG, "        interfaces[%" PRIuPTR "] = %s", i,
-                resource->interfaces[i] ? resource->interfaces[i] : "null");
-        }
-
-        resourceCount++;
-    }
-
-    // Log the validities.
-    OicSecValidity_t *validity = NULL;
-    uint32_t validityCount = 0;
-    LL_FOREACH(ace->validities, validity)
-    {
-        OIC_LOG_V(INFO, TAG, "    validities[%u]:", validityCount);
-        OIC_LOG_V(INFO, TAG, "        period = %s", validity->period);
-        for (size_t i = 0; i < validity->recurrenceLen; i++)
-        {
-            OIC_LOG_V(INFO, TAG, "    recurrences[%" PRIuPTR "] = %s", i,
-                validity->recurrences[i] ? validity->recurrences[i] : "null");
-        }
-        validityCount++;
-    }
-
-    OIC_LOG(INFO, TAG, "=================================================");
-#endif
-}
-
-void printACL(const OicSecAcl_t* acl)
-{
-#ifndef TB_LOG
-    OC_UNUSED(acl);
-#else
-    OIC_LOG_V(INFO, TAG, "Print ACL @ %p:", acl);
-
-    if (NULL == acl)
-    {
-        return;
-    }
-
-    char rowner[UUID_STRING_SIZE];
-    if (OCConvertUuidToString(acl->rownerID.id, rowner))
-    {
-        OIC_LOG_V(INFO, TAG, "rowner id = %s", rowner);
-    }
-    else
-    {
-        OIC_LOG(ERROR, TAG, "Can't convert rowner uuid to string");
-    }
-
-    const OicSecAce_t *ace = acl->aces;
-    int ace_count = 0;
-    while (ace)
-    {
-        ace_count++;
-        OIC_LOG_V(INFO, TAG, "Print ace[%d]:", ace_count);
-        printACE(ace);
-        ace = ace->next;
-    }
-#endif
-}
-
 /**
  * Internal function to remove all ACL data on ACL resource and persistent storage
  *
@@ -2055,7 +1966,7 @@ static OCEntityHandlerResult HandleACLPostRequest(const OCEntityHandlerRequest *
                     if(insertAce)
                     {
                         OIC_LOG(DEBUG, TAG, "Prepending new ACE:");
-                        printACE(insertAce);
+                        OIC_LOG_ACE(DEBUG, insertAce);
                         LL_PREPEND(gAcl->aces, insertAce);
                     }
                     else
@@ -2511,7 +2422,7 @@ const OicSecAce_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAce_t **
         if (memcmp(&(ace->subjectuuid), subjectId, sizeof(OicUuid_t)) == 0)
         {
             OIC_LOG(DEBUG, TAG, "GetACLResourceData: found matching ACE:");
-            printACE(ace);
+            OIC_LOG_ACE(DEBUG, ace);
             *savePtr = ace;
             return ace;
         }
@@ -2547,7 +2458,7 @@ OCStackResult AppendACL2(const OicSecAcl_t* acl)
         gAcl->aces = acl->aces;
     }
 
-    printACL(gAcl);
+    OIC_LOG_ACL(INFO, gAcl);
 
     size_t size = 0;
     uint8_t *payload = NULL;
@@ -2606,7 +2517,7 @@ OCStackResult InstallACL(const OicSecAcl_t* acl)
             if(insertAce)
             {
                 OIC_LOG(DEBUG, TAG, "Prepending new ACE:");
-                printACE(insertAce);
+                OIC_LOG_ACE(DEBUG, insertAce);
 
                 if (!newInstallAcl)
                 {
index 4d071f0..cef6b20 100644 (file)
@@ -19,6 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "utlist.h"
+#include "crl_logging.h"
 #include "payload_logging.h"
 #include "psinterface.h"
 #include "resourcemanager.h"
@@ -75,24 +76,6 @@ void DeleteCrl(OicSecCrl_t *crl)
     }
 }
 
-void printCrl(const OicSecCrl_t *crl)
-{
-    if (NULL == crl)
-    {
-        OIC_LOG(INFO, TAG, "Received NULL CRL");
-        return;
-    }
-
-    OIC_LOG(INFO, TAG, "Crl object contain:");
-    OIC_LOG_V(INFO, TAG, "id = %d", crl->CrlId);
-    OIC_LOG_V(INFO, TAG, "this update = %s", crl->ThisUpdate.data);
-
-    OIC_LOG(INFO, TAG, "crl:");
-    OIC_LOG_V(INFO, TAG, "encoding = %d", crl->CrlData.encoding);
-    OIC_LOG_V(INFO, TAG, "data (length = %" PRIuPTR "):", crl->CrlData.len);
-    OIC_LOG_BUFFER(INFO, TAG, crl->CrlData.data, crl->CrlData.len);
-}
-
 static bool copyByteArray(const uint8_t *in, size_t in_len, uint8_t **out, size_t *out_len)
 {
     OICFree(*out);
@@ -309,7 +292,7 @@ OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t
         mapSize++;
     }
 
-    printCrl(crl);
+    OIC_LOG_CRL(INFO, crl);
 
     OCStackResult ret = OC_STACK_ERROR;
 
@@ -436,7 +419,7 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
     cborFindResult = getPubDataType(&crlCbor, OC_RSRVD_CRL, &crl->CrlData);
     VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to read CRL.");
 
-    printCrl(crl);
+    OIC_LOG_CRL(INFO, crl);
 
     *secCrl = crl;
     ret = OC_STACK_OK;
index eeacfc2..5964919 100644 (file)
@@ -17,11 +17,11 @@ OCCloudAclGetInvitation
 OCCloudAclGroupGetInfo
 OCCloudAclIdCreate
 OCCloudAclIdDelete
-OCCloudAclIndividualDelete
-OCCloudAclIndividualDeleteAce
+OCCloudAclAcesDelete
+OCCloudAclIndividualAceDelete
 OCCloudAclIndividualGetInfo
-OCCloudAclIndividualUpdate
-OCCloudAclIndividualUpdateAce
+OCCloudAclIndividualAceUpdate
+OCCloudAclIndividualAclUpdate
 OCCloudAclInviteUser
 OCCloudAclJoinToInvitedGroup
 OCCloudAclObserveGroup
@@ -33,6 +33,4 @@ OCCloudPostCRL
 OCSaveTrustCertChain
 OIC_RSRC_DOXM_URI
 OIC_RSRC_PSTAT_URI
-printACL
-printCrl
 setCoapPrefix
index 491f68a..1d9ac82 100755 (executable)
@@ -125,7 +125,7 @@ namespace OC
              * @param result result of the request performed\r
              * @param data response data\r
              */\r
-            static void callbackWrapper(void* ctx, OCStackResult result, void* data);\r
+            static void callbackWrapper(void* ctx, OCClientResponse *response, void* data);\r
 \r
             /**\r
              * Callback wrapper for Acl ID get request\r
@@ -133,7 +133,7 @@ namespace OC
              * @param result result of the request performed\r
              * @param data AclID for the device\r
              */\r
-            static void aclIdResponseWrapper(void* ctx, OCStackResult result, void* data);\r
+            static void aclIdResponseWrapper(void* ctx, OCClientResponse *response, void* data);\r
     };\r
 }\r
 #endif //OC_CLOUD_PROVISIONING_CXX_H_\r
index 813448d..e0e3f77 100644 (file)
@@ -56,7 +56,7 @@ typedef struct
 
 static sessionObject_t sessionObject = {0,0,0,0,0,0,0,0};
 
-extern void handleCB(void* ctx, OCStackResult result, void* data);
+extern void handleCB(void* ctx, OCClientResponse *response, void* data);
 
 /**
  * Session free function
@@ -188,7 +188,8 @@ OCStackApplicationResult handleCloudSignUpResponse(void *ctx,
         SessionParsePayload((OCRepPayload*)response->payload);
     }
 exit:
-    handleCB(NULL, OC_STACK_OK, NULL);
+    response->result = OC_STACK_OK;
+    handleCB(NULL, response, NULL);
     return OC_STACK_DELETE_TRANSACTION;
 }
 
@@ -297,7 +298,8 @@ OCStackApplicationResult handleCloudSignInResponse(void *ctx,
     OIC_LOG_V(DEBUG, TAG, "OUT: %s", __func__);
 
 exit:
-    handleCB(NULL, OC_STACK_OK, NULL);
+    response->result = OC_STACK_OK;
+    handleCB(NULL, response, NULL);
     return OC_STACK_DELETE_TRANSACTION;
 }
 
@@ -404,7 +406,8 @@ OCStackApplicationResult handleCloudSignOutResponse(void *ctx,
     OIC_LOG_V(DEBUG, TAG, "OUT: %s", __func__);
 
 exit:
-    handleCB(NULL, OC_STACK_OK, NULL);
+    response->result = OC_STACK_OK;
+    handleCB(NULL, response, NULL);
     return OC_STACK_DELETE_TRANSACTION;
 }
 /**
index 9ea5f2c..804aaad 100644 (file)
@@ -184,12 +184,12 @@ void printMenu()
  * @param[in] result       result
  * @param[in] data         data
  */
-void handleCB(void* ctx, OCStackResult result, void* data)
+void handleCB(void* ctx, OCClientResponse *response, void* data)
 {
     OC_UNUSED(ctx);
     OC_UNUSED(data);
 
-    printf("Cloud request Result is == %d", result);
+    printf("Cloud request Result is == %d", response->result);
     oc_mutex_lock(mutex);
     oc_cond_signal(cond);
     oc_mutex_unlock(mutex);
index 94261b9..3048380 100644 (file)
@@ -429,7 +429,7 @@ OCStackResult OCWrapperAclIndividualUpdateAce(const OCDevAddr *endPoint, OCCloud
         }
     }
 
-    result = OCCloudAclIndividualUpdateAce(NULL, aclid, aces, endPoint, callback);
+    result = OCCloudAclIndividualAclUpdate(NULL, aclid, aces, endPoint, callback);
 exit:
     if (aces)
     {
@@ -464,7 +464,7 @@ OCStackResult OCWrapperAclIndividualDelete(const OCDevAddr *endPoint, OCCloudRes
 
     readString(aclid, sizeof(aclid), "acl id", ACL_ID_EXAMPLE);
 
-    return OCCloudAclIndividualDelete(NULL, aclid, endPoint, callback);
+    return OCCloudAclAcesDelete(NULL, aclid, endPoint, callback);
 }
 
 OCStackResult OCWrapperAclCreateGroup(const OCDevAddr *endPoint, OCCloudResponseCB callback)
index 295704d..d60fdae 100644 (file)
 namespace OC
 {
     void OCCloudProvisioning::callbackWrapper(void *ctx,
-            OCStackResult result,
+            OCClientResponse *response,
             void *data)
     {
         CloudProvisionContext* context = static_cast<CloudProvisionContext*>(ctx);
 
-        std::thread exec(context->callback, result, data);
+        std::thread exec(context->callback, response->result, data);
         exec.detach();
 
         delete context;
     }
 
     void OCCloudProvisioning::aclIdResponseWrapper(void *ctx,
-            OCStackResult result,
+            OCClientResponse *response,
             void *data)
     {
         std::string aclId = "";
         AclIdContext* context = static_cast<AclIdContext*>(ctx);
 
-        if ((OC_STACK_OK == result) && data)
+        if ((OC_STACK_OK == response->result) && data)
         {
             aclId = (char *)data;
         }
-        std::thread exec(context->callback, result, aclId);
+        std::thread exec(context->callback, response->result, aclId);
         exec.detach();
 
         delete context;