[IOT-1873] Implement OCF Security CR50
authorDan Mihai <Daniel.Mihai@microsoft.com>
Wed, 1 Mar 2017 03:28:30 +0000 (19:28 -0800)
committerKevin Kane <kkane@microsoft.com>
Wed, 8 Mar 2017 18:54:02 +0000 (18:54 +0000)
1. Removed entire resource:

/oic/sec/svc

2. Removed resource properties:
    a. From /oic/sec/amacl:
        rowneruuid
        ams
        amsuuid
    b. From /oic/sec/pstat:
        deviceuuid

Change-Id: I7bbe344feb0a99ca2f8d5e77eef64f840164bc20
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17607
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
19 files changed:
resource/csdk/security/SConscript
resource/csdk/security/include/internal/amaclresource.h
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/include/internal/svcresource.h [deleted file]
resource/csdk/security/include/securevirtualresourcetypes.h
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/policyengine.c
resource/csdk/security/src/psinterface.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/resourcemanager.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/src/svcresource.c [deleted file]
resource/csdk/security/tool/json2cbor.c
resource/csdk/security/unittest/SConscript
resource/csdk/security/unittest/amaclresourcetest.cpp
resource/csdk/security/unittest/pstatresource.cpp
resource/csdk/security/unittest/svcresourcetest.cpp [deleted file]

index 28c016f..842471e 100644 (file)
@@ -113,7 +113,6 @@ libocsrm_src = [
        OCSRM_SRC + 'pstatresource.c',
        OCSRM_SRC + 'doxmresource.c',
        OCSRM_SRC + 'credresource.c',
-       OCSRM_SRC + 'svcresource.c',
        OCSRM_SRC + 'pconfresource.c',
        OCSRM_SRC + 'dpairingresource.c',
        OCSRM_SRC + 'policyengine.c',
index d7a524a..d31eb54 100644 (file)
@@ -46,19 +46,6 @@ OCStackResult InitAmaclResource();
 void DeInitAmaclResource();
 
 /**
- * This method is used by PolicyEngine to retrieve amsId for the resource.
- * If the Amacl is found for the given resource then populate the parameter
- * amsId with Amacl resource amss id.
- *
- * @param resource for which AMS service is required.
- * @param amsId of the ams service for the given resource.
- *
- * @return ::OC_STACK_OK, if Amacl is found for the resource, else ::OC_STACK_ERROR,
- *  if no Amacl found for the resource.
- */
-OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
-
-/**
  * This function converts Amacl data into CBOR format.
  * Caller needs to invoke 'free' when done using returned string.
  *
@@ -73,23 +60,6 @@ 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);
-
-/**
- * Gets the OicUuid_t value for the rownerid of the amacl resource.
- *
- * @param rowneruuid a pointer to be assigned to the rowneruuid property
- * @return ::OC_STACK_OK if rowneruuid is assigned correctly, else ::OC_STACK_ERROR.
- */
-OCStackResult GetAmaclRownerId(OicUuid_t *rowneruuid);
-
 #ifdef __cplusplus
 }
 #endif
index aa21018..85ba6e8 100644 (file)
@@ -92,7 +92,6 @@ extern const char * OIC_JSON_VER_NAME;
 //reset profile
 extern const char * OIC_JSON_RESET_PF_NAME;
 
-extern const char * OIC_JSON_SUBJECT_NAME;
 extern const char * OIC_JSON_SUBJECTID_NAME;
 extern const char * OIC_JSON_RESOURCES_NAME;
 extern const char * OIC_JSON_AMSS_NAME;
@@ -143,7 +142,6 @@ extern const char * OIC_JSON_EDP_NAME;
 extern const char * OIC_JSON_PIN_NAME;
 extern const char * OIC_JSON_PDACL_NAME;
 extern const char * OIC_JSON_PDDEV_LIST_NAME;
-extern const char * OIC_JSON_ROWNER_NAME;
 extern const char * OIC_JSON_PRM_NAME;
 extern const char * OIC_JSON_SPM_NAME;
 extern const char * OIC_JSON_PDEVICE_ID_NAME;
diff --git a/resource/csdk/security/include/internal/svcresource.h b/resource/csdk/security/include/internal/svcresource.h
deleted file mode 100644 (file)
index e6ff9bc..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-//******************************************************************
-//
-// Copyright 2015 Intel Mobile Communications GmbH 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 IOTVT_SRM_SVCR_H
-#define IOTVT_SRM_SVCR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Initialize SVC resource by loading data from persistent storage.
- *
- * @return ::OC_STACK_OK for Success, otherwise some error value.
- */
-OCStackResult InitSVCResource();
-
-/**
- * Perform cleanup for SVC resources.
- */
-void DeInitSVCResource();
-
-/**
- * This function converts SVC data into CBOR format.
- * Caller needs to invoke 'free' when done using returned string.
- *
- * @param svc is the instance of @ref OicSecSvc_t structure. In case of NULL it
- * will return ::OC_STACK_INVALID_PARAM.
- * @param cborPayload is the converted cbor value of SVC structure.
- * @param cborSize is the size of the cbor payload. This value is the size of the
- * cborPayload. It should not be NON-NULL value.
- *
- * @return ::OC_STACK_OK for Success. ::OC_STACK_INVALID_PARAM in case of invalid parameters.
- * ::OC_STACK_ERROR in case of error in converting to cbor.
- */
- OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
-                                size_t *cborSize);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //IOTVT_SRM_SVCR_H
index cd34e43..4891850 100644 (file)
@@ -434,9 +434,6 @@ struct OicSecAmacl
     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
     size_t              resourcesLen;   // the number of elts in Resources
     char                **resources;    // 0:R:M:Y:String
-    size_t              amssLen;        // the number of elts in Amss
-    OicUuid_t           *amss;          // 1:R:M:Y:acl
-    OicUuid_t           rownerID;        // 2:R:S:Y:oic.uuid
     OicSecAmacl_t         *next;
 };
 
@@ -515,7 +512,6 @@ struct OicSecPstat
     bool                isOp;           // 0:R:S:Y:Boolean
     OicSecDpm_t         cm;             // 1:R:S:Y:oic.sec.dpm
     OicSecDpm_t         tm;             // 2:RW:S:Y:oic.sec.dpm
-    OicUuid_t           deviceID;       // 3:R:S:Y:oic.uuid
     OicSecDpom_t        om;             // 4:RW:M:Y:oic.sec.dpom
     size_t              smLen;          // the number of elts in Sm
     OicSecDpom_t        *sm;            // 5:R:M:Y:oic.sec.dpom
@@ -547,20 +543,6 @@ struct OicSecSacl
 #endif
 };
 
-/**
- * /oic/sec/svc (Service requiring a secure connection) data type.
- * Derived from OIC Security Spec; see Spec for details.
- */
-struct OicSecSvc
-{
-    // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
-    OicUuid_t               svcdid;                 //0:R:S:Y:oic.uuid
-    OicSecSvcType_t         svct;                   //1:R:M:Y:OIC Service Type
-    size_t                  ownersLen;              //2:the number of elts in Owners
-    OicUuid_t               *owners;                //3:R:M:Y:oic.uuid
-    OicSecSvc_t             *next;
-};
-
 #if defined(__WITH_DTLS__) ||  defined(__WITH_TLS__)
 struct OicSecCrl
 {
index 9c68a11..2646f3a 100644 (file)
@@ -2345,7 +2345,6 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
 
     pstat->cm = RESET;
     pstat->isOp = false;
-    memcpy(pstat->deviceID.id, pTargetDev->doxm->deviceID.id, sizeof(OicUuid_t));
     pstat->tm = TAKE_OWNER;
     pstat->om = (OicSecDpom_t)(SINGLE_SERVICE_CLIENT_DRIVEN); // the only mode IoTivity supports currently
     pstat->smLen = 1;
index 82e94e4..8d2238f 100644 (file)
@@ -64,9 +64,6 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
             }
             OICFree(amaclTmp1->resources);
 
