[IOT-1395] Fix for rowneruuid update
authorJongmin Choi <jminl.choi@samsung.com>
Wed, 5 Oct 2016 11:33:05 +0000 (20:33 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Mon, 10 Oct 2016 04:52:25 +0000 (04:52 +0000)
[IOT-1395] Fix for rowneruuid update for CTT testing

Patch #1-2: rowneruuid update enabled
Patch #4: Logic modified

Change-Id: I2d6a53c1868e59ea112def5c45ed869b2b6d86da
Signed-off-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12807
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/pstatresource.c

index a41f99e..e887a3e 100644 (file)
@@ -58,7 +58,7 @@ static const uint8_t ACL_RESOURCE_MAP_SIZE = 3;
 
 
 // CborSize is the default cbor payload size being used.
-static const uint16_t CBOR_SIZE = 2048;
+static const uint16_t CBOR_SIZE = 2048*8;
 
 static OicSecAcl_t *gAcl = NULL;
 static OCResourceHandle gAclHandle = NULL;
@@ -1774,6 +1774,7 @@ static OCEntityHandlerResult HandleACLPostRequest(const OCEntityHandlerRequest *
                     }
                 }
             }
+            memcpy(&(gAcl->rownerID), &(newAcl->rownerID), sizeof(OicUuid_t));
 
             DeleteACLList(newAcl);
 
@@ -1781,6 +1782,7 @@ static OCEntityHandlerResult HandleACLPostRequest(const OCEntityHandlerRequest *
             {
                 size_t size = 0;
                 uint8_t *cborPayload = NULL;
+
                 if (OC_STACK_OK == AclToCBORPayload(gAcl, &cborPayload, &size))
                 {
                     if (UpdateSecureResourceInPS(OIC_JSON_ACL_NAME, cborPayload, size) == OC_STACK_OK)
index ea4c816..b4255c1 100644 (file)
@@ -948,6 +948,10 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
                 VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
                 OICFree(stRowner);
             }
+            else if (NULL != gCred)
+            {
+                memcpy(&(headCred->rownerID), &(gCred->rownerID), sizeof(OicUuid_t));
+            }
             OICFree(tagName);
         }
         if (cbor_value_is_valid(&CredRootMap))
@@ -1284,6 +1288,7 @@ OCStackResult AddCredential(OicSecCred_t * newCred)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OicSecCred_t * temp = NULL;
+    bool validFlag = true;
     VERIFY_SUCCESS(TAG, NULL != newCred, ERROR);
 
     //Assigning credId to the newCred
@@ -1299,20 +1304,26 @@ OCStackResult AddCredential(OicSecCred_t * newCred)
                       "new credential's ID will be replaced.", temp->credId);
             newCred->credId = temp->credId;
             ret = OC_STACK_OK;
-            goto exit;
+            validFlag = false;
+            break;
         }
 
         if (CRED_CMP_ERROR == cmpRes)
         {
             OIC_LOG_V(WARNING, TAG, "Credential skipped : %d", cmpRes);
             ret = OC_STACK_ERROR;
-            goto exit;
+            validFlag = false;
+            break;
         }
     }
 
-    //Append the new Cred to existing list
-    LL_APPEND(gCred, newCred);
+    //Append the new Cred to existing list if new Cred is valid
+    if (validFlag)
+    {
+        LL_APPEND(gCred, newCred);
+    }
 
+    memcpy(&(gCred->rownerID), &(newCred->rownerID), sizeof(OicUuid_t));
     if (UpdatePersistentStorage(gCred))
     {
         ret = OC_STACK_OK;
index a5ec8ae..63742c7 100644 (file)
@@ -390,11 +390,6 @@ static OCStackResult CBORPayloadToPstatBin(const uint8_t *cborPayload, const siz
         VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
         OICFree(strUuid );
         strUuid  = NULL;
-
-        if (roParsed)
-        {
-            *roParsed = true;
-        }
     }
     else
     {
@@ -607,6 +602,7 @@ static OCEntityHandlerResult HandlePstatPostRequest(const OCEntityHandlerRequest
             gPstat->om = pstat->om;
             gPstat->tm = pstat->tm;
             gPstat->cm = pstat->cm;
+            memcpy(&(gPstat->rownerID), &(pstat->rownerID), sizeof(OicUuid_t));
 
             // Convert pstat data into CBOR for update to persistent storage
             if (UpdatePersistentStorage(gPstat))