Merge branch 'master' into iot-1785
authorKevin Kane <kkane@microsoft.com>
Fri, 31 Mar 2017 19:41:13 +0000 (12:41 -0700)
committerKevin Kane <kkane@microsoft.com>
Fri, 31 Mar 2017 19:58:15 +0000 (12:58 -0700)
Conflicts:

    resource\csdk\security\include\internal\acl_logging.h
    resource\csdk\security\src\aclresource.c

Change-Id: Ide5322ac5c02c82af08586c4dc2fb2ec80b1b301
Signed-off-by: Kevin Kane <kkane@microsoft.com>
1  2 
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/security/SConscript
resource/csdk/security/include/internal/acl_logging.h
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/src/cloud/aclid.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/src/aclresource.c

Simple merge
index 0000000,5d26284..a78584b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,137 +1,149 @@@
 -    // 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");
+ //******************************************************************
+ //
+ // 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 subject
++    if (ace->subjectType == OicSecAceUuidSubject)
++    {
++        char uuidString[UUID_STRING_SIZE] = { 0 };
++        bool convertedUUID = OCConvertUuidToString(ace->subjectuuid.id, uuidString);
++        OIC_LOG_V(level, ACL_TAG, "    subject UUID = %s", convertedUUID ? uuidString : "incorrect format");
++    }
++    else if (ace->subjectType == OicSecAceRoleSubject)
++    {
++        OIC_LOG_V(level, ACL_TAG, "    role id = %s", ace->subjectRole.id);
++        OIC_LOG_V(level, ACL_TAG, "    authority = %s", ace->subjectRole.authority);
++    }
++    else
++    {
++        OIC_LOG(level, ACL_TAG, "    subject = (subject of unknown type)");
++    }
+     // 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
@@@ -189,16 -174,8 +189,8 @@@ OCStackResult GetAclRownerId(OicUuid_t 
   *
   * @return instance of @ref OicSecAcl_t structure or NULL if error occurs
   */
 -OicSecAcl_t* CBORPayloadToAcl2(const uint8_t *cborPayload, const size_t size);
 +OicSecAcl_t* CBORPayloadToCloudAcl(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
@@@ -2753,11 -2419,10 +2652,11 @@@ const OicSecAce_t* GetACLResourceData(c
      // Find the next ACL corresponding to the 'subjectID' and return it.
      LL_FOREACH(begin, ace)
      {
 -        if (memcmp(&(ace->subjectuuid), subjectId, sizeof(OicUuid_t)) == 0)
 +        if ((OicSecAceUuidSubject == ace->subjectType) &&
 +            (0 == memcmp(&(ace->subjectuuid), subjectId, sizeof(OicUuid_t))))
          {
              OIC_LOG(DEBUG, TAG, "GetACLResourceData: found matching ACE:");
-             printACE(ace);
+             OIC_LOG_ACE(DEBUG, ace);
              *savePtr = ace;
              return ace;
          }