-            // Clean Amss
-            OICFree(amaclTmp1->amss);
-
             // Clean Amacl node itself
             OICFree(amaclTmp1);
         }
@@ -95,8 +92,6 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
     int64_t cborEncoderResult = CborNoError;
     CborEncoder rsrcMap;
     CborEncoder rlistArray;
-    CborEncoder amss;
-    char *stRowner = NULL;
 
     const OicSecAmacl_t *amacl = amaclS;
     uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
@@ -169,35 +164,6 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
     cborEncoderResult = cbor_encoder_close_container(&amaclMap, &rsrcMap);
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Resource Map.");
 
-    // TODO : Need to modify type of OicSecAmacl_t->amss based on RAML spec.
-    // ams -- Mandatory
-    cborEncoderResult = cbor_encode_text_string(&amaclMap, OIC_JSON_AMS_NAME,
-                strlen(OIC_JSON_AMS_NAME));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding AMSS Name Tag.");
-
-    cborEncoderResult = cbor_encoder_create_array(&amaclMap, &amss, amacl->amssLen);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding AMS Name Array.");
-    for (size_t i = 0; i < amacl->amssLen; i++)
-    {
-        cborEncoderResult = cbor_encode_text_string(&amss, (const char *)amacl->amss[i].id,
-            sizeof(amacl->amss[i].id));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding AMS Name Value.");
-    }
-    cborEncoderResult = cbor_encoder_close_container(&amaclMap, &amss);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing AMSS Array.");
-
-    // TODO : Need to check owner property in the RAML spec.
-    // 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.");
-
-    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.");
-    OICFree(stRowner);
-
     cborEncoderResult = cbor_encoder_close_container(&encoder, &amaclMap);
     VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Amacl Map.");
 
@@ -374,51 +340,8 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
                 }
                 OICFree(rsrcName);
             }
-
-        }
-
-        // TODO : Need to modify type of OicSecAmacl_t->amss based on RAML spec.
-         // Ams -- Mandatory
-        if (0 == strcmp(OIC_JSON_AMS_NAME, name))
-        {
-            int i = 0;
-            CborValue amsArray = { .parser = NULL };
-            cborFindResult = cbor_value_get_array_length(&amaclMap, &headAmacl->amssLen);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding AMS Array Len.");
-            cborFindResult = cbor_value_enter_container(&amaclMap, &amsArray);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering AMS Array Container.");
-            headAmacl->amss = (OicUuid_t *)OICCalloc(headAmacl->amssLen, sizeof(*headAmacl->amss));
-            VERIFY_NOT_NULL(TAG, headAmacl->amss, ERROR);
-            while (cbor_value_is_valid(&amsArray) && cbor_value_is_text_string(&amsArray))
-            {
-                char *amssId = NULL;
-                cborFindResult = cbor_value_dup_text_string(&amsArray, &amssId, &len, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding AMS Id.");
-                cborFindResult = cbor_value_advance(&amsArray);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing AMS.");
-                memcpy(headAmacl->amss[i++].id, (OicUuid_t *)amssId, len);
-                OICFree(amssId);
-            }
-        }
-
-        // Rowner -- Mandatory
-        if (0 == strcmp(OIC_JSON_ROWNERID_NAME, name) && cbor_value_is_text_string(&amaclMap))
-        {
-            char *stRowner = NULL;
-            cborFindResult = cbor_value_dup_text_string(&amaclMap, &stRowner, &len, NULL);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding ROwner Value.");
-
-            ret = ConvertStrToUuid(stRowner, &headAmacl->rownerID);
-            VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
-            OICFree(stRowner);
         }
 
-        //if (CborMapType != type && cbor_value_is_valid(&amaclMap))
-        if (cbor_value_is_valid(&amaclMap))
-        {
-            cborFindResult = cbor_value_advance(&amaclMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Amacl Map.");
-        }
         OICFree(name);
     }
 
@@ -596,76 +519,3 @@ void DeInitAmaclResource()
     DeleteAmaclList(gAmacl);
     gAmacl = NULL;
 }
-
-OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsDeviceId)
-{
-    OicSecAmacl_t *amacl = NULL;
-
-    VERIFY_NOT_NULL(TAG, resource, ERROR);
-    VERIFY_NOT_NULL(TAG, amsDeviceId, ERROR);
-
-    LL_FOREACH(gAmacl, amacl)
-    {
-        for(size_t i = 0; i < amacl->resourcesLen; i++)
-        {
-            if (0 == strncmp((amacl->resources[i]), resource, strlen(amacl->resources[i])))
-            {
-                //Returning the ID of the first AMS service for the resource
-                memcpy(amsDeviceId, &amacl->amss[0], sizeof(*amsDeviceId));
-                return OC_STACK_OK;
-            }
-        }
-    }
-
-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;
-}
-
-OCStackResult GetAmaclRownerId(OicUuid_t *rowneruuid)
-{
-    OCStackResult retVal = OC_STACK_ERROR;
-    if (gAmacl)
-    {
-        *rowneruuid = gAmacl->rownerID;
-        retVal = OC_STACK_OK;
-    }
-    return retVal;
-}
index 5832b57..1814459 100644 (file)
@@ -1411,12 +1411,6 @@ static OCEntityHandlerResult HandleDoxmPostRequest(OCEntityHandlerRequest * ehRe
                     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)
                 {
index 3029ce7..05cded1 100644 (file)
@@ -217,47 +217,18 @@ static bool IsValidRequestFromSubOwner(SRMRequestContext_t *context)
 }
 #endif //MULTIPLE_OWNER
 
