Modify to update rowner as PT's UUID when ownership transfer is done.
authorleechul <chuls.lee@samsung.com>
Fri, 25 Mar 2016 09:31:21 +0000 (18:31 +0900)
committerDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Fri, 25 Mar 2016 13:44:46 +0000 (13:44 +0000)
  1) Modify data structure of each security resource as single instance of rowner.
  1) Add internal API to set the rowner.
  2) Modify the doxmresource.c in order to update rowner when OTM is done.
  3) Fix the minor bugs.

[Patch 1] : Intial upload
[Patch 2] : Revert the direct pairing related SVR DB files to prevent conflict.
[Patch 3] : Rebase
[Patch 4] : Remove the compile errors
[Patch 5-6] : Remove the compile errors for arduino
[Patch 7] : Update commit message
[Patch 8] : Rebase

Change-Id: I2f10786082265a2942dcadccb12f113658db8c34
Signed-off-by: leechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6325
Reviewed-by: Yonggoo Kang <ygace.kang@samsung.com>
Reviewed-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Tested-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
27 files changed:
resource/csdk/security/include/internal/aclresource.h
resource/csdk/security/include/internal/amaclresource.h
resource/csdk/security/include/internal/credresource.h
resource/csdk/security/include/internal/dpairingresource.h
resource/csdk/security/include/internal/pconfresource.h
resource/csdk/security/include/internal/pstatresource.h
resource/csdk/security/include/securevirtualresourcetypes.h
resource/csdk/security/provisioning/ck_manager/sample/provisioningclient.c
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/credentialgenerator.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/crlresource.c
resource/csdk/security/src/directpairing.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/dpairingresource.c
resource/csdk/security/src/pconfresource.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/svcresource.c
resource/csdk/security/tool/json2cbor.c
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/amaclresourcetest.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/provisioning/examples/provisioningclient.cpp

index ac4d543..dc45d5c 100644 (file)
@@ -87,6 +87,15 @@ OCStackResult InstallNewACL(const uint8_t* payload, const size_t size);
  */
 OCStackResult UpdateDefaultSecProvACL();
 
+/**
+ * Internal function to update resource owner
+ *
+ * @param newROwner new owner
+ *
+ * @retval ::OC_STACK_OK for Success, otherwise some error value
+ */
+OCStackResult SetAclRownerId(const OicUuid_t* newROwner);
+
 #ifdef __cplusplus
 }
 #endif
index e3dc1fa..49b0dff 100644 (file)
@@ -73,6 +73,16 @@ OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
 OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amacl, uint8_t **cborPayload,
                                  size_t *cborSize);
 
+
+/**
+ * Internal function to update resource owner
+ *
+ * @param newROwner new owner
+ *
+ * @retval ::OC_STACK_OK for Success, otherwise some error value
+ */
+OCStackResult SetAmaclRownerId(const OicUuid_t* newROwner);
+
 #ifdef __cplusplus
 }
 #endif
index 1d7e2d4..f85d21f 100644 (file)
@@ -76,15 +76,14 @@ OCStackResult CredToCBORPayload(const OicSecCred_t* cred, uint8_t **cborPayload,
  * @param credType credential type.
  * @param publicData public data such as public key.
  * @param privateData private data such as private key.
- * @param ownersLen length of owners array
- * @param owners array of owners.
+ * @param rownerID Resource owner's UUID.
  *
  * @return pointer to instance of @ref OicSecCred_t if successful. else NULL in case of error.
 
  */
 OicSecCred_t * GenerateCredential(const OicUuid_t* subject, OicSecCredType_t credType,
                      const OicSecCert_t * publicData, const OicSecKey_t * privateData,
-                     size_t ownersLen, const OicUuid_t * owners);
+                     const OicUuid_t * rownerID);
 
 /**
  * This function adds the new cred to the credential list.
@@ -130,15 +129,14 @@ int32_t GetDtlsPskCredentials( CADtlsPskCredType_t type,
  * @param credType is the type of credential to be added
  * @param pin is the numeric characters
  * @param pinSize is the length of 'pin'
- * @param ownersLen is the number of owners
- * @param owners is the array of owners
+ * @param rownerID Resource owner's UUID
  * @param tmpCredSubject is the generated credential's subject.
  *
  * @return ::OC_STACK_OK for success or else errorcode.
  */
 OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t credType,
                             const char * pin, size_t pinSize,
-                            size_t ownersLen, const OicUuid_t * owners,
+                            const OicUuid_t * rownerID,
                             OicUuid_t* tmpCredSubject);
 
 #endif /* __WITH_DTLS__ */
@@ -162,6 +160,15 @@ int GetDtlsX509Credentials(CADtlsX509Creds_t *credInfo);
  */
 void DeleteCredList(OicSecCred_t* cred);
 
+/**
+ * Internal function to update resource owner
+ *
+ * @param newROwner new owner
+ *
+ * @retval ::OC_STACK_OK for Success, otherwise some error value
+ */
+OCStackResult SetCredRownerId(const OicUuid_t* newROwner);
+
 #ifdef __cplusplus
 }
 #endif
index 1d2d363..6769ed3 100644 (file)
@@ -91,6 +91,15 @@ OCStackResult SavePairingPSK(OCDevAddr *endpoint,
 #endif // __WITH_DTLS__\r
 \r
 \r
+/**\r
+ * Internal function to update resource owner\r
+ *\r
+ * @param newROwner new owner\r
+ *\r
+ * @retval ::OC_STACK_OK for Success, otherwise some error value\r
+ */\r
+OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner);\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index b48bd1e..5494e62 100644 (file)
@@ -117,6 +117,14 @@ void DeletePconfBinData(OicSecPconf_t* pconf);
  */\r
 void FreePdAclList(OicSecPdAcl_t* pdacls);\r
 \r
+/**\r
+ * Internal function to update resource owner\r
+ *\r
+ * @param newROwner new owner\r
+ *\r
+ * @retval ::OC_STACK_OK for Success, otherwise some error value\r
+ */\r
+OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);\r
 \r
 #ifdef __cplusplus\r
 }\r
index facab4e..90e5657 100644 (file)
@@ -76,6 +76,15 @@ void DeletePstatBinData(OicSecPstat_t* pstat);
  */
 void RestorePstatToInitState();
 
+/**
+ * Internal function to update resource owner
+ *
+ * @param newROwner new owner
+ *
+ * @retval ::OC_STACK_OK for Success, otherwise some error value
+ */
+OCStackResult SetPstatRownerId(const OicUuid_t* newROwner);
+
 #ifdef __cplusplus
 }
 #endif
index 816b53a..428f941 100644 (file)
@@ -325,8 +325,7 @@ struct OicSecAcl
     size_t              prdRecrLen;     // the number of elts in Periods
     char                **periods;       // 3:R:M*:N:String (<--M*; see Spec)
     char                **recurrences;   // 5:R:M:N:String
-    size_t              ownersLen;      // the number of elts in Owners
-    OicUuid_t           *owners;        // 8:R:M:Y:oic.uuid
+    OicUuid_t           rownerID;        // 8:R:S:Y:oic.uuid
     // NOTE: we are using UUID for Owners instead of Svc type for mid-April
     // SRM version only; this will change to Svc type for full implementation.
     //TODO change Owners type to oic.sec.svc
@@ -345,8 +344,7 @@ struct OicSecAmacl
     char                **resources;    // 0:R:M:Y:String
     size_t              amssLen;        // the number of elts in Amss
     OicUuid_t           *amss;          // 1:R:M:Y:acl
-    size_t              ownersLen;      // the number of elts in Owners
-    OicUuid_t           *owners;        // 2:R:M:Y:oic.uuid
+    OicUuid_t           rownerID;        // 2:R:S:Y:oic.uuid
     // NOTE: we are using UUID for Owners instead of Svc type for mid-April
     // SRM version only; this will change to Svc type for full implementation.
     //TODO change Owners type to oic.sec.svc