-// TODO - remove these function placeholders as they are implemented
-// in the resource entity handler code.
-// Note that because many SVRs do not have a rowner, in those cases we
-// just return "OC_STACK_ERROR" which results in a "false" return by
-// IsRequestFromResourceOwner().
-// As these SVRs are revised to have a rowner, these functions should be
-// replaced (see pstatresource.c for example of GetPstatRownerId).
-
-OCStackResult GetCrlRownerId(OicUuid_t *rowner)
-{
-    OC_UNUSED(rowner);
-    rowner = NULL;
-    return OC_STACK_ERROR;
-}
-
-OCStackResult GetSaclRownerId(OicUuid_t *rowner)
-{
-    OC_UNUSED(rowner);
-    rowner = NULL;
-    return OC_STACK_ERROR;
-}
-
-OCStackResult GetSvcRownerId(OicUuid_t *rowner)
-{
-    OC_UNUSED(rowner);
-    rowner = NULL;
-    return OC_STACK_ERROR;
-}
-
 static GetSvrRownerId_t GetSvrRownerId[OIC_SEC_SVR_TYPE_COUNT + 1] = {
     NULL,
     GetAclRownerId,
-    GetAmaclRownerId,
+    NULL,               // amacl's rowneruuid has been removed from the OCF 1.0 Security spec.
     GetCredRownerId,
-    GetCrlRownerId,
+    NULL,               // crl doesn't have rowneruuid.
     GetDoxmRownerId,
     GetDpairingRownerId,
     GetPconfRownerId,
     GetPstatRownerId,
-    GetSaclRownerId,
-    GetSvcRownerId
+    NULL,               // sacl is not implemented yet.
+    NULL                // svc has been removed from the OCF 1.0 Security spec.
 };
 
 /**
@@ -278,7 +249,9 @@ bool IsRequestFromResourceOwner(SRMRequestContext_t *context)
     if((OIC_R_ACL_TYPE <= context->resourceType) && \
         (OIC_SEC_SVR_TYPE_COUNT > context->resourceType))
     {
-        if(OC_STACK_OK == GetSvrRownerId[(int)context->resourceType](&resourceOwner))
+        GetSvrRownerId_t getRownerId = GetSvrRownerId[(int)context->resourceType];
+
+        if((NULL != getRownerId) && (OC_STACK_OK == getRownerId(&resourceOwner)))
         {
             retVal = UuidCmp(&context->subjectUuid, &resourceOwner);
         }
index eec45af..2f90135 100644 (file)
@@ -232,12 +232,6 @@ OCStackResult UpdateSecureResourceInPS(const char *rsrcName, const uint8_t *psPa
                 cborFindResult = cbor_value_dup_byte_string(&curVal, &amaclCbor, &amaclCborLen, NULL);
                 VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding AMACL Name Value.");
             }
-            cborFindResult = cbor_value_map_find_value(&cbor, OIC_JSON_SVC_NAME, &curVal);
-            if (CborNoError == cborFindResult && cbor_value_is_byte_string(&curVal))
-            {
-                cborFindResult = cbor_value_dup_byte_string(&curVal, &svcCbor, &svcCborLen, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding SVC Name Value.");
-            }
             cborFindResult = cbor_value_map_find_value(&cbor, OIC_JSON_CRED_NAME, &curVal);
             if (CborNoError == cborFindResult && cbor_value_is_byte_string(&curVal))
             {
@@ -322,13 +316,6 @@ OCStackResult UpdateSecureResourceInPS(const char *rsrcName, const uint8_t *psPa
                 cborEncoderResult |= cbor_encode_byte_string(&secRsrc, amaclCbor, amaclCborLen);
                 VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Amacl Value.");
             }
-            if (strcmp(OIC_JSON_SVC_NAME, rsrcName) && svcCborLen)
-            {
-                cborEncoderResult |= cbor_encode_text_string(&secRsrc, OIC_JSON_SVC_NAME, strlen(OIC_JSON_SVC_NAME));
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SVC Name.");
-                cborEncoderResult |= cbor_encode_byte_string(&secRsrc, svcCbor, svcCborLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SVC Value.");
-            }
             if (strcmp(OIC_JSON_CRED_NAME, rsrcName) && credCborLen)
             {
                 cborEncoderResult |= cbor_encode_text_string(&secRsrc, OIC_JSON_CRED_NAME, strlen(OIC_JSON_CRED_NAME));
index 2dfc275..267cd14 100644 (file)
@@ -54,7 +54,6 @@ static OicSecPstat_t gDefaultPstat =
     false,                                    // bool isop
     TAKE_OWNER,                               // OicSecDpm_t cm
     NORMAL,                                   // OicSecDpm_t tm
-    {.id = {0}},                              // OicUuid_t deviceID
     SINGLE_SERVICE_CLIENT_DRIVEN,             // OicSecDpom_t om */
     1,                                        // the number of elts in Sms
     &gSm,                                     // OicSecDpom_t *sm