@@ -373,8 +371,7 @@ struct OicSecCred
 #endif /* __WITH_X509__ */
     OicSecKey_t         privateData;    // 6:R:S:N:oic.sec.key
     char                *period;        // 7:R:S:N:String
-    size_t              ownersLen;      // the number of elts in Owners
-    OicUuid_t           *owners;        // 8:R:M:Y:oic.uuid
+    OicUuid_t           rownerID;        // 8:R:S:Y:oic.uuid
     // NOTE: we are using UUID for Owners instead of Svc type for mid-April
     // SRM version only; this will change to Svc type for full implementation.
     //OicSecSvc_t         *Owners;        // 8:R:M:Y:oic.sec.svc
@@ -537,7 +534,7 @@ struct OicSecPconf
     OicUuid_t           *pddevs;        // 4:R:M:Y:oic.uuid
     size_t                 pddevLen;     // the number of elts in pddev
     OicUuid_t           deviceID;       // 5:R:S:Y:oic.uuid
-    OicUuid_t           rowner;          // 6:R:S:Y:oic.uuid
+    OicUuid_t           rownerID;          // 6:R:S:Y:oic.uuid
 };
 
 /**
@@ -548,7 +545,7 @@ struct OicSecDpairing
     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
     OicSecPrm_t      spm;               // 0:R/W:S:Y:UINT16
     OicUuid_t           pdeviceID;     // 1:R:S:Y:oic.uuid
-    OicUuid_t           rowner;          // 2:R:S:Y:oic.uuid
+    OicUuid_t           rownerID;          // 2:R:S:Y:oic.uuid
 };
 
 #define MAX_VERSION_LEN 16 // Security Version length. i.e., 00.00.000 + reserved space
index 4b2f0c2..91a7619 100644 (file)
@@ -80,9 +80,6 @@ static void deleteACL(OicSecAcl_t *acl)
         }
         OICFree((acl)->resources);
 
-        /* Clean Owners */
-        OICFree((acl)->owners);
-
         /* Clean ACL node itself */
         OICFree((acl));
 
@@ -275,43 +272,28 @@ static int InputACL(OicSecAcl_t *acl)
     }
     while (0 != CalculateAclPermission(temp_pms, &(acl->permission)) );
     // Set Rowner
-    printf("Num. of Rowner : ");
-    ret = scanf("%zu", &acl->ownersLen);
-    if(-1 == ret)
-    {
-        printf("Error while input\n");
-        return -1;
-    }
     printf("-URN identifying the rowner\n");
     printf("ex) lightDeviceUUID0 (16 Numbers except to '-')\n");
-    acl->owners = (OicUuid_t *)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
-    if (NULL == acl->owners)
+
+    printf("Rowner : ");
+    char *ptr_temp_id = NULL;
+    ret = scanf("%19ms", &ptr_temp_id);
+    if (1 == ret)
     {
-        OIC_LOG(ERROR, TAG, "Error while memory allocation");
+        OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
+        OICFree(ptr_temp_id);
+    }
+    else
+    {
+        printf("Error while input\n");
         return -1;
     }
-    for (size_t i = 0; i < acl->ownersLen; i++)
+    j = 0;
+    for (int k = 0; temp_id[k] != '\0'; k++)
     {
-        printf("[%zu]Rowner : ", i + 1);
-        char *ptr_temp_id = NULL;
-        ret = scanf("%19ms", &ptr_temp_id);
-        if (1 == ret)
-        {
-            OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
-            OICFree(ptr_temp_id);
-        }
-        else
-        {
-            printf("Error while input\n");
-            return -1;
-        }
-        j = 0;
-        for (int k = 0; temp_id[k] != '\0'; k++)
+        if (DASH != temp_id[k])
         {
-            if (DASH != temp_id[k])
-            {
-                acl->owners[i].id[j++] = temp_id[k];
-            }
+            acl->rownerID.id[j++] = temp_id[k];
         }
     }
     return 0;
index 85555ed..ab423b4 100644 (file)
@@ -1018,13 +1018,6 @@ static OicSecAcl_t* createAcl(const int dev_num)
         }
         printf("         Entered Wrong Number. Please Enter Again\n");
     }
-    acl->ownersLen = 1;
-    acl->owners = (OicUuid_t*) OICCalloc(1, sizeof(OicUuid_t));
-    if(!acl->owners)
-    {
-        OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
-        goto CRACL_ERROR;
-    }
 
     dev = getDevInst((const OCProvisionDev_t*)g_own_list, own_num);
     if(!dev || !dev->doxm)
@@ -1032,7 +1025,7 @@ static OicSecAcl_t* createAcl(const int dev_num)
         OIC_LOG(ERROR, TAG, "createAcl: device instance empty");
         goto CRACL_ERROR;
     }
-    memcpy(acl->owners, &dev->doxm->deviceID, UUID_LENGTH);
+    memcpy(&acl->rownerID, &dev->doxm->deviceID, sizeof(OicUuid_t));
     printf("\n");
 
     return acl;
index 7093369..44e80a4 100644 (file)
@@ -68,11 +68,11 @@ OCStackResult PMGeneratePairWiseCredentials(OicSecCredType_t type, size_t keySiz
     OCFillRandomMem(privData, privDataKeySize);
 
     // TODO: currently owner array is 1. only provisioning tool's id.
-    tempFirstCred =  GenerateCredential(secondDeviceId, type, NULL, &privKey, 1, ptDeviceId);
+    tempFirstCred =  GenerateCredential(secondDeviceId, type, NULL, &privKey, ptDeviceId);
     VERIFY_NON_NULL(TAG, tempFirstCred, ERROR);
 
     // TODO: currently owner array is 1. only provisioning tool's id.
-    tempSecondCred =  GenerateCredential(firstDeviceId, type, NULL, &privKey, 1, ptDeviceId);
+    tempSecondCred =  GenerateCredential(firstDeviceId, type, NULL, &privKey, ptDeviceId);
     VERIFY_NON_NULL(TAG, tempSecondCred, ERROR);
 
     *firstCred = tempFirstCred;
@@ -230,7 +230,7 @@ OCStackResult PMGenerateCertificateCredentials(const OicUuid_t *ptDeviceId,
     }
 
     *cred = GenerateCredential(deviceId, SIGNED_ASYMMETRIC_KEY, &certificateChain,
-                              &privKey, 1, ptDeviceId);
+                              &privKey, ptDeviceId);
     return OC_STACK_OK;
 }
 #endif // __WITH_X509__
index 15f9946..f04526f 100644 (file)
@@ -420,11 +420,9 @@ static OCStackResult SaveOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
         OIC_LOG(INFO, TAG,"ownerPSK dump:\n");
         OIC_LOG_BUFFER(INFO, TAG,ownerPSK, OWNER_PSK_LENGTH_128);
         //Generating new credential for provisioning tool
-        size_t ownLen = 1;
-
         OicSecCred_t *cred = GenerateCredential(&selectedDeviceInfo->doxm->deviceID,
                 SYMMETRIC_PAIR_WISE_KEY, NULL,
-                &ownerKey, ownLen, &ptDeviceID);
+                &ownerKey, &ptDeviceID);
         VERIFY_NON_NULL(TAG, cred, ERROR);
 
         res = AddCredential(cred);
index 63e37d1..48be684 100644 (file)
@@ -639,7 +639,7 @@ OCStackResult SRPProvisionCredentials(void *ctx, OicSecCredType_t type, size_t k
         OIC_LOG(INFO, TAG, "SRPUnlinkDevices : NULL Callback");
         return OC_STACK_INVALID_CALLBACK;
     }
-    if (SYMMETRIC_PAIR_WISE_KEY == type && 
+    if (SYMMETRIC_PAIR_WISE_KEY == type &&
         0 == memcmp(&pDev1->doxm->deviceID, &pDev2->doxm->deviceID, sizeof(OicUuid_t)))
     {
         OIC_LOG(INFO, TAG, "SRPUnlinkDevices : Same device ID");
@@ -989,7 +989,7 @@ OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selec
         OIC_LOG(ERROR, TAG, "Error while retrieving provisioning tool's device ID");
         return OC_STACK_ERROR;
     }
-    memcpy(&pconf->rowner, &provTooldeviceID, sizeof(OicUuid_t));
+    memcpy(&pconf->rownerID, &provTooldeviceID, sizeof(OicUuid_t));
 
     OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
     if(!secPayload)
index 7507d36..4369e7b 100644 (file)
@@ -97,9 +97,6 @@ static void FreeACE(OicSecAcl_t *ace)
         OICFree(ace->recurrences);
     }
 
-    // Clean Owners
-    OICFree(ace->owners);
-
     // Clean ACL node itself
     OICFree(ace);
 }
@@ -210,7 +207,6 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
             WILDCARD_SUBJECT_ID_LEN : sizeof(OicUuid_t);
         if(inLen == WILDCARD_SUBJECT_ID_LEN)
         {
-            char *subject = NULL;
             cborEncoderResult = cbor_encode_text_string(&oicSecAclMap, WILDCARD_RESOURCE_URI,
                 strlen(WILDCARD_RESOURCE_URI));
             VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Subject Id wildcard Value.");
@@ -340,31 +336,21 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
         acl = acl->next;
     }
 
-
-
     // Close ACES Array
     cborEncoderResult = cbor_encoder_close_container(&aclListMap, &acesArray);
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing ACES Array.");
 
-
-
     // Close ACLIST Map
     cborEncoderResult = cbor_encoder_close_container(&aclMap, &aclListMap);
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing ACLIST Map.");
 
-
-
-    // TODO : Need to modify acl->owners[0] to acl->rownerid based on RAML spec.
-    acl = (OicSecAcl_t *)secAcl;
     // Rownerid
-    if(acl->owners && acl->ownersLen > 0)
     {
+        char *rowner = NULL;
         cborEncoderResult = cbor_encode_text_string(&aclMap, OIC_JSON_ROWNERID_NAME,
             strlen(OIC_JSON_ROWNERID_NAME));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding rownerid Name.");
-
-        char *rowner = NULL;
-        ret = ConvertUuidToStr(&acl->owners[0], &rowner);
+        ret = ConvertUuidToStr(&secAcl->rownerID, &rowner);
         VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
         cborEncoderResult = cbor_encode_text_string(&aclMap, rowner, strlen(rowner));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding rownerid Value.");
@@ -696,10 +682,7 @@ OicSecAcl_t* CBORPayloadToAcl(const uint8_t *cborPayload, const size_t size)
                 char *stRowner = NULL;
                 cborFindResult = cbor_value_dup_text_string(&aclMap, &stRowner, &len, NULL);
                 VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Rownerid Value.");
-                headAcl->ownersLen = 1;
-                headAcl->owners = (OicUuid_t *)OICCalloc(headAcl->ownersLen, sizeof(*headAcl->owners));
-                VERIFY_NON_NULL(TAG, headAcl->owners, ERROR);
-                ret = ConvertStrToUuid(stRowner, &headAcl->owners[0]);
+                ret = ConvertStrToUuid(stRowner, &headAcl->rownerID);
                 VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
                 OICFree(stRowner);
             }
@@ -1179,10 +1162,8 @@ OCStackResult GetDefaultACL(OicSecAcl_t** defaultAcl)
         OCRandomUuidResult rdm = OCGenerateUuid(ownerId.id);
         VERIFY_SUCCESS(TAG, RAND_UUID_OK == rdm, FATAL);
     }
-    acl->ownersLen = 1;
-    acl->owners = (OicUuid_t*) OICMalloc(sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, (acl->owners), ERROR);
-    memcpy(acl->owners, &ownerId, sizeof(OicUuid_t));
+
+    memcpy(&acl->rownerID, &ownerId, sizeof(OicUuid_t));
 
     acl->next = NULL;
 
@@ -1385,10 +1366,7 @@ static OicSecAcl_t* GetSecDefaultACL()
     VERIFY_SUCCESS(TAG, OC_STACK_OK == res, FATAL);
 
     // Owners -- Mandatory
-    newDefaultAcl->ownersLen = 1;
-    newDefaultAcl->owners = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, (newDefaultAcl->owners), ERROR);
-    memcpy(newDefaultAcl->owners, &ownerId, sizeof(OicUuid_t));
+    memcpy(&newDefaultAcl->rownerID, &ownerId, sizeof(OicUuid_t));
 
     return newDefaultAcl;
 exit:
@@ -1470,3 +1448,41 @@ OCStackResult UpdateDefaultSecProvACL()
 
     return ret;
 }
+
+OCStackResult SetAclRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gAcl)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gAcl)
+    {
+        memcpy(prevId.id, gAcl->rownerID.id, sizeof(prevId.id));
+        memcpy(gAcl->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = AclToCBORPayload(gAcl, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_ACL_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gAcl->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
index cff8272..130ca00 100644 (file)
@@ -66,9 +66,6 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
             // Clean Amss
             OICFree(amaclTmp1->amss);
 
-            // Clean Owners
-            OICFree(amaclTmp1->owners);
-
             // Clean Amacl node itself
             OICFree(amaclTmp1);
         }
@@ -199,13 +196,12 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing AMSS Array.");
 
     // TODO : Need to check owner property in the RAML spec.
-    // rowner
+    // rowner -- Mandatory
     cborEncoderResult = cbor_encode_text_string(&amaclMap, OIC_JSON_ROWNERID_NAME,
                 strlen(OIC_JSON_ROWNERID_NAME));
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding ROwnerID Name Tag.");
 
-    // TODO : Need to modify amacl->owners[0] to amacl->rownerid based on RAML spec.
-    ret = ConvertUuidToStr(&amacl->owners[0], &stRowner);
+    ret = ConvertUuidToStr(&amacl->rownerID, &stRowner);
     VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
     cborEncoderResult = cbor_encode_text_string(&amaclMap, stRowner, strlen(stRowner));
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding ROwner Value.");
@@ -419,17 +415,14 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
             }
         }
 
-        // TODO : Need to modify headAmacl->owners[0].id to headAmacl->rowner based on RAML spec.
         // Rowner -- Mandatory
         if (0 == strcmp(OIC_JSON_ROWNERID_NAME, name))
         {
             char *stRowner = NULL;
             cborFindResult = cbor_value_dup_text_string(&amaclMap, &stRowner, &len, NULL);
             VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding ROwner Value.");
-            headAmacl->ownersLen = 1;
-            headAmacl->owners = (OicUuid_t *)OICCalloc(headAmacl->ownersLen, sizeof(*headAmacl->owners));
-            VERIFY_NON_NULL(TAG, headAmacl->owners, ERROR);
-            ret = ConvertStrToUuid(stRowner, &headAmacl->owners[0]);
+
+            ret = ConvertStrToUuid(stRowner, &headAmacl->rownerID);
             VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
             OICFree(stRowner);
         }
@@ -636,3 +629,43 @@ OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsDeviceId)
 exit:
     return OC_STACK_ERROR;
 }