@@ -156,16 +155,6 @@ OCStackResult PstatToCBORPayload(const OicSecPstat_t *pstat, uint8_t **payload,
         cborEncoderResult = cbor_encode_int(&pstatMap, pstat->sm[0]);
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SM Name Value.");
 
-        cborEncoderResult = cbor_encode_text_string(&pstatMap, OIC_JSON_DEVICE_ID_NAME,
-            strlen(OIC_JSON_DEVICE_ID_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Device Id Tag.");
-        ret = ConvertUuidToStr(&pstat->deviceID, &strUuid);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret , ERROR);
-        cborEncoderResult = cbor_encode_text_string(&pstatMap, strUuid, strlen(strUuid));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Device Id Value.");
-        OICFree(strUuid);
-        strUuid = NULL;
-
         cborEncoderResult = cbor_encode_text_string(&pstatMap, OIC_JSON_ROWNERID_NAME,
             strlen(OIC_JSON_ROWNERID_NAME));
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROwner Id Tag.");
@@ -291,23 +280,6 @@ static OCStackResult CBORPayloadToPstatBin(const uint8_t *cborPayload, const siz
         cborFindResult = CborNoError;
     }
 
-    cborFindResult = cbor_value_map_find_value(&pstatCbor, OIC_JSON_DEVICE_ID_NAME, &pstatMap);
-    if (CborNoError == cborFindResult && cbor_value_is_text_string(&pstatMap))
-    {
-        cborFindResult = cbor_value_dup_text_string(&pstatMap, &strUuid , &len, NULL);
-        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Device Id Value.");
-        ret = ConvertStrToUuid(strUuid , &pstat->deviceID);
-        VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-        OICFree(strUuid );
-        strUuid  = NULL;
-
-    }
-    else
-    {
-        memcpy(&pstat->deviceID, &gPstat->deviceID, sizeof(OicUuid_t));
-        cborFindResult = CborNoError;
-    }
-
     cborFindResult = cbor_value_map_find_value(&pstatCbor, OIC_JSON_CM_NAME, &pstatMap);
     if (CborNoError == cborFindResult && cbor_value_is_integer(&pstatMap))
     {
@@ -611,7 +583,6 @@ static OCEntityHandlerResult HandlePstatPostRequest(OCEntityHandlerRequest *ehRe
             gPstat->om = pstat->om;
             gPstat->tm = pstat->tm;
             gPstat->cm = pstat->cm;
-            memcpy(&(gPstat->deviceID), &(pstat->deviceID), sizeof(OicUuid_t));
             memcpy(&(gPstat->rownerID), &(pstat->rownerID), sizeof(OicUuid_t));
 
             // Convert pstat data into CBOR for update to persistent storage
@@ -751,7 +722,6 @@ OCStackResult InitPstatResource()
     // Read Pstat resource from PS
     uint8_t *data = NULL;
     size_t size = 0;
-    OicUuid_t emptyUuid = {.id={0}};
     ret = GetSecureVirtualDatabaseFromPS(OIC_JSON_PSTAT_NAME, &data, &size);
     // If database read failed
     if (OC_STACK_OK != ret)
@@ -775,16 +745,6 @@ OCStackResult InitPstatResource()
     }
     VERIFY_NOT_NULL(TAG, gPstat, FATAL);
 
-    //In case of Pstat's device id is empty, fill the device id as doxm's device id.
-    if(0 == memcmp(&gPstat->deviceID, &emptyUuid, sizeof(OicUuid_t)))
-    {
-        OicUuid_t doxmUuid = {.id={0}};
-        if(OC_STACK_OK == GetDoxmDeviceID(&doxmUuid))
-        {
-            memcpy(&gPstat->deviceID, &doxmUuid, sizeof(OicUuid_t));
-        }
-    }
-
     // Instantiate 'oic.sec.pstat'
     ret = CreatePstatResource();
 
@@ -907,7 +867,6 @@ OCStackResult SetPstatSelfOwnership(const OicUuid_t* newROwner)
         gPstat->cm = (OicSecDpm_t)(gPstat->cm & (~TAKE_OWNER));
         gPstat->isOp = true;
 
-        memcpy(gPstat->deviceID.id, newROwner->id, sizeof(newROwner->id));
         memcpy(gPstat->rownerID.id, newROwner->id, sizeof(newROwner->id));
 
         ret = PstatToCBORPayload(gPstat, &cborPayload, &size, false);
index 221b873..323a0bf 100644 (file)
@@ -25,7 +25,6 @@
 #include "pstatresource.h"
 #include "doxmresource.h"
 #include "credresource.h"
-#include "svcresource.h"
 #include "amaclresource.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
@@ -100,10 +99,6 @@ OCStackResult InitSecureResources( )
 #endif // __WITH_DTLS__ || __WITH_TLS__
     if(OC_STACK_OK == ret)
     {
-        ret = InitSVCResource();
-    }
-    if(OC_STACK_OK == ret)
-    {
         ret = InitAmaclResource();
     }
 //#ifdef DIRECT_PAIRING
@@ -137,7 +132,6 @@ OCStackResult DestroySecureResources( )
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     DeInitCRLResource();
 #endif // __WITH_DTLS__ || __WITH_TLS__
-    DeInitSVCResource();
     DeInitAmaclResource();
 //#ifdef DIRECT_PAIRING
     DeInitPconfResource();
index da88d58..3d4b913 100644 (file)
@@ -58,12 +58,12 @@ const char * OIC_RSRC_TYPE_SEC_CRL = "oic.r.crl";
 const char * OIC_RSRC_CRL_URI =  "/oic/sec/crl";
 const char * OIC_JSON_CRL_NAME = "crl";
 
-//SACL
+//SACL - not implemented yet
 const char * OIC_RSRC_TYPE_SEC_SACL = "oic.r.sacl";
 const char * OIC_RSRC_SACL_URI =  "/oic/sec/sacl";
 const char * OIC_JSON_SACL_NAME = "sacl";
 
-//svc
+//svc - removed from the OCF 1.0 Security spec and from IoTivity
 const char * OIC_RSRC_TYPE_SEC_SVC = "oic.r.svc";
 const char * OIC_RSRC_SVC_URI =  "/oic/sec/svc";
 const char * OIC_JSON_SVC_NAME = "svc";
@@ -86,7 +86,6 @@ const char * OIC_JSON_VER_NAME = "ver";
 //reset profile
 const char * OIC_JSON_RESET_PF_NAME = "resetpf";
 
-const char * OIC_JSON_SUBJECT_NAME = "subject";
 const char * OIC_JSON_RESOURCES_NAME = "resources";
 const char * OIC_JSON_AMSS_NAME = "amss";
 const char * OIC_JSON_AMS_NAME = "ams";
@@ -137,7 +136,6 @@ const char * OIC_JSON_EDP_NAME = "edp";
 const char * OIC_JSON_PIN_NAME = "pin";
 const char * OIC_JSON_PDACL_NAME = "pdacl";
 const char * OIC_JSON_PDDEV_LIST_NAME = "pddev";
-const char * OIC_JSON_ROWNER_NAME = "rowner";
 const char * OIC_JSON_PRM_NAME = "prm";
 const char * OIC_JSON_SPM_NAME = "spm";
 const char * OIC_JSON_PDEVICE_ID_NAME = "pdeviceuuid";
diff --git a/resource/csdk/security/src/svcresource.c b/resource/csdk/security/src/svcresource.c
deleted file mode 100644 (file)
index 781ff97..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-//******************************************************************
-//
-// Copyright 2015 Intel Mobile Communications GmbH 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <stdlib.h>
-#include <string.h>
-
-#include "ocstack.h"
-#include "ocpayload.h"
-#include "ocpayloadcbor.h"
-#include "oic_malloc.h"
-#include "utlist.h"
-#include "payload_logging.h"
-#include "resourcemanager.h"
-#include "psinterface.h"
-#include "svcresource.h"
-#include "srmresourcestrings.h"
-#include "srmutility.h"
-
-#include "security_internals.h"
-
-#define TAG  "OIC_SRM_SVC"
-
-/** Default cbor payload size. This value is increased in case of CborErrorOutOfMemory.
- * The value of payload size is increased until reaching belox max cbor size. */
-static const uint16_t CBOR_SIZE = 512;
-
-/** Max cbor size payload. */
-static const uint16_t CBOR_MAX_SIZE = 4400;
-
-/** SVC Map size - Number of mandatory items. */
-static const uint8_t SVC_MAP_SIZE = 3;
-
-static OicSecSvc_t        *gSvc = NULL;
-static OCResourceHandle    gSvcHandle = NULL;
-
-void DeleteSVCList(OicSecSvc_t* svc)
-{
-    if (svc)
-    {
-        OicSecSvc_t *svcTmp1 = NULL, *svcTmp2 = NULL;
-        LL_FOREACH_SAFE(svc, svcTmp1, svcTmp2)
-        {
-            LL_DELETE(svc, svcTmp1);
-
-            // Clean Owners
-            OICFree(svcTmp1->owners);
-
-            // Clean SVC node itself
-            OICFree(svcTmp1);
-        }
-    }
-}
-
-static size_t svcElementsCount(const OicSecSvc_t *secSvc)
-{
-    size_t size = 0;
-    for (const OicSecSvc_t *svc = secSvc; svc; svc = svc->next)
-    {
-        size++;
-    }
-    return size;
-}
-
-OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
-                               size_t *cborSize)
-{
-    if (NULL == svc || NULL == cborPayload || NULL != *cborPayload || NULL == cborSize)
-    {
-       return OC_STACK_INVALID_PARAM;
-    }
-
-    size_t cborLen = *cborSize;
-    if (0 == cborLen)
-    {
-        cborLen = CBOR_SIZE;
-    }
-    *cborPayload = NULL;
-    *cborSize = 0;
-
-    int64_t cborEncoderResult = CborNoError;
-    OCStackResult ret = OC_STACK_ERROR;
-    CborEncoder encoder;
-    CborEncoder svcArray;
-
-    uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
-    VERIFY_NOT_NULL_RETURN(TAG, outPayload, ERROR, OC_STACK_ERROR);
-
-    cbor_encoder_init(&encoder, outPayload, cborLen, 0);
-
-    // Create SVC Array
-    cborEncoderResult = cbor_encoder_create_array(&encoder, &svcArray, svcElementsCount(svc));
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Create SVC Array.");
-
-    while (svc)
-    {
-        CborEncoder svcMap;
-        CborEncoder owners;
-
-        cborEncoderResult = cbor_encoder_create_map(&svcArray, &svcMap, SVC_MAP_SIZE);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Create SVC Map.");
-
-        // Service Device Identity
-        cborEncoderResult = cbor_encode_text_string(&svcMap, OIC_JSON_SERVICE_DEVICE_ID,
-            strlen(OIC_JSON_SERVICE_DEVICE_ID));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Device Id.");
-        cborEncoderResult = cbor_encode_byte_string(&svcMap, (uint8_t *)svc->svcdid.id,
-            sizeof(svc->svcdid.id));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to ");
-
-        // Service Type
-        cborEncoderResult = cbor_encode_text_string(&svcMap, OIC_JSON_SERVICE_TYPE,
-            strlen(OIC_JSON_SERVICE_TYPE));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Serv Type Tag.");
-        cborEncoderResult = cbor_encode_int(&svcMap, svc->svct);
-        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.");
-        cborEncoderResult = cbor_encoder_create_array(&svcMap, &owners, svc->ownersLen);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Array.");
-        for (size_t i = 0; i < svc->ownersLen; i++)
-        {
-            cborEncoderResult = cbor_encode_byte_string(&owners, (uint8_t *)svc->owners[i].id,
-                sizeof(svc->owners[i].id));
-            VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Owners Value.");
-        }
-        cborEncoderResult = cbor_encoder_close_container(&svcMap, &owners);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Close SVC Array.");
-
-        cborEncoderResult = cbor_encoder_close_container(&svcArray, &svcMap);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Close SVC Map.");
-
-        svc = svc->next;
-    }
-
-    cborEncoderResult = cbor_encoder_close_container(&encoder, &svcArray);
-    VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Close SVC Array.");
-
-    if (CborNoError == cborEncoderResult)
-    {
-        *cborPayload = outPayload;
-        *cborSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
-        ret = OC_STACK_OK;
-    }
-
-exit:
-    if ((CborErrorOutOfMemory == cborEncoderResult) && (cborLen < CBOR_MAX_SIZE))
-    {
-        // reallocate and try again!
-        OICFree(outPayload);
-        outPayload = NULL;
-        // Since the allocated initial memory failed, double the memory.
-        cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
-        cborEncoderResult = CborNoError;
-        ret = SVCToCBORPayload(svc, cborPayload, &cborLen);
-        *cborSize = cborLen;
-    }
-
-    if (CborNoError != cborEncoderResult)
-    {
-        OICFree(outPayload);
-        outPayload = NULL;
-        *cborSize = 0;
-        *cborPayload = NULL;
-        ret = OC_STACK_ERROR;
-    }
-
-    return ret;
-}
-
-OCStackResult CBORPayloadToSVC(const uint8_t *cborPayload, size_t size,
-                               OicSecSvc_t **secSvc)
-{
-    if (NULL == cborPayload || NULL == secSvc || NULL != *secSvc || 0 == size)
-    {
-        return OC_STACK_INVALID_PARAM;
-    }
-
-    *secSvc = NULL;
-
-    OCStackResult ret = OC_STACK_ERROR;
-
-    CborValue svcCbor = { .parser = NULL };
-    CborParser parser = { .end = NULL };
-    CborError cborFindResult = CborNoError;
-
-    cbor_parser_init(cborPayload, size, 0, &parser, &svcCbor);
-    OicSecSvc_t *headSvc = NULL;
-
-    CborValue svcArray = { .parser = NULL };
-    cborFindResult = cbor_value_enter_container(&svcCbor, &svcArray);
-    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Enter SVC Array.");
-
-    while (cbor_value_is_valid(&svcArray))
-    {
-        CborValue svcMap = { .parser = NULL };
-        OicSecSvc_t *svc = (OicSecSvc_t *) OICCalloc(1, sizeof(OicSecSvc_t));
-        VERIFY_NOT_NULL(TAG, svc, ERROR);
-        cborFindResult = cbor_value_enter_container(&svcArray, &svcMap);
-        VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Enter SVC Map.");
-
-        while (cbor_value_is_valid(&svcMap))
-        {
-            char* name = NULL;
-            size_t len = 0;
-            CborType type = CborInvalidType;
-
-            cborFindResult = cbor_value_dup_text_string(&svcMap, &name, &len, NULL);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find Name.");
-            cborFindResult = cbor_value_advance(&svcMap);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Advance.");
-
-            type = cbor_value_get_type(&svcMap);
-            // Service Device Identity
-            if (0 == strcmp(OIC_JSON_SERVICE_DEVICE_ID, name) && cbor_value_is_byte_string(&svcMap))
-            {
-                uint8_t *subjectId = NULL;
-                cborFindResult = cbor_value_dup_byte_string(&svcMap, &subjectId, &len, NULL);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find SubjectId.");
-                memcpy(svc->svcdid.id, subjectId, len);
-                OICFree(subjectId);
-            }
-            // Service Type
-            if (0 == strcmp(OIC_JSON_SERVICE_TYPE, name) && cbor_value_is_integer(&svcMap))
-            {
-                int svct;
-
-                cborFindResult = cbor_value_get_int(&svcMap, &svct);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find SVCT.");
-                svc->svct = (OicSecSvcType_t)svct;
-            }
-
-            // Owners -- Mandatory
-            if (0 == strcmp(OIC_JSON_OWNERS_NAME, name) && cbor_value_is_array(&svcMap))
-            {
-                int i = 0;
-                CborValue owners = { .parser = NULL };
-
-                cborFindResult = cbor_value_get_array_length(&svcMap, &svc->ownersLen);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find Owner Len.");
-                cborFindResult = cbor_value_enter_container(&svcMap, &owners);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Enter Owner Array.");
-                svc->owners = (OicUuid_t *)OICCalloc(svc->ownersLen, sizeof(*svc->owners));
-                VERIFY_NOT_NULL(TAG, svc->owners, ERROR);
-
-                while (cbor_value_is_valid(&owners) && cbor_value_is_byte_string(&owners))
-                {
-                    uint8_t *owner = NULL;
-                    cborFindResult = cbor_value_dup_byte_string(&owners, &owner, &len, NULL);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find Owner Array Value.");
-                    cborFindResult = cbor_value_advance(&owners);
-                    VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Advance Owner Array.");
-                    memcpy(svc->owners[i++].id, owner, len);
-                    OICFree(owner);
-                }
-            }
-            if (CborMapType != type  && cbor_value_is_valid(&svcMap))
-            {
-                cborFindResult = cbor_value_advance(&svcMap);
-                VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Advance SVC.");
-            }
-            OICFree(name);
-        }
-
-        svc->next = NULL;
-        if (NULL == headSvc)
-        {
-            headSvc = svc;
-        }
-        else
-        {
-            OicSecSvc_t *temp = headSvc;
-            while (temp->next)
-            {
-                temp = temp->next;
-            }
-            temp->next = svc;
-        }
-        if (cbor_value_is_valid(&svcArray))
-        {
-            cborFindResult = cbor_value_advance(&svcArray);
-            VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to Find Name.");
-        }
-    }
-    *secSvc = headSvc;
-    ret = OC_STACK_OK;
-
-exit:
-    if (CborNoError != cborFindResult)
-    {
-        DeleteSVCList(headSvc);
-        headSvc = NULL;
-        *secSvc = NULL;
-        ret = OC_STACK_ERROR;
-    }
-    return ret;
-}
-
-static OCEntityHandlerResult HandleSVCGetRequest(const OCEntityHandlerRequest * ehRequest)
-{
-    // Convert SVC data into JSON for transmission
-    size_t size = 0;
-    uint8_t *cborSvc = NULL;
-    OCStackResult res =  SVCToCBORPayload(gSvc, &cborSvc, &size);
-    OCEntityHandlerResult ehRet = (res == OC_STACK_OK) ? OC_EH_OK : OC_EH_ERROR;
-
-    // Send response payload to request originator
-    ehRet = ((SendSRMResponse(ehRequest, ehRet, cborSvc, size)) == OC_STACK_OK) ?
-                   OC_EH_OK : OC_EH_ERROR;
-
-    OICFree(cborSvc);
-    OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
-    return ehRet;
-}
-
-static OCEntityHandlerResult HandleSVCPostRequest(const OCEntityHandlerRequest * ehRequest)
-{
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-    uint8_t *payload = ((OCSecurityPayload *) ehRequest->payload)->securityData;
-    size_t size = ((OCSecurityPayload *) ehRequest->payload)->payloadSize;
-    if (payload)
-    {
-        // Convert CBOR SVC data into SVC. This will also validate the SVC data received.
-        OicSecSvc_t *newSvc = NULL;
-        OCStackResult res =  CBORPayloadToSVC(payload, size, &newSvc);
-        if (newSvc && res == OC_STACK_OK)
-        {
-            // Append the new SVC to existing SVC
-            LL_APPEND(gSvc, newSvc);
-
-            // Convert SVC data into JSON for update to persistent storage
-            size_t cborSize = 0;
-            uint8_t *cborPayload = NULL;
-            res = SVCToCBORPayload(gSvc, &cborPayload, &cborSize);
-            if (cborPayload && OC_STACK_OK == res &&
-                UpdateSecureResourceInPS(OIC_JSON_SVC_NAME, cborPayload, cborSize) == OC_STACK_OK)
-            {
-                ehRet = OC_EH_CHANGED;
-            }
-            OICFree(cborPayload);
-        }
-    }
-
-    // Send payload to request originator
-    if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
-    {
-        ehRet = OC_EH_ERROR;
-        OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleSVCPostRequest");
-    }
-
-    OIC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet);
-    return ehRet;
-}
-
-/**
- * This internal method is the entity handler for SVC resources and
- * will handle REST request (GET/PUT/POST/DEL) for them.
- */
-static OCEntityHandlerResult SVCEntityHandler(OCEntityHandlerFlag flag,
-                                              OCEntityHandlerRequest * ehRequest,
-                                              void* callbackParameter)
-{
-    (void) callbackParameter;
-    OCEntityHandlerResult ehRet = OC_EH_ERROR;
-
-    if (!ehRequest)
-    {
-        return ehRet;
-    }
-
-    if (flag & OC_REQUEST_FLAG)
-    {
-        switch (ehRequest->method)
-        {
-            case OC_REST_GET:
-                ehRet = HandleSVCGetRequest(ehRequest);
-                break;
-
-            case OC_REST_POST:
-                ehRet = HandleSVCPostRequest(ehRequest);
-                break;
-
-            default:
-                if (OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL, 0))
-                {
-                    OIC_LOG(ERROR, TAG, "SendSRMResponse failed in HandleSVCPostRequest");
-                }
-                else
-                {
-                    ehRet = OC_EH_OK;
-                }
-        }
-    }
-
-    return ehRet;
-}
-
-/**
- * This internal method is used to create '/oic/sec/svc' resource.
- */
-static OCStackResult CreateSVCResource()
-{
-    OCStackResult ret = OCCreateResource(&gSvcHandle,
-                                         OIC_RSRC_TYPE_SEC_SVC,
-                                         OC_RSRVD_INTERFACE_DEFAULT,
-                                         OIC_RSRC_SVC_URI,
-                                         SVCEntityHandler,
-                                         NULL,
-                                         OC_OBSERVABLE);
-
-    if (OC_STACK_OK != ret)
-    {
-        OIC_LOG(FATAL, TAG, "Unable to instantiate SVC resource");
-        DeInitSVCResource();
-    }
-    return ret;
-}
-
-OCStackResult InitSVCResource()
-{
-    OCStackResult ret = OC_STACK_ERROR;
-
-    OIC_LOG_V(DEBUG, TAG, "Begin %s ", __func__ );
-
-    uint8_t *data = NULL;
-    size_t size = 0;
-    ret = GetSecureVirtualDatabaseFromPS(OIC_JSON_SVC_NAME, &data, &size);
-    // If database read failed
-    if (ret != OC_STACK_OK)
-    {
-        OIC_LOG (DEBUG, TAG, "ReadSVDataFromPS failed");
-    }
-
-    if (data)
-    {
-        // Convert CBOR SVC into binary format
-        ret = CBORPayloadToSVC(data, size, &gSvc);
-        if (ret != OC_STACK_OK)
-        {
-            OIC_LOG (DEBUG, TAG, " ConvertCBOR SVC into binary format failed");
-        }
-        OICFree(data);
-    }
-
-    // Instantiate 'oic.sec.svc'
-    ret = CreateSVCResource();
-
-    if (OC_STACK_OK != ret)
-    {
-        DeInitSVCResource();
-    }
-
-    OIC_LOG_V(DEBUG, TAG, "%s RetVal %d", __func__ , ret);
-    return ret;
-}
-
-void DeInitSVCResource()
-{
-    OCDeleteResource(gSvcHandle);
-    gSvcHandle = NULL;
-
-    DeleteSVCList(gSvc);
-    gSvc = NULL;
-}
index 45aed57..70ce730 100644 (file)
@@ -38,7 +38,6 @@
 #include "doxmresource.h"
 #include "amaclresource.h"
 #include "credresource.h"