+
+
+OCStackResult SetAmaclRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gAmacl)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gAmacl)
+    {
+        memcpy(prevId.id, gAmacl->rownerID.id, sizeof(prevId.id));
+        memcpy(gAmacl->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = AmaclToCBORPayload(gAmacl, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_AMACL_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gAmacl->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
+
index 7227bda..b1f4101 100644 (file)
@@ -96,9 +96,6 @@ static void FreeCred(OicSecCred_t *cred)
     //Clean Period
     OICFree(cred->period);
 
-    //Clean Owners
-    OICFree(cred->owners);
-
     //Clean Cred node itself
     OICFree(cred);
 }
@@ -293,22 +290,21 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
 
         cborEncoderResult = cbor_encoder_close_container(&credArray, &credMap);
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Cred Map.");
-        
+
         cred = cred->next;
     }
     cborEncoderResult = cbor_encoder_close_container(&credRootMap, &credArray);
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Cred Array.");
 
     cred = credS;
-    // TODO : Need to modify cred->owners[0] to cred->rownerid based on RAML spec.
+
     // Rownerid
-    if(cred->owners && cred->ownersLen > 0)
     {
         char *rowner = NULL;
         cborEncoderResult = cbor_encode_text_string(&credRootMap, OIC_JSON_ROWNERID_NAME,
             strlen(OIC_JSON_ROWNERID_NAME));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding rownerid Name.");
-        ret = ConvertUuidToStr(&cred->owners[0], &rowner);
+        ret = ConvertUuidToStr(&cred->rownerID, &rowner);
         VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
         cborEncoderResult = cbor_encode_text_string(&credRootMap, rowner, strlen(rowner));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding rownerid Value.");
@@ -566,16 +562,14 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
                 }
             }
 
-            // TODO : Need to modify headCred->owners[0].id to headCred->rowner based on RAML spec.
+            //ROwner -- Mandatory
             if (strcmp(tagName, OIC_JSON_ROWNERID_NAME)  == 0)
             {
                 char *stRowner = NULL;
                 cborFindResult = cbor_value_dup_text_string(&CredRootMap, &stRowner, &len, NULL);
                 VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Rownerid Value.");
-                headCred->ownersLen = 1;
-                headCred->owners = (OicUuid_t *)OICCalloc(headCred->ownersLen, sizeof(*headCred->owners));
-                VERIFY_NON_NULL(TAG, headCred->owners, ERROR);
-                ret = ConvertStrToUuid(stRowner, &headCred->owners[0]);
+
+                ret = ConvertStrToUuid(stRowner, &headCred->rownerID);
                 VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
                 OICFree(stRowner);
             }
@@ -605,7 +599,7 @@ exit:
 
 OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t credType,
                                   const OicSecCert_t * publicData, const OicSecKey_t* privateData,
-                                  size_t ownersLen, const OicUuid_t * owners)
+                                  const OicUuid_t * rownerID)
 {
     (void)publicData;
     OCStackResult ret = OC_STACK_ERROR;
@@ -642,15 +636,8 @@ OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t cr
         cred->privateData.len = privateData->len;
     }
 
-    VERIFY_SUCCESS(TAG, ownersLen > 0, ERROR);
-    cred->ownersLen = ownersLen;
-
-    cred->owners = (OicUuid_t *)OICCalloc(cred->ownersLen, sizeof(*cred->owners));
-    VERIFY_NON_NULL(TAG, cred->owners, ERROR);
-    for (size_t i = 0; i < cred->ownersLen; i++)
-    {
-        memcpy(cred->owners[i].id, owners[i].id, sizeof(cred->owners[i].id));
-    }
+    VERIFY_NON_NULL(TAG, rownerID, ERROR);
+    memcpy(&cred->rownerID, rownerID, sizeof(OicUuid_t));
 
     ret = OC_STACK_OK;
 exit:
@@ -1292,15 +1279,14 @@ int32_t GetDtlsPskCredentials(CADtlsPskCredType_t type,
  * @param[in] credType Type of credential to be added
  * @param[in] pin numeric characters
  * @param[in] pinSize length of 'pin'
- * @param[in] ownersLen Number of owners
- * @param[in] owners Array of owners
+ * @param[in] rownerID Resource owner's UUID
  * @param[out] tmpCredSubject Generated credential's subject.
  *
  * @return OC_STACK_OK for success and errorcode otherwise.
  */
 OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t credType,
                             const char * pin, size_t pinSize,
-                            size_t ownersLen, const OicUuid_t * owners, OicUuid_t* tmpCredSubject)
+                            const OicUuid_t * rownerID, OicUuid_t* tmpCredSubject)
 {
     OCStackResult ret = OC_STACK_ERROR;
     OIC_LOG(DEBUG, TAG, "AddTmpPskWithPIN IN");
@@ -1313,13 +1299,13 @@ OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t cre
     uint8_t privData[OWNER_PSK_LENGTH_128] = {0,};
     OicSecKey_t privKey = {privData, OWNER_PSK_LENGTH_128};
     OicSecCred_t* cred = NULL;
-    int dtlsRes = DeriveCryptoKeyFromPassword((const unsigned char *)pin, pinSize, owners->id,
+    int dtlsRes = DeriveCryptoKeyFromPassword((const unsigned char *)pin, pinSize, rownerID->id,
                                               UUID_LENGTH, PBKDF_ITERATIONS,
                                               OWNER_PSK_LENGTH_128, privData);
     VERIFY_SUCCESS(TAG, (0 == dtlsRes) , ERROR);
 
     cred = GenerateCredential(tmpSubject, credType, NULL,
-                              &privKey, ownersLen, owners);
+                              &privKey, rownerID);
     if(NULL == cred)
     {
         OIC_LOG(ERROR, TAG, "GeneratePskWithPIN() : Failed to generate credential");
@@ -1416,3 +1402,42 @@ exit:
 }
 #undef CERT_LEN_PREFIX
 #endif /* __WITH_X509__ */
+
+OCStackResult SetCredRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gCred)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gCred)
+    {
+        memcpy(prevId.id, gCred->rownerID.id, sizeof(prevId.id));
+        memcpy(gCred->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = CredToCBORPayload(gCred, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_CRED_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gCred->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
+
index bf9041d..4eaf3db 100644 (file)
@@ -188,7 +188,7 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
         cborFindResult = cbor_value_get_int(&crlMap, (int *) &crl->CrlId);
         VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CrlId.");
     }
-    
+
     cborFindResult = cbor_value_map_find_value(&crlCbor, OIC_CBOR_CRL_THIS_UPDATE, &crlMap);
     if (CborNoError == cborFindResult && cbor_value_is_byte_string(&crlMap))
     {
@@ -199,7 +199,7 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
     cborFindResult = cbor_value_map_find_value(&crlCbor, OIC_CBOR_CRL_DATA, &crlMap);
     if (CborNoError == cborFindResult && cbor_value_is_byte_string(&crlMap))
     {
-        cborFindResult = cbor_value_dup_byte_string(&crlMap, 
+        cborFindResult = cbor_value_dup_byte_string(&crlMap,
                          &crl->CrlData.data, &crl->CrlData.len, NULL);
         VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Byte Array.");
     }
@@ -241,7 +241,7 @@ exit:
                 memcpy(crl->CrlData.data, gCrl->CrlData.data, outLen);
                 crl->CrlData.len = outLen;
             }
-            else 
+            else
             {
                 crl->CrlData.len = 0;
                 OIC_LOG (ERROR, TAG, "Set default failed");
index 8b0eec4..c75ad5b 100644 (file)
@@ -142,7 +142,7 @@ OCStackResult addDev(OCDirectPairingDev_t **ppList, OCDevAddr *endpoint,
         pconf->prm = NULL;  // to prevent free\r
         ptr->prmLen = pconf->prmLen;\r
         memcpy(&ptr->deviceID, &pconf->deviceID, sizeof(OicUuid_t));\r
-        memcpy(&ptr->rowner, &pconf->rowner, sizeof(OicUuid_t));\r
+        memcpy(&ptr->rowner, &pconf->rownerID, sizeof(OicUuid_t));\r
         ptr->next = NULL;\r
 \r
         LL_PREPEND(*ppList, ptr);\r
@@ -595,7 +595,7 @@ static OCStackApplicationResult DirectPairingHandler(void *ctx, OCDoHandle UNUSE
             res = AddTmpPskWithPIN(&dpairData->peer->deviceID,\r
                            SYMMETRIC_PAIR_WISE_KEY,\r
                            (char*)dpairData->pin, DP_PIN_LENGTH,\r
-                           1, &dpairData->peer->rowner, &subjectId);\r
+                           &dpairData->peer->rowner, &subjectId);\r
             VERIFY_SUCCESS(TAG, OC_STACK_OK == res, ERROR);\r
 \r
 \r
index 101c115..995dfb5 100644 (file)
@@ -40,6 +40,9 @@
 #include "doxmresource.h"
 #include "pstatresource.h"
 #include "aclresource.h"
+#include "amaclresource.h"
+#include "pconfresource.h"
+#include "dpairingresource.h"
 #include "psinterface.h"
 #include "srmresourcestrings.h"
 #include "securevirtualresourcetypes.h"
@@ -426,7 +429,6 @@ OCStackResult CBORPayloadToDoxm(const uint8_t *cborPayload, size_t size,
         strUuid  = NULL;
     }
 
-
     *secDoxm = doxm;
     ret = OC_STACK_OK;
 
@@ -619,14 +621,6 @@ static OCEntityHandlerResult HandleDoxmPutRequest(const OCEntityHandlerRequest *
                         //Save the owner's UUID to derive owner credential
                         memcpy(&(gDoxm->owner), &(newDoxm->owner), sizeof(OicUuid_t));
 
-                        // OCServerRequest *request = (OCServerRequest *)ehRequest->requestHandle;
-                        // Generating OwnerPSK
-                        // OIC_LOG (INFO, TAG, "Doxm EntityHandle  generating OwnerPSK");
-                        // Generate new credential for provisioning tool
-                        // ehRet = AddOwnerPSK((CAEndpoint_t *)&request->devAddr, newDoxm,
-                        //       (uint8_t*) OXM_JUST_WORKS, strlen(OXM_JUST_WORKS));
-                        // VERIFY_SUCCESS(TAG, OC_EH_OK == ehRet, ERROR);
-
                         // Update new state in persistent storage
                         if (true == UpdatePersistentStorage(gDoxm))
                         {
@@ -739,7 +733,47 @@ static OCEntityHandlerResult HandleDoxmPutRequest(const OCEntityHandlerRequest *
             if ((false == gDoxm->owned) && (true == newDoxm->owned) &&
                     (memcmp(&(gDoxm->owner), &(newDoxm->owner), sizeof(OicUuid_t)) == 0))
             {
+                //Change the SVR's resource owner as owner device.
+                OCStackResult ownerRes = SetAclRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+                ownerRes = SetAmaclRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+                ownerRes = SetCredRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+                ownerRes = SetPstatRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+                ownerRes = SetDpairingRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+                ownerRes = SetPconfRownerId(&gDoxm->owner);
+                if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+                {
+                    ehRet = OC_EH_ERROR;
+                    goto exit;
+                }
+
                 gDoxm->owned = true;
+                memcpy(&gDoxm->rownerID, &gDoxm->owner, sizeof(OicUuid_t));
+
                 // Update new state in persistent storage
                 if (UpdatePersistentStorage(gDoxm))
                 {
index 1507c75..900509a 100644 (file)
@@ -101,7 +101,7 @@ void SetDpairingResourceOwner(OicUuid_t *rowner)
     OIC_LOG (DEBUG, TAG, "SetDpairingResourceOwner");
     if (gDpair)
     {
-        memcpy(&gDpair->rowner, rowner, sizeof(OicUuid_t));
+        memcpy(&gDpair->rownerID, rowner, sizeof(OicUuid_t));
     }
 }
 
@@ -151,11 +151,10 @@ OCStackResult SavePairingPSK(OCDevAddr *endpoint,
         OIC_LOG(INFO, TAG, "pairingPSK dump:\n");
         OIC_LOG_BUFFER(INFO, TAG, pairingPSK, OWNER_PSK_LENGTH_128);
         //Generating new credential for direct-pairing client
-        size_t ownLen = 1;
 
         OicSecCred_t *cred = GenerateCredential(peerDevID,
                 SYMMETRIC_PAIR_WISE_KEY, NULL,
-                &pairingKey, ownLen, owner);
+                &pairingKey, owner);
         VERIFY_NON_NULL(TAG, cred, ERROR);
 
         res = AddCredential(cred);
@@ -228,12 +227,12 @@ OCStackResult DpairingToCBORPayload(const OicSecDpairing_t *dpair, uint8_t **pay
     }
 
     //ROWNER -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_ROWNERID_NAME,
-        strlen(OIC_JSON_ROWNERID_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROWNER tag");
     {
         char *rowner = NULL;
-        ret = ConvertUuidToStr(&dpair->rowner, &rowner);
+        cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_ROWNERID_NAME,
+            strlen(OIC_JSON_ROWNERID_NAME));
+        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROWNER tag");
+        ret = ConvertUuidToStr(&dpair->rownerID, &rowner);
         VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
         cborEncoderResult = cbor_encode_text_string(&dpairMap, rowner, strlen(rowner));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Rowner ID value");
@@ -331,7 +330,7 @@ OCStackResult CBORPayloadToDpair(const uint8_t *cborPayload, size_t size,
             char *id = NULL;
             cborFindResult = cbor_value_dup_text_string(&dpairMap, &id, &len, NULL);
             VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RownerID value");
-            ret = ConvertStrToUuid(id, &dpair->rowner);
+            ret = ConvertStrToUuid(id, &dpair->rownerID);
             VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
             OICFree(id);
         }
@@ -442,7 +441,7 @@ static OCEntityHandlerResult HandleDpairingPostRequest (const OCEntityHandlerReq
             }
             gDpair->spm = newDpair->spm;
             memcpy(&gDpair->pdeviceID, &newDpair->pdeviceID, sizeof(OicUuid_t));
-            memcpy(&gDpair->rowner, &pconf->rowner, sizeof(OicUuid_t));
+            memcpy(&gDpair->rownerID, &pconf->rownerID, sizeof(OicUuid_t));
 
 #ifdef __WITH_DTLS__
             // Add temporary psk
@@ -451,7 +450,7 @@ static OCEntityHandlerResult HandleDpairingPostRequest (const OCEntityHandlerReq
             res = AddTmpPskWithPIN(&gDpair->pdeviceID,
                            SYMMETRIC_PAIR_WISE_KEY,
                            (char*)pconf->pin.val, DP_PIN_LENGTH,
-                           1, &gDpair->rowner, &subjectId);
+                           &gDpair->rownerID, &subjectId);
             if(res != OC_STACK_OK ||
                     memcmp(&gDpair->pdeviceID, &subjectId, sizeof(OicUuid_t)))
             {
@@ -552,7 +551,7 @@ static OCEntityHandlerResult HandleDpairingPutRequest (const OCEntityHandlerRequ
         OIC_LOG_V(INFO, TAG, "SavePairingPSK for %s(%d)", request->devAddr.addr,
                 request->devAddr.port);
         OCStackResult res = SavePairingPSK(&request->devAddr, &newDpair->pdeviceID,
-                (OicUuid_t *)&pconf->rowner, true);
+                (OicUuid_t *)&pconf->rownerID, true);
         VERIFY_SUCCESS(TAG, OC_STACK_OK == res, ERROR);
 #endif //__WITH_DTLS__
 
@@ -565,8 +564,7 @@ static OCEntityHandlerResult HandleDpairingPutRequest (const OCEntityHandlerRequ
             memcpy(&acl.subject, &gDpair->pdeviceID, sizeof(OicUuid_t));
             acl.resources = pdAcl->resources;
             acl.resourcesLen = pdAcl->resourcesLen;
-            acl.owners = (OicUuid_t*)&pconf->rowner;
-            acl.ownersLen = 1;
+            memcpy(&acl.rownerID, &pconf->rownerID, sizeof(OicUuid_t));
             acl.permission = pdAcl->permission;
             acl.periods = pdAcl->periods;
             acl.recurrences = pdAcl->recurrences;
@@ -712,3 +710,41 @@ OCStackResult DeInitDpairingResource()
         return OC_STACK_ERROR;
     }
 }
+
+OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gDpair)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gDpair)
+    {
+        memcpy(prevId.id, gDpair->rownerID.id, sizeof(prevId.id));
+        memcpy(gDpair->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = DpairingToCBORPayload(gDpair, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_DPAIRING_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gDpair->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
index bf66ee1..016f513 100644 (file)
@@ -412,12 +412,12 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
     }
 
     //ROwner -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_ROWNERID_NAME,
-            strlen(OIC_JSON_ROWNERID_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rowner string");
     {
         char *rowner = NULL;
-        ret = ConvertUuidToStr(&pconf->rowner, &rowner);
+        cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_ROWNERID_NAME,
+                strlen(OIC_JSON_ROWNERID_NAME));
+        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rowner string");
+        ret = ConvertUuidToStr(&pconf->rownerID, &rowner);
         VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
         cborEncoderResult = cbor_encode_text_string(&pconfMap, rowner, strlen(rowner));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rwoner value");
@@ -767,7 +767,7 @@ OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSec
                 char *rowner = NULL;
                 cborFindResult = cbor_value_dup_text_string(&pconfMap, &rowner, &len, NULL);
                 VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get rowner");
-                ret = ConvertStrToUuid(rowner, &pconf->rowner);
+                ret = ConvertStrToUuid(rowner, &pconf->rownerID);
                 VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
                 OICFree(rowner);
             }
@@ -826,20 +826,22 @@ static OCEntityHandlerResult HandlePconfGetRequest (const OCEntityHandlerRequest
     if (true == GetDoxmResourceData()->dpc)
     {
         //Making response elements for Get request
-        if( (true == gPconf->edp) && (gPconf->prm && 0 < gPconf->prmLen) &&
-                (0 < strlen((const char*)gPconf->deviceID.id)) && (0 < strlen((const char*)gPconf->rowner.id)))
+        if( (true == gPconf->edp) &&
+            (gPconf->prm && 0 < gPconf->prmLen) &&
+            (0 < strlen((const char*)gPconf->deviceID.id)) &&
+            (0 < strlen((const char*)gPconf->rownerID.id)))
         {
             pconf.edp = true;
             pconf.prm = gPconf->prm;
             pconf.prmLen = gPconf->prmLen;
             memcpy(&pconf.deviceID, &gPconf->deviceID, sizeof(OicUuid_t));
-            memcpy(&pconf.rowner, &gPconf->rowner, sizeof(OicUuid_t));
+            memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
             OIC_LOG (DEBUG, TAG, "PCONF - direct pairing enabled");
         }
         else if (false == gPconf->edp)
         {
             pconf.edp = false;
-            memcpy(&pconf.rowner, &gPconf->rowner, sizeof(OicUuid_t));
+            memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
             OIC_LOG (DEBUG, TAG, "PCONF - direct pairing disable");
         }
         else
@@ -914,7 +916,7 @@ static OCEntityHandlerResult HandlePconfPostRequest (const OCEntityHandlerReques
             gPconf->prm = newPconf->prm;
             gPconf->prmLen = newPconf->prmLen;
             gPconf->pdacls = newPconf->pdacls;
-            memcpy(&gPconf->rowner, &newPconf->rowner, sizeof(OicUuid_t));
+            memcpy(&gPconf->rownerID, &newPconf->rownerID, sizeof(OicUuid_t));
 
             // to delete old value(prm, pdacl)
             newPconf->prm = oldPrm;
@@ -1229,3 +1231,42 @@ bool IsPairedDevice(const OicUuid_t* pdeviceId)
     }
     return false;
 }
+
+OCStackResult SetPconfRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gPconf)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gPconf)
+    {
+        memcpy(prevId.id, gPconf->rownerID.id, sizeof(prevId.id));
+        memcpy(gPconf->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = PconfToCBORPayload(gPconf, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_PCONF_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gPconf->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
+
index dc3cc14..f66b760 100644 (file)
@@ -559,3 +559,42 @@ void RestorePstatToInitState()
         }
     }
 }
+
+OCStackResult SetPstatRownerId(const OicUuid_t* newROwner)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    uint8_t *cborPayload = NULL;
+    size_t size = 0;
+    OicUuid_t prevId = {.id={0}};
+
+    if(NULL == newROwner)
+    {
+        ret = OC_STACK_INVALID_PARAM;
+    }
+    if(NULL == gPstat)
+    {
+        ret = OC_STACK_NO_RESOURCE;
+    }
+
+    if(newROwner && gPstat)
+    {
+        memcpy(prevId.id, gPstat->rownerID.id, sizeof(prevId.id));
+        memcpy(gPstat->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+        ret = PstatToCBORPayload(gPstat, &cborPayload, &size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        ret = UpdateSecureResourceInPS(OIC_JSON_PSTAT_NAME, cborPayload, size);
+        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+        OICFree(cborPayload);
+    }
+
+    return ret;
+
+exit:
+    OICFree(cborPayload);
+    memcpy(gPstat->rownerID.id, prevId.id, sizeof(prevId.id));
+    return ret;
+}
+
index a9b32a9..5d7859e 100644 (file)
@@ -130,6 +130,7 @@ OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Serv Type Value.");
 
         // Owners
+        // TODO: Need to modification to single ROwner, (Currently SINGLE_SERVICE_CLIENT_DRIVEN only)
         cborEncoderResult = cbor_encode_text_string(&svcMap, OIC_JSON_OWNERS_NAME,
             strlen(OIC_JSON_OWNERS_NAME));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Owners Tag.");
index 60710b0..1024a1f 100644 (file)
@@ -467,11 +467,7 @@ OicSecAcl_t* JSONToAclBin(const char * jsonStr)
     jsonAclObj = cJSON_GetObjectItem(jsonAclMap, OIC_JSON_ROWNERID_NAME);
     VERIFY_NON_NULL(TAG, jsonAclObj, ERROR);
     VERIFY_SUCCESS(TAG, cJSON_String == jsonAclObj->type, ERROR);
-    headAcl->ownersLen = 1;
-    VERIFY_SUCCESS(TAG, headAcl->ownersLen > 0, ERROR);
-    headAcl->owners = (OicUuid_t*)OICCalloc(headAcl->ownersLen, sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, (headAcl->owners), ERROR);
-    ret = ConvertStrToUuid(jsonAclObj->valuestring, &headAcl->owners[0]);
+    ret = ConvertStrToUuid(jsonAclObj->valuestring, &headAcl->rownerID);
     VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
 
     ret = OC_STACK_OK;
@@ -732,6 +728,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
         int numCred = cJSON_GetArraySize(jsonCredArray);
         VERIFY_SUCCESS(TAG, numCred > 0, ERROR);
         int idx = 0;
+        size_t ownersLen = 0;
         do
         {
             cJSON *jsonCred = cJSON_GetArrayItem(jsonCredArray, idx);
@@ -814,9 +811,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
                 VERIFY_NON_NULL(TAG, cred->period, ERROR);
                 strncpy(cred->period, jsonObj->valuestring, jsonObjLen);
             }
-
             cred->next = NULL;
-
         } while( ++idx < numCred);
     }
 
@@ -824,11 +819,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
     cJSON *jsonCredObj = cJSON_GetObjectItem(jsonCredMap, OIC_JSON_ROWNERID_NAME);
     VERIFY_NON_NULL(TAG, jsonCredObj, ERROR);
     VERIFY_SUCCESS(TAG, cJSON_String == jsonCredObj->type, ERROR);
-    headCred->ownersLen = 1;
-    VERIFY_SUCCESS(TAG, headCred->ownersLen > 0, ERROR);
-    headCred->owners = (OicUuid_t*)OICCalloc(headCred->ownersLen, sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, (headCred->owners), ERROR);
-    ret = ConvertStrToUuid(jsonCredObj->valuestring, &headCred->owners[0]);
+    ret = ConvertStrToUuid(jsonCredObj->valuestring, &headCred->rownerID);
     VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
     ret = OC_STACK_OK;
 
@@ -1014,12 +1005,7 @@ static OicSecAmacl_t* JSONToAmaclBin(const char * jsonStr)
     VERIFY_NON_NULL(TAG, jsonObj, ERROR);
     VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
 
-    headAmacl->ownersLen = 1;
-    VERIFY_SUCCESS(TAG, headAmacl->ownersLen > 0, ERROR);
-    headAmacl->owners = (OicUuid_t*)OICCalloc(headAmacl->ownersLen, sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, (headAmacl->owners), ERROR);
-
-    ret = ConvertStrToUuid(jsonObj->valuestring, &headAmacl->owners[0]);
+    ret = ConvertStrToUuid(jsonObj->valuestring, &headAmacl->rownerID);
     VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
 
     ret = OC_STACK_OK;
index e082eec..bf8069d 100644 (file)
@@ -69,12 +69,9 @@ TEST(ACLResourceTest, CBORDefaultACLConversion)
         defaultAcl->resources[i] = OICStrdup(defaulAclRsrc[i]);
         ASSERT_TRUE(defaultAcl->resources[i] != NULL);
     }
-    defaultAcl->ownersLen = 1;
     uint8_t defaultAclOwnrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
         0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
-    defaultAcl->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
-    ASSERT_TRUE(defaultAcl->owners != NULL);
-    memcpy(defaultAcl->owners[0].id, defaultAclOwnrs, sizeof(defaultAclOwnrs));
+    memcpy(defaultAcl->rownerID.id, defaultAclOwnrs, sizeof(defaultAclOwnrs));
 
     size_t defaultAclSize = 0;
     uint8_t *defaultPsStorage = NULL;
@@ -115,12 +112,10 @@ TEST(ACLResourceTest, CBORACLConversion)
         ASSERT_TRUE(secAcl->resources[i] != NULL);
 
     }
-    secAcl->ownersLen = 1;
+
     uint8_t ownrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
         0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
-    secAcl->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
-    ASSERT_TRUE(secAcl->owners != NULL);
-    memcpy(secAcl->owners[0].id, ownrs, sizeof(ownrs));
+    memcpy(secAcl->rownerID.id, ownrs, sizeof(ownrs));
 
     OicSecAcl_t *secAcl1 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
     ASSERT_TRUE(secAcl1 != NULL);
@@ -135,10 +130,7 @@ TEST(ACLResourceTest, CBORACLConversion)
         secAcl1->resources[i] = OICStrdup(rsrc1[i]);
         ASSERT_TRUE(secAcl1->resources[i] != NULL);
     }
-    secAcl1->ownersLen = 1;
-    secAcl1->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
-    ASSERT_TRUE(secAcl1->owners != NULL);
-    memcpy(secAcl1->owners[0].id, ownrs, sizeof(ownrs));
+    memcpy(secAcl1->rownerID.id, ownrs, sizeof(ownrs));
     secAcl->next = secAcl1;
 
     OicSecAcl_t *secAcl2 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
@@ -156,10 +148,7 @@ TEST(ACLResourceTest, CBORACLConversion)
         secAcl2->resources[i] = OICStrdup(rsrc2[i]);
         ASSERT_TRUE(secAcl2->resources[i] != NULL);
     }
-    secAcl2->ownersLen = 1;
-    secAcl2->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
-    ASSERT_TRUE(secAcl2->owners != NULL);
-    memcpy(secAcl2->owners[0].id, ownrs, sizeof(ownrs));
+    memcpy(secAcl2->rownerID.id, ownrs, sizeof(ownrs));
     secAcl1->next = secAcl2;
 
     OicSecAcl_t *secAcl3 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
@@ -177,13 +166,7 @@ TEST(ACLResourceTest, CBORACLConversion)
         secAcl3->resources[i] = OICStrdup(rsrc3[i]);
         ASSERT_TRUE(secAcl3->resources[i] != NULL);
     }
-    secAcl3->ownersLen = 2;
-    secAcl3->owners = (OicUuid_t *)OICCalloc(2, sizeof(OicUuid_t));
-    ASSERT_TRUE(secAcl3->owners != NULL);
-    memcpy(secAcl3->owners[0].id, ownrs, sizeof(ownrs));
-    uint8_t ownrs1[] = {0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
-                        0x34, 0x34, 0x34, 0x34, 0x34, 0x34};
-    memcpy(secAcl3->owners[1].id, ownrs1, sizeof(ownrs1));
+    memcpy(secAcl3->rownerID.id, ownrs, sizeof(ownrs));
     secAcl2->next = secAcl3;
     secAcl3->next = NULL;
 
@@ -196,7 +179,6 @@ TEST(ACLResourceTest, CBORACLConversion)
     EXPECT_EQ(2, acl->permission);
     EXPECT_EQ(6 , acl->resourcesLen);
     EXPECT_STREQ("/oic/res", acl->resources[0]);
-    EXPECT_EQ(1, acl->ownersLen);
     DeleteACLList(acl);
     OICFree(psStorage);
     DeleteACLList(secAcl);
@@ -342,10 +324,7 @@ static OCStackResult  populateAcl(OicSecAcl_t *acl,  int numRsrc)
         OICStrcpy(acl->resources[1], sizeof(acl->resources[1]) - 1, "/a/fan");
     }
     acl->permission = 6;
-    acl->ownersLen = 1;
-    acl->owners = (OicUuid_t*)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
-    VERIFY_NON_NULL(TAG, acl->owners, ERROR);
-    memcpy(acl->owners->id, "1111111111111111", sizeof(acl->owners->id));
+    memcpy(acl->rownerID.id, "1111111111111111", sizeof(acl->rownerID.id));
 
     ret = OC_STACK_OK;
 exit:
index 493a8d1..5a138ef 100644 (file)
@@ -69,16 +69,9 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
         secAmacl->resources[i] = OICStrdup(rsrc[i]);
         ASSERT_TRUE(NULL != secAmacl->resources[i]);
     }
-    secAmacl->ownersLen = 1;
     uint8_t ownrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
         0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
-    secAmacl->owners = (OicUuid_t *)OICCalloc(1, sizeof(*secAmacl->owners));
-    if (!secAmacl->owners)
-    {
-        DeleteAmaclList(secAmacl);
-    }
-    ASSERT_TRUE(NULL != secAmacl->owners);
-    memcpy(secAmacl->owners[0].id, ownrs, sizeof(ownrs));
+    memcpy(secAmacl->rownerID.id, ownrs, sizeof(ownrs));
 
     OicSecAmacl_t *secAmacl1 = (OicSecAmacl_t *) OICCalloc(1, sizeof(*secAmacl1));
     if (!secAmacl1)
@@ -112,15 +105,7 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
         secAmacl1->resources[i] = OICStrdup(rsrc1[i]);
         ASSERT_TRUE(NULL != secAmacl1->resources[i]);
     }