-#include "svcresource.h"
 #include "security_internals.h"
 
 #define TAG  "OIC_JSON2CBOR"
@@ -50,7 +49,6 @@
 static OicSecPstat_t* JSONToPstatBin(const char * jsonStr);
 static OicSecDoxm_t* JSONToDoxmBin(const char * jsonStr);
 static OicSecAcl_t *JSONToAclBin(const char * jsonStr);
-static OicSecSvc_t* JSONToSvcBin(const char * jsonStr);
 static OicSecAmacl_t* JSONToAmaclBin(const char * jsonStr);
 static OicSecCred_t* JSONToCredBin(const char * jsonStr);
 
@@ -86,7 +84,6 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
     uint8_t *pstatCbor = NULL;
     uint8_t *doxmCbor = NULL;
     uint8_t *amaclCbor = NULL;
-    uint8_t *svcCbor = NULL;
     uint8_t *credCbor = NULL;
     cJSON *jsonRoot = NULL;
     OCStackResult ret = OC_STACK_ERROR;
@@ -184,22 +181,6 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
         printf("AMACL Cbor Size: %zd\n", amaclCborSize);
         DeleteAmaclList(amacl);
     }
-    value = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
-    size_t svcCborSize = 0;
-    if (NULL != value)
-    {
-        OicSecSvc_t *svc = JSONToSvcBin(jsonStr);
-        VERIFY_NOT_NULL(TAG, svc, FATAL);
-        ret = SVCToCBORPayload(svc, &svcCbor, &svcCborSize);
-        if(OC_STACK_OK != ret)
-        {
-            OIC_LOG (ERROR, TAG, "Failed converting Svc to Cbor Payload");
-            DeleteSVCList(svc);
-            goto exit;
-        }
-        printf("SVC Cbor Size: %zd\n", svcCborSize);
-        DeleteSVCList(svc);
-    }
     value = cJSON_GetObjectItem(jsonRoot, OIC_JSON_CRED_NAME);
     //printf("CRED json : \n%s\n", cJSON_PrintUnformatted(value));
     size_t credCborSize = 0;