-    secAmacl1->ownersLen = 1;
-    secAmacl1->owners = (OicUuid_t *)OICCalloc(1, sizeof(*secAmacl1->owners));
-    if (!secAmacl1->owners)
-    {
-        DeleteAmaclList(secAmacl);
-        DeleteAmaclList(secAmacl1);
-    }
-    ASSERT_TRUE(NULL != secAmacl1->owners);
-    memcpy(secAmacl1->owners[0].id, ownrs, sizeof(ownrs));
+    memcpy(secAmacl1->rownerID.id, ownrs, sizeof(ownrs));
     secAmacl1->next = NULL;
     secAmacl->next = secAmacl1;
 
@@ -148,8 +133,7 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
     EXPECT_STREQ(secAmacl->resources[0], amacl->resources[0]);
     EXPECT_STREQ(secAmacl->resources[1], amacl->resources[1]);
     EXPECT_EQ(secAmacl->resourcesLen, amacl->resourcesLen);
-    EXPECT_EQ(secAmacl->ownersLen, amacl->ownersLen);
-    EXPECT_EQ(*secAmacl->owners[0].id, *amacl->owners[0].id);
+    EXPECT_EQ(memcmp(secAmacl->rownerID.id, amacl->rownerID.id, sizeof(amacl->rownerID.id)), 0);
 
     DeleteAmaclList(secAmacl);
     DeleteAmaclList(amacl);