@@ -220,7 +201,7 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
     }
 
     CborEncoder encoder;
-    size_t cborSize = aclCborSize + pstatCborSize + doxmCborSize + svcCborSize + credCborSize + amaclCborSize;
+    size_t cborSize = aclCborSize + pstatCborSize + doxmCborSize + credCborSize + amaclCborSize;
 
     printf("Total Cbor Size : %zd\n", cborSize);
     cborSize += 255; // buffer margin for adding map and byte string
@@ -259,13 +240,6 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
         cborEncoderResult = cbor_encode_byte_string(&map, amaclCbor, amaclCborSize);
         VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding AMACL Value.");
     }
-    if (svcCborSize > 0)
-    {
-        cborEncoderResult = cbor_encode_text_string(&map, OIC_JSON_SVC_NAME, strlen(OIC_JSON_SVC_NAME));
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SVC Name.");
-        cborEncoderResult = cbor_encode_byte_string(&map, svcCbor, svcCborSize);
-        VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding SVC Value.");
-    }
     if (credCborSize > 0)
     {
         cborEncoderResult = cbor_encode_text_string(&map, OIC_JSON_CRED_NAME, strlen(OIC_JSON_CRED_NAME));
@@ -302,7 +276,6 @@ exit:
     OICFree(doxmCbor);
     OICFree(pstatCbor);
     OICFree(amaclCbor);
-    OICFree(svcCbor);
     OICFree(credCbor);
     OICFree(jsonStr);
     return ;
@@ -755,12 +728,6 @@ OicSecPstat_t* JSONToPstatBin(const char * jsonStr)
     VERIFY_SUCCESS(TAG, (cJSON_True == jsonObj->type || cJSON_False == jsonObj->type) , ERROR);
     pstat->isOp = jsonObj->valueint;
 
-    jsonObj = cJSON_GetObjectItem(jsonPstat, OIC_JSON_DEVICE_ID_NAME);
-    VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
-    VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
-    ret = ConvertStrToUuid(jsonObj->valuestring, &pstat->deviceID);
-    VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
     jsonObj = cJSON_GetObjectItem(jsonPstat, OIC_JSON_ROWNERID_NAME);
     VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
     VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
@@ -1000,112 +967,6 @@ exit:
     return headCred;
 }
 
-static OicSecSvc_t* JSONToSvcBin(const char * jsonStr)
-{
-    OCStackResult ret = OC_STACK_ERROR;
-    OicSecSvc_t * headSvc = NULL;
-    OicSecSvc_t * prevSvc = NULL;
-    cJSON *jsonRoot = NULL;
-    cJSON *jsonSvcArray = NULL;
-
-    VERIFY_NOT_NULL(TAG, jsonStr, ERROR);
-
-    jsonRoot = cJSON_Parse(jsonStr);
-    VERIFY_NOT_NULL(TAG, jsonRoot, ERROR);
-
-    jsonSvcArray = cJSON_GetObjectItem(jsonRoot, OIC_JSON_SVC_NAME);
-    VERIFY_NOT_NULL(TAG, jsonSvcArray, INFO);
-
-    if (cJSON_Array == jsonSvcArray->type)
-    {
-        int numSvc = cJSON_GetArraySize(jsonSvcArray);
-        int idx = 0;
-
-        VERIFY_SUCCESS(TAG, numSvc > 0, INFO);
-        do
-        {
-            cJSON *jsonSvc = cJSON_GetArrayItem(jsonSvcArray, idx);
-            VERIFY_NOT_NULL(TAG, jsonSvc, ERROR);
-
-            OicSecSvc_t *svc = (OicSecSvc_t*)OICCalloc(1, sizeof(OicSecSvc_t));
-            VERIFY_NOT_NULL(TAG, svc, ERROR);
-
-            headSvc = (headSvc) ? headSvc : svc;
-            if (prevSvc)
-            {
-                prevSvc->next = svc;
-            }
-
-            cJSON *jsonObj = NULL;
-            unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {0};
-            size_t outLen = 0;
-            B64Result b64Ret = B64_OK;
-
-            // Service Device Identity
-            jsonObj = cJSON_GetObjectItem(jsonSvc, OIC_JSON_SERVICE_DEVICE_ID);
-            VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
-            VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
-            outLen = 0;
-            b64Ret = b64Decode(jsonObj->valuestring, strlen(jsonObj->valuestring), base64Buff,
-                       sizeof(base64Buff), &outLen);
-            VERIFY_SUCCESS(TAG, (b64Ret == B64_OK && outLen <= sizeof(svc->svcdid.id)), ERROR);
-            memcpy(svc->svcdid.id, base64Buff, outLen);
-
-            // Service Type
-            jsonObj = cJSON_GetObjectItem(jsonSvc, OIC_JSON_SERVICE_TYPE);
-            VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
-            VERIFY_SUCCESS(TAG, cJSON_Number == jsonObj->type, ERROR);
-            svc->svct = (OicSecSvcType_t)jsonObj->valueint;
-
-            // Resource Owners
-            jsonObj = cJSON_GetObjectItem(jsonSvc, OIC_JSON_OWNERS_NAME);
-            VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
-            VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
-
-            svc->ownersLen = cJSON_GetArraySize(jsonObj);
-            VERIFY_SUCCESS(TAG, svc->ownersLen > 0, ERROR);
-            svc->owners = (OicUuid_t*)OICCalloc(svc->ownersLen, sizeof(OicUuid_t));
-            VERIFY_NOT_NULL(TAG, (svc->owners), ERROR);
-
-            size_t idxx = 0;
-            do
-            {
-// Needs to be removed once IOT-1746 is resolved.
-#ifdef _MSC_VER
-#pragma warning(suppress : 4267)
-                cJSON *jsonOwnr = cJSON_GetArrayItem(jsonObj, idxx);
-
-#else
-                cJSON *jsonOwnr = cJSON_GetArrayItem(jsonObj, idxx);
-
-#endif
-                VERIFY_NOT_NULL(TAG, jsonOwnr, ERROR);
-                VERIFY_SUCCESS(TAG, cJSON_String == jsonOwnr->type, ERROR);
-                outLen = 0;
-                b64Ret = b64Decode(jsonOwnr->valuestring, strlen(jsonOwnr->valuestring), base64Buff,
-                           sizeof(base64Buff), &outLen);
-
-                VERIFY_SUCCESS(TAG, (b64Ret == B64_OK && outLen <= sizeof(svc->owners[idxx].id)),
-                                   ERROR);
-                memcpy(svc->owners[idxx].id, base64Buff, outLen);
-            } while ( ++idxx < svc->ownersLen);
-
-            prevSvc = svc;
-        } while( ++idx < numSvc);
-    }
-
-    ret = OC_STACK_OK;
-
-exit:
-    cJSON_Delete(jsonRoot);
-    if (OC_STACK_OK != ret)
-    {
-        DeleteSVCList(headSvc);
-        headSvc = NULL;
-    }
-    return headSvc;
-}
-
 static OicSecAmacl_t* JSONToAmaclBin(const char * jsonStr)
 {
     OCStackResult ret = OC_STACK_ERROR;
@@ -1158,44 +1019,11 @@ static OicSecAmacl_t* JSONToAmaclBin(const char * jsonStr)
 
     } while ( ++idxx < headAmacl->resourcesLen);
 
-    // Ams -- Mandatory
-    jsonObj = cJSON_GetObjectItem(jsonAmacl, OIC_JSON_AMS_NAME);
-    VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
-    VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
-
-    headAmacl->amssLen = cJSON_GetArraySize(jsonObj);
-    VERIFY_SUCCESS(TAG, headAmacl->amssLen > 0, ERROR);
-    headAmacl->amss = (OicUuid_t*)OICCalloc(headAmacl->amssLen, sizeof(OicUuid_t));
-    VERIFY_NOT_NULL(TAG, headAmacl->amss, ERROR);
-
-    idxx = 0;
-    do
-    {
-// Needs to be removed once IOT-1746 is resolved.
-#ifdef _MSC_VER
-#pragma warning(suppress : 4267)
-        cJSON *jsonAms = cJSON_GetArrayItem(jsonObj, idxx);
-
-#else
-        cJSON *jsonAms = cJSON_GetArrayItem(jsonObj, idxx);
-
-#endif
-        VERIFY_NOT_NULL(TAG, jsonAms, ERROR);
-        VERIFY_SUCCESS(TAG, cJSON_String == jsonAms->type, ERROR);
-
-        memcpy(headAmacl->amss[idxx].id, (OicUuid_t *)jsonAms->valuestring, strlen(jsonAms->valuestring));
-
-    } while ( ++idxx < headAmacl->amssLen);
-
-
     // Rowner -- Mandatory
     jsonObj = cJSON_GetObjectItem(jsonAmacl, OIC_JSON_ROWNERID_NAME);
     VERIFY_NOT_NULL(TAG, jsonObj, ERROR);
     VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
 
-    ret = ConvertStrToUuid(jsonObj->valuestring, &headAmacl->rownerID);
-    VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
-
     ret = OC_STACK_OK;
 
 exit:
index 0908ebd..4110243 100644 (file)
@@ -99,7 +99,6 @@ unittest = srmtest_env.Program('unittest', ['aclresourcetest.cpp',
                                             'iotvticalendartest.cpp',
                                             'base64tests.cpp',
                                             'pbkdf2tests.cpp',
-                                            'svcresourcetest.cpp',
                                             'srmtestcommon.cpp',
                                             'directpairingtest.cpp',
                                             'crlresourcetest.cpp'])
index 5a138ef..dbe82ff 100644 (file)
@@ -41,19 +41,6 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
 {
     OicSecAmacl_t *secAmacl = (OicSecAmacl_t *) OICCalloc(1, sizeof(*secAmacl));
     ASSERT_TRUE(NULL != secAmacl);
-    uint8_t amss[] = {0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
-        0x35, 0x35, 0x35, 0x35, 0x35, 0x35};
-    uint8_t amss1[] = {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-        0x36, 0x36, 0x36, 0x36, 0x36, 0x36};
-    secAmacl->amssLen = 2;
-    secAmacl->amss = (OicUuid_t *)OICCalloc(secAmacl->amssLen, sizeof(*secAmacl->amss));
-    if (!secAmacl->amss)
-    {
-        DeleteAmaclList(secAmacl);
-    }
-    ASSERT_TRUE(NULL != secAmacl->amss);
-    memcpy(secAmacl->amss[0].id, amss, sizeof(amss));
-    memcpy(secAmacl->amss[1].id, amss1, sizeof(amss1));
 
     const char *rsrc[] = { "/a/led", "/a/fan"};
     secAmacl->resourcesLen = 2;
@@ -69,9 +56,6 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
         secAmacl->resources[i] = OICStrdup(rsrc[i]);
         ASSERT_TRUE(NULL != secAmacl->resources[i]);
     }