index 4b18c8a..4ecf9aa 100644 (file)
@@ -55,10 +55,7 @@ OicSecCred_t * getCredList()
     cred->privateData.data = (uint8_t *)OICCalloc(1, strlen("My private Key11") + 1);
     VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
     OICStrcpy((char *)cred->privateData.data, strlen("My private Key11")+1,"My private Key11");
-    cred->ownersLen = 1;
-    cred->owners = (OicUuid_t *)OICCalloc(cred->ownersLen, sizeof(*cred->owners));
-    VERIFY_NON_NULL(TAG, cred->owners, ERROR);
-    OICStrcpy((char *)cred->owners[0].id, sizeof(cred->owners[0].id), "aaaaaaaaaaaaaaaa");
+    OICStrcpy((char *)cred->rownerID.id, sizeof(cred->rownerID.id), "aaaaaaaaaaaaaaaa");
     cred->next = (OicSecCred_t*)OICCalloc(1, sizeof(*cred->next));
     VERIFY_NON_NULL(TAG, cred->next, ERROR);
     cred->next->credId = 5678;
@@ -77,11 +74,7 @@ OicSecCred_t * getCredList()
     VERIFY_NON_NULL(TAG, cred->next->publicData.data, ERROR);
     OICStrcpy(cred->next->publicData.data, sz,"My Public Key123");
 #endif
-    cred->next->ownersLen = 2;
-    cred->next->owners = (OicUuid_t *)OICCalloc(cred->next->ownersLen, sizeof(*cred->next->owners));
-    VERIFY_NON_NULL(TAG, cred->next->owners, ERROR);
-    OICStrcpy((char *)cred->next->owners[0].id, sizeof(cred->next->owners[0].id), "bbbbbbbbbbbbbbbb");
-    OICStrcpy((char *)cred->next->owners[1].id, sizeof(cred->next->owners[1].id), "cccccccccccccccc");
+    OICStrcpy((char *)cred->next->rownerID.id, sizeof(cred->next->rownerID.id), "bbbbbbbbbbbbbbbb");
 
     return cred;
 
@@ -114,11 +107,7 @@ static void printCred(const OicSecCred_t * cred)
            OIC_LOG_V(INFO, TAG, "cred->publicData.data = %s", credTmp1->publicData.data);
         }
 #endif /* __WITH_X509__ */
-        OIC_LOG_V(INFO, TAG, "cred->ownersLen = %zu", credTmp1->ownersLen);
-        for(size_t i = 0; i < cred->ownersLen; i++)
-        {
-            OIC_LOG_V(INFO, TAG, "cred->owners[%zu].id = %s", i, credTmp1->owners[i].id);
-        }
+       OIC_LOG_V(INFO, TAG, "cred->rownerID = %s", credTmp1->rownerID.id);
     }
 }
 
@@ -301,8 +290,8 @@ TEST(CredResourceTest, GetCredResourceDataNULLSubject)
 
 TEST(CredResourceTest, GenerateCredentialValidInput)
 {
-    OicUuid_t owners[1];
-    OICStrcpy((char *)owners[0].id, strlen("ownersId21"), "ownersId21");
+    OicUuid_t rownerID = {{0}};
+    OICStrcpy((char *)rownerID.id, strlen("ownersId21"), "ownersId21");
 
     OicUuid_t subject = {{0}};
     OICStrcpy((char *)subject.id, strlen("subject11"), "subject11");
@@ -311,9 +300,8 @@ TEST(CredResourceTest, GenerateCredentialValidInput)
     OicSecKey_t key = {privateKey, sizeof(privateKey)};
 
     OicSecCred_t * cred  = NULL;
-
     cred = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
-                              &key, 1, owners);
+                              &key, &rownerID);
     printCred(cred);
 
     ASSERT_TRUE(NULL != cred);
@@ -322,8 +310,8 @@ TEST(CredResourceTest, GenerateCredentialValidInput)
 
 TEST(CredResourceTest, GenerateAndAddCredentialValidInput)
 {
-    OicUuid_t owners[1];
-    OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId11");
+    OicUuid_t rownerID = {{0}};
+    OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId11");
 
     OicUuid_t subject = {{0}};
     OICStrcpy((char *)subject.id, sizeof(subject.id), "subject11");
@@ -335,21 +323,21 @@ TEST(CredResourceTest, GenerateAndAddCredentialValidInput)
     OicSecCred_t *headCred = NULL;
 
     cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
-                               &key, 1, owners);
+                               &key, &rownerID);
 
     EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
     headCred = cred1;
 
-    OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId22");
+    OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId22");
     OICStrcpy((char *)subject.id, sizeof(subject.id), "subject22");
     cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
-                               &key, 1, owners);
+                               &key, &rownerID);
     EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
 
-    OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId33");
+    OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId33");
     OICStrcpy((char *)subject.id, sizeof(subject.id), "subject33");
     cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
-                               &key, 1, owners);
+                               &key, &rownerID);
     EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
 
     const OicSecCred_t* credList = GetCredResourceData(&headCred->subject);
index 57af892..b2c9825 100644 (file)
@@ -272,9 +272,6 @@ static void deleteACL(OicSecAcl_t *acl)
         }
         OICFree((acl)->resources);
 
-        /* Clean Owners */
-        OICFree((acl)->owners);
-
         /* Clean ACL node itself */
         /* Required only if acl was created in heap */
         OICFree((acl));
@@ -431,40 +428,26 @@ static int InputACL(OicSecAcl_t *acl)
     } while (0 != ret );
 
     // Set Rowner
-    printf("Num. of Rowner : ");
-    ret = scanf("%zu", &acl->ownersLen);
-    if ((1 != ret) || (acl->ownersLen <= 0 || acl->ownersLen > 20))
-    {
-        printf("Error while input\n");
-        return -1;
-    }
     printf("-URN identifying the rowner\n");
     printf("ex) 1111-1111-1111-1111 (16 Numbers except to '-')\n");
-    acl->owners = (OicUuid_t *)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
-    if (NULL == acl->owners)
+
+    printf("Rowner : ");
+    ret = scanf("%19ms", &temp_id);
+    if (1 != ret)
     {
-        OIC_LOG(ERROR, TAG, "Error while memory allocation");
+        printf("Error while input\n");
         return -1;
     }
-    for (size_t i = 0; i < acl->ownersLen; i++)
-    {
-        printf("[%zu]Rowner : ", i + 1);
-        ret = scanf("%19ms", &temp_id);
-        if (1 != ret)
-        {
-            printf("Error while input\n");
-            return -1;
-        }
 
-        for (int k = 0, j = 0; temp_id[k] != '\0'; k++)
+    for (int k = 0, j = 0; temp_id[k] != '\0'; k++)
+    {
+        if (DASH != temp_id[k])
         {
-            if (DASH != temp_id[k])
-            {
-                acl->owners[i].id[j++] = temp_id[k];
-            }
+            acl->rownerID.id[j++] = temp_id[k];
         }
-        OICFree(temp_id);
     }
+    OICFree(temp_id);
+
     return 0;
 }