-    uint8_t ownrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
-        0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
-    memcpy(secAmacl->rownerID.id, ownrs, sizeof(ownrs));
 
     OicSecAmacl_t *secAmacl1 = (OicSecAmacl_t *) OICCalloc(1, sizeof(*secAmacl1));
     if (!secAmacl1)
@@ -79,16 +63,6 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
         DeleteAmaclList(secAmacl);
     }
     ASSERT_TRUE(NULL != secAmacl1);
-    secAmacl1->amssLen = 2;
-    secAmacl1->amss = (OicUuid_t *)OICCalloc(2, sizeof(*secAmacl1->amss));
-    if (!secAmacl1->amss)
-    {
-        DeleteAmaclList(secAmacl);
-        DeleteAmaclList(secAmacl1);
-    }
-    ASSERT_TRUE(NULL != secAmacl1->amss);
-    memcpy(secAmacl1->amss[0].id, amss, sizeof(amss));
-    memcpy(secAmacl1->amss[1].id, amss1, sizeof(amss1));
 
     const char *rsrc1[] = { "/b/led", "/b/fan"};
     secAmacl1->resourcesLen = 2;
@@ -105,7 +79,6 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
         secAmacl1->resources[i] = OICStrdup(rsrc1[i]);
         ASSERT_TRUE(NULL != secAmacl1->resources[i]);
     }
-    memcpy(secAmacl1->rownerID.id, ownrs, sizeof(ownrs));
     secAmacl1->next = NULL;
     secAmacl->next = secAmacl1;
 
@@ -127,13 +100,9 @@ TEST(AMACLResourceTest, CBORAMACLConversion)
     }
     ASSERT_TRUE(NULL != amacl);
 
-    EXPECT_EQ(secAmacl->amssLen, amacl->amssLen);
-    EXPECT_EQ(sizeof(secAmacl->amss[0].id), sizeof(amacl->amss[0].id));
-    EXPECT_EQ(sizeof(secAmacl->amss[1].id), sizeof(amacl->amss[1].id));
     EXPECT_STREQ(secAmacl->resources[0], amacl->resources[0]);
     EXPECT_STREQ(secAmacl->resources[1], amacl->resources[1]);
     EXPECT_EQ(secAmacl->resourcesLen, amacl->resourcesLen);
-    EXPECT_EQ(memcmp(secAmacl->rownerID.id, amacl->rownerID.id, sizeof(amacl->rownerID.id)), 0);
 
     DeleteAmaclList(secAmacl);
     DeleteAmaclList(amacl);
index df46f27..17d4298 100644 (file)
@@ -63,10 +63,6 @@ TEST(PstatResourceTest, PstatEntityHandlerWithPostRequest)
     OicSecPstat_t *defaultPstat = (OicSecPstat_t *) OICCalloc(1, sizeof(*defaultPstat));
     ASSERT_TRUE(defaultPstat != NULL);
     defaultPstat->isOp = false;
-    uint8_t deviceId[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x69, 0x64, 0x00,
-                          0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x9f};
-    memcpy(defaultPstat->deviceID.id, deviceId, sizeof(deviceId));
-    EXPECT_EQ(sizeof(defaultPstat->deviceID.id), sizeof(deviceId));
     defaultPstat->commitHash = 1234;
     defaultPstat->cm = (OicSecDpm_t) 63;
     defaultPstat->tm = (OicSecDpm_t) 48;
@@ -123,9 +119,6 @@ TEST(PstatResourceTest, PstatToCBORPayloadAndCBORPayloadToPstat)
     OicSecPstat_t pstat;
     pstat.cm = NORMAL;
     pstat.commitHash = 0;
-    uint8_t deviceId[] = {0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x69, 0x64, 0x00,
-                          0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x9f};
-    memcpy(pstat.deviceID.id, deviceId, sizeof(deviceId));
     pstat.isOp = true;
     pstat.tm = NORMAL;
     pstat.om = SINGLE_SERVICE_CLIENT_DRIVEN;
diff --git a/resource/csdk/security/unittest/svcresourcetest.cpp b/resource/csdk/security/unittest/svcresourcetest.cpp
deleted file mode 100644 (file)
index 8d4553f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//******************************************************************
-//
-// Copyright 2015 Intel Mobile Communications GmbH 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "gtest/gtest.h"
-#include "ocstack.h"
-#include "oic_malloc.h"
-#include "cainterface.h"
-#include "secureresourcemanager.h"
-#include "securevirtualresourcetypes.h"
-#include "srmresourcestrings.h"
-#include "svcresource.h"
-#include "srmtestcommon.h"
-#include "security_internals.h"
-
-using namespace std;
-
-#define NUM_SVC_IN_CBOR_DB (2)
-
-TEST(SVCResourceTest, CBORConversionTests)
-{
-    OicSecSvc_t *svc1 = (OicSecSvc_t *) OICCalloc(1, sizeof(*svc1));
-    ASSERT_TRUE(NULL != svc1);
-    uint8_t svcdid[] = {0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
-                        0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35};
-    memcpy(svc1->svcdid.id, svcdid, sizeof(svcdid));
-    ASSERT_EQ(sizeof(svc1->svcdid.id), sizeof(svcdid));
-
-    svc1->svct = (OicSecSvcType_t) 1;
-    uint8_t owners[] = {0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
-                        0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39};
-    svc1->ownersLen = 1;
-    svc1->owners = (OicUuid_t *)OICCalloc(svc1->ownersLen, sizeof(*svc1->owners));
-    ASSERT_TRUE(NULL != svc1->owners);
-    memcpy(svc1->owners[0].id, owners, sizeof(owners));
-    ASSERT_EQ(sizeof(svc1->owners[0].id), sizeof(owners));
-
-    svc1->next = (OicSecSvc_t *) OICCalloc(1, sizeof(*svc1->next));
-    ASSERT_TRUE(svc1->next != NULL);
-    memcpy(svc1->next->svcdid.id, svcdid, sizeof(svcdid));
-    ASSERT_EQ(sizeof(svc1->next->svcdid.id), sizeof(svcdid));
-    svc1->next->svct = (OicSecSvcType_t) 1;
-    uint8_t owners1[] = {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-                        0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36};
-    svc1->next->ownersLen = 1;
-    svc1->next->owners = (OicUuid_t *)OICCalloc(svc1->next->ownersLen,
-                                                sizeof(*svc1->next->owners));
-    ASSERT_TRUE(NULL != svc1->next->owners);
-    memcpy(svc1->next->owners[0].id, owners1, sizeof(owners1));
-    svc1->next->next = NULL;
-
-    size_t size = 0;
-    uint8_t *psStorage = NULL;
-    EXPECT_EQ(OC_STACK_OK, SVCToCBORPayload(svc1, &psStorage, &size));
-    ASSERT_TRUE(NULL != psStorage);
-
-    OicSecSvc_t *svc = NULL;
-    EXPECT_EQ(OC_STACK_OK, CBORPayloadToSVC(psStorage, size, &svc));
-    ASSERT_TRUE(NULL != svc);
-
-    int cnt = 0;
-    OicSecSvc_t *tempSvc = svc;
-    while (tempSvc)
-    {
-        EXPECT_EQ(ACCESS_MGMT_SERVICE, tempSvc->svct);
-        cnt++;
-        tempSvc = tempSvc->next;
-    }
-    EXPECT_EQ(NUM_SVC_IN_CBOR_DB, cnt);
-
-    OICFree(psStorage);
-    DeleteSVCList(svc);
-    DeleteSVCList(svc1);
-}