Update /sp to latest CR text 51/26951/1
authorNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Fri, 3 Aug 2018 05:05:42 +0000 (22:05 -0700)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Tue, 11 Sep 2018 20:47:17 +0000 (13:47 -0700)
The Security WG approved a new version of the CR (v14) that
reflects several changes in the /sp Resource.  From a Server
perspective the main impact is that the Property names were
changed, and support for all 4 defined Profiles is required
for CTT validation.

Change-Id: Ibaf2c7d0b9daad7248b2f226da164a7a301dc526
Signed-off-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
resource/csdk/security/include/experimental/securevirtualresourcetypes.h
resource/csdk/security/include/internal/spresource.h
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.dat
resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.json
resource/csdk/security/src/spresource.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/tool/json2cbor.c
resource/csdk/security/unittest/spresource.cpp

index 3ed0da1..f612b09 100644 (file)
@@ -637,8 +637,8 @@ struct OicSecSp
 {
     size_t          supportedLen;       // the number of supported profiles
     char          **supportedProfiles;  // Array of supported security profiles
-    char           *activeProfile;      // active security profile
-    uint16_t        credid;             // Cred supporting asserted support of active_profile
+    char           *currentProfile;     // currently selected security profile
+    uint16_t        credid;             // Cred to accompany currentprofile
 };
 
 #if defined(__WITH_DTLS__) ||  defined(__WITH_TLS__)
index bed292a..2cc43c6 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 
 typedef enum {
     SP_SUPPORTED_PROFILES = 0,
-    SP_ACTIVE_PROFILE,
+    SP_CURRENT_PROFILE,
     SP_CRED_ID,
     SP_PROPERTY_COUNT
 } SpProperty_t;
index 11dc28d..5fadf22 100644 (file)
@@ -151,7 +151,7 @@ extern const char * OIC_JSON_TM_NAME;
 extern const char * OIC_JSON_OM_NAME;
 extern const char * OIC_JSON_SM_NAME;
 extern const char * OIC_JSON_SUPPORTED_SP_NAME;
-extern const char * OIC_JSON_ACTIVE_SP_NAME;
+extern const char * OIC_JSON_CURRENT_SP_NAME;
 extern const char * OIC_JSON_SP_CREDID_NAME;
 extern const char * OIC_JSON_SERVICE_DEVICE_ID;
 extern const char * OIC_JSON_SERVICE_TYPE;
index 4fda544..dd7134c 100644 (file)
Binary files a/resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.dat and b/resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.dat differ
index ce6aa65..cbe6d84 100644 (file)
@@ -1,7 +1,7 @@
 {
     "sp": {
-        "supported_profiles": [ "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple", "oic.sec.sp.baseline" ],
-        "active_profile": "oic.sec.sp.black",
+        "supportedprofiles": [ "oic.sec.sp.baseline", "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple" ],
+        "currentprofile": "oic.sec.sp.baseline",
         "credid": 1,
         "rowneruuid": "00000000-0000-0000-0000-000000000000",
         "rt": ["oic.r.ps"],
index 4d89426..b9623bf 100644 (file)
@@ -43,12 +43,16 @@ static OCResourceHandle    gSpHandle  = NULL;
 static OicSecSp_t         *gSp        = NULL;
 
 // Default sp values
-char * gSupportedProfiles[] = { "oic.sec.sp.baseline" };
+char * gSupportedProfiles[] = { "oic.sec.sp.baseline",
+                                "oic.sec.sp.black",
+                                "oic.sec.sp.blue",
+                                "oic.sec.sp.purple"
+                                };
 OicSecSp_t gDefaultSp =
 {
     1,                     // supportedLen
     gSupportedProfiles,    // supportedProfiles[0]
-    "oic.sec.sp.baseline", // activeProfile
+    "oic.sec.sp.baseline", // currentProfile
     0                      // credid
 };
 
@@ -69,7 +73,7 @@ OCStackResult SpToCBORPayload(const OicSecSp_t *sp, uint8_t **payload, size_t *s
     bool allProps[SP_PROPERTY_COUNT];
     SetAllSpProps(allProps, true);
 
-    if (false == SpRequiresCred(sp->activeProfile))
+    if (false == SpRequiresCred(sp->currentProfile))
     {
         allProps[SP_CRED_ID] = false;
     }
@@ -118,7 +122,7 @@ OCStackResult SpToCBORPayloadPartial(const OicSecSp_t *sp,
     cborEncoderResult = cbor_encoder_create_map(&encoder, &spMap, spMapSize);
     VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding sp Map.");
 
-    // supported_profiles
+    // supportedprofiles
     if (propertiesToInclude[SP_SUPPORTED_PROFILES])
     {
         VERIFY_OR_LOG_AND_EXIT(TAG, (0 < sp->supportedLen),
@@ -127,38 +131,38 @@ OCStackResult SpToCBORPayloadPartial(const OicSecSp_t *sp,
         cborEncoderResult = cbor_encode_text_string(
             &spMap, OIC_JSON_SUPPORTED_SP_NAME, strlen(OIC_JSON_SUPPORTED_SP_NAME));
         VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult,
-            "Failed Adding supported_profiles Name Tag.");
+            "Failed Adding supportedprofiles Name Tag.");
         OIC_LOG_V(DEBUG, TAG, "%s encoded sp %s tag.", __func__, OIC_JSON_SUPPORTED_SP_NAME);
 
         CborEncoder supportedProfiles;
         cborEncoderResult = cbor_encoder_create_array(&spMap, &supportedProfiles, sp->supportedLen);
         VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed creating supported_types Array.");
-        OIC_LOG_V(DEBUG, TAG, "%s created sp supported_profiles array.", __func__);
+        OIC_LOG_V(DEBUG, TAG, "%s created sp supportedprofiles array.", __func__);
         for(size_t i = 0; i < sp->supportedLen; i++)
         {
             char* curProfile = sp->supportedProfiles[i];
             cborEncoderResult = cbor_encode_text_string(&supportedProfiles, curProfile, strlen(curProfile));
-            VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding supported_profiles Value.");
-            OIC_LOG_V(DEBUG, TAG, "%s encoded sp supported_profile value %s.", __func__, curProfile);
+            VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding supportedprofiles Value.");
+            OIC_LOG_V(DEBUG, TAG, "%s encoded sp supportedprofiles value %s.", __func__, curProfile);
         }
 
         cborEncoderResult = cbor_encoder_close_container(&spMap, &supportedProfiles);
         VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing supportedProfiles.");
-        OIC_LOG_V(DEBUG, TAG, "%s closed sp supported_profiles map.", __func__);
+        OIC_LOG_V(DEBUG, TAG, "%s closed sp supportedprofiles map.", __func__);
     }
 
-    // active profile
-    if (propertiesToInclude[SP_ACTIVE_PROFILE])
+    // current profile
+    if (propertiesToInclude[SP_CURRENT_PROFILE])
     {
         cborEncoderResult = cbor_encode_text_string(
-            &spMap, OIC_JSON_ACTIVE_SP_NAME, strlen(OIC_JSON_ACTIVE_SP_NAME));
-        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding active_profile Name Tag.");
-        OIC_LOG_V(DEBUG, TAG, "%s encoded sp %s tag.", __func__, OIC_JSON_ACTIVE_SP_NAME);
+            &spMap, OIC_JSON_CURRENT_SP_NAME, strlen(OIC_JSON_CURRENT_SP_NAME));
+        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding currentprofile Name Tag.");
+        OIC_LOG_V(DEBUG, TAG, "%s encoded sp %s tag.", __func__, OIC_JSON_CURRENT_SP_NAME);
 
         cborEncoderResult = cbor_encode_text_string(
-            &spMap, sp->activeProfile, strlen(sp->activeProfile));
-        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding supported_profiles Value.");
-        OIC_LOG_V(DEBUG, TAG, "%s encoded sp active_profile value %s.", __func__, sp->activeProfile);
+            &spMap, sp->currentProfile, strlen(sp->currentProfile));
+        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding supportedprofiles Value.");
+        OIC_LOG_V(DEBUG, TAG, "%s encoded sp currentprofile value %s.", __func__, sp->currentProfile);
     }
 
     // cred id
@@ -248,9 +252,9 @@ exit:
 }
 
 /**
- * Static method to extract a supported_profiles array from spMap.
+ * Static method to extract a supportedprofiles array from spMap.
  *
- * @param [i] spMap             sp map positioned at supported_profiles array
+ * @param [i] spMap             sp map positioned at supportedprofiles array
  * @param [o] supportedProfiles allocated and extracted list of supported profile names
  * @param [o] supportedLen      length of the extracted supportedProfiles array
  *
@@ -271,14 +275,14 @@ static OCStackResult SupportedProfilesFromCBOR(CborValue *spMap,
 
     cborResult = cbor_value_get_array_length(spMap, supportedLen);
     VERIFY_OR_LOG_AND_EXIT(TAG, (CborNoError == cborResult) && (0 != supportedLen),
-        "Failed to find sp supported_profiles array length", ERROR);
+        "Failed to find sp supportedprofiles array length", ERROR);
 
     *supportedProfiles = (char**)OICCalloc(*supportedLen, sizeof(char*));
     VERIFY_NOT_NULL(TAG, *supportedProfiles, ERROR);
 
     CborValue supportedProfilesCbor;
     cborResult = cbor_value_enter_container(spMap, &supportedProfilesCbor);
-    VERIFY_CBOR_SUCCESS(TAG, cborResult, "Failed to enter SP supported_profiles array");
+    VERIFY_CBOR_SUCCESS(TAG, cborResult, "Failed to enter SP supportedprofiles array");
 
     size_t numProfilesExtracted = 0;
     for(size_t i = 0;
@@ -289,7 +293,7 @@ static OCStackResult SupportedProfilesFromCBOR(CborValue *spMap,
         cborResult = cbor_value_dup_text_string(
             &supportedProfilesCbor, &((*supportedProfiles)[i]), &readLen, NULL);
         VERIFY_CBOR_SUCCESS(TAG, cborResult,
-            "Failed to extract SP security profile name from supported_profiles.");
+            "Failed to extract SP security profile name from supportedprofiles.");
         numProfilesExtracted++;
 
         // advance to the next profile
@@ -299,7 +303,7 @@ static OCStackResult SupportedProfilesFromCBOR(CborValue *spMap,
 
     // Make sure we extracted the entire contents of the cbor array
     VERIFY_OR_LOG_AND_EXIT(TAG, (*supportedLen == numProfilesExtracted),
-        "Not all of the profiles from SP supported_profiles were extracted", ERROR);
+        "Not all of the profiles from SP supportedprofiles were extracted", ERROR);
 
     ret = OC_STACK_OK;
 
@@ -317,29 +321,29 @@ exit:
 }
 
 /**
- * Static method to extract the active_profile from a spMap, and determine the
+ * Static method to extract the currentprofile from a spMap, and determine the
  * corresponding index into the supportedProfiles array
  *
- * @param [i] spMap             sp map positioned at supported_profiles map
+ * @param [i] spMap             sp map positioned at supportedprofiles map
  * @param [i] supportedProfiles array of supported profile names
  * @param [i] supportedLen      length of supportedProfiles array
  *
- * @param [o] activeProfile     active profile
+ * @param [o] currentProfile     current profile
  *                              NULL on error
  *
  * @return ::OC_STACK_OK for Success, otherwise error value.
  */
-static OCStackResult ActiveProfileFromCBOR(CborValue *spMap, char **activeProfile)
+static OCStackResult CurrentProfileFromCBOR(CborValue *spMap, char **currentProfile)
 {
     OCStackResult ret = OC_STACK_ERROR;
     CborError cborResult = CborNoError;
-    *activeProfile = NULL;
+    *currentProfile = NULL;
 
     size_t readLen = 0;
 
-    // extract the active profile name
-    cborResult = cbor_value_dup_text_string(spMap, activeProfile, &readLen, NULL);
-    VERIFY_CBOR_SUCCESS(TAG, cborResult, "Failed to extract SP active profile name.");
+    // extract the current profile name
+    cborResult = cbor_value_dup_text_string(spMap, currentProfile, &readLen, NULL);
+    VERIFY_CBOR_SUCCESS(TAG, cborResult, "Failed to extract SP current profile name.");
 
     ret = OC_STACK_OK;
 
@@ -429,7 +433,7 @@ OCStackResult CBORPayloadToSp(const uint8_t *cborPayload,
 
         if(NULL != tagName)
         {
-            // supported_profiles
+            // supportedprofiles
             if (strcmp(tagName, OIC_JSON_SUPPORTED_SP_NAME) == 0)
             {
                 ret = SupportedProfilesFromCBOR(
@@ -442,15 +446,15 @@ OCStackResult CBORPayloadToSp(const uint8_t *cborPayload,
                 }
             }
 
-            // active profile
-            else if (strcmp(tagName, OIC_JSON_ACTIVE_SP_NAME) == 0)
+            // current profile
+            else if (strcmp(tagName, OIC_JSON_CURRENT_SP_NAME) == 0)
             {
-                ret = ActiveProfileFromCBOR(&spMap, &sp->activeProfile);
-                VERIFY_OR_LOG_AND_EXIT(TAG, (OC_STACK_OK == ret) && (NULL != sp->activeProfile),
-                    "Failed to extract SP active profile", ERROR);
+                ret = CurrentProfileFromCBOR(&spMap, &sp->currentProfile);
+                VERIFY_OR_LOG_AND_EXIT(TAG, (OC_STACK_OK == ret) && (NULL != sp->currentProfile),
+                    "Failed to extract SP current profile", ERROR);
                 if (NULL != decodedProperties)
                 {
-                    decodedProperties[SP_ACTIVE_PROFILE] = true;
+                    decodedProperties[SP_CURRENT_PROFILE] = true;
                 }
             }
 
@@ -520,11 +524,11 @@ void DeleteSpBinData(OicSecSp_t* sp)
         sp->supportedLen = 0;
         sp->supportedProfiles = NULL;
 
-        if (NULL != sp->activeProfile)
+        if (NULL != sp->currentProfile)
         {
-            OICFree(sp->activeProfile);
+            OICFree(sp->currentProfile);
         }
-        sp->activeProfile = NULL;
+        sp->currentProfile = NULL;
         sp->credid = 0;
     }
 }
@@ -551,23 +555,23 @@ bool RequiredSpPropsPresentAndValid(OicSecSp_t* sp, bool *propertiesPresent)
     bool requiredPropsPresentAndValid = false;
 
     VERIFY_OR_LOG_AND_EXIT(TAG, (true == propertiesPresent[SP_SUPPORTED_PROFILES]),
-        "Required SP property supported_profiles not present", WARNING);
+        "Required SP property supportedprofiles not present", WARNING);
 
     VERIFY_OR_LOG_AND_EXIT(TAG, ((NULL != sp->supportedProfiles) && (0 < sp->supportedLen)),
-        "Required SP property supported_profiles list is empty", WARNING);
+        "Required SP property supportedprofiles list is empty", WARNING);
 
-    VERIFY_OR_LOG_AND_EXIT(TAG, (true == propertiesPresent[SP_ACTIVE_PROFILE]),
-        "Required SP property active_profile not present", WARNING);
+    VERIFY_OR_LOG_AND_EXIT(TAG, (true == propertiesPresent[SP_CURRENT_PROFILE]),
+        "Required SP property currentprofile not present", WARNING);
 
-    VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != sp->activeProfile),
-        "Required SP property active_profile is invalid", WARNING);
+    VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != sp->currentProfile),
+        "Required SP property currentprofile is invalid", WARNING);
 
-    VERIFY_OR_LOG_AND_EXIT(TAG, (0 <= ProfileIdx(sp->supportedLen, sp->supportedProfiles, sp->activeProfile)),
-        "Active_profile is not contained in supported_profiles list", WARNING);
+    VERIFY_OR_LOG_AND_EXIT(TAG, (0 <= ProfileIdx(sp->supportedLen, sp->supportedProfiles, sp->currentProfile)),
+        "Currentprofile is not contained in supportedprofiles list", WARNING);
 
     VERIFY_OR_LOG_AND_EXIT(TAG,
-        !((true == SpRequiresCred(sp->activeProfile)) &&  (false == propertiesPresent[SP_CRED_ID])),
-        "Active profile requires credential, but none is present", WARNING);
+        !((true == SpRequiresCred(sp->currentProfile)) &&  (false == propertiesPresent[SP_CRED_ID])),
+        "Current profile requires credential, but none is present", WARNING);
 
     requiredPropsPresentAndValid = true;
 
@@ -686,10 +690,10 @@ static char** SpSupportedProfilesDup(size_t supportedLen, char** supportedProfil
     char** supportedProfilesDup = NULL;
 
     VERIFY_OR_LOG_AND_EXIT(TAG, (0 < supportedLen),
-        "sp supported profiles duplicate: invalid length for supported_profiles array", ERROR);
+        "sp supported profiles duplicate: invalid length for supportedprofiles array", ERROR);
 
     VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != supportedProfilesSrc),
-        "sp  supported profiles duplicate: supported_profiles array not present", ERROR);
+        "sp  supported profiles duplicate: supportedprofiles array not present", ERROR);
 
     // allocate and populate list of supported profiles
     supportedProfilesDup = (char**)OICCalloc(supportedLen, sizeof(char*));
@@ -735,8 +739,8 @@ static OicSecSp_t* SpDup(OicSecSp_t* spToDup)
 
     dupSp->supportedLen = spToDup->supportedLen;
     dupSp->credid = spToDup->credid;
-    dupSp->activeProfile = OICStrdup(spToDup->activeProfile);
-    VERIFY_NOT_NULL(TAG, dupSp->activeProfile, ERROR);
+    dupSp->currentProfile = OICStrdup(spToDup->currentProfile);
+    VERIFY_NOT_NULL(TAG, dupSp->currentProfile, ERROR);
 
     dupSp->supportedProfiles = SpSupportedProfilesDup(spToDup->supportedLen, spToDup->supportedProfiles);
     VERIFY_NOT_NULL(TAG, dupSp->supportedProfiles, ERROR);
@@ -792,10 +796,10 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
     OicSecSp_t *spUpdate = NULL;
 
     char** supportedProfilesSrc = NULL;
-    char* activeProfileSrc = NULL;
+    char* currentProfileSrc = NULL;
 
     bool newSupportedProfiles = false;
-    bool newActiveProfile = false;
+    bool newCurrentProfile = false;
     bool newCredid = false;
 
     uint8_t *payload = NULL;
@@ -814,7 +818,7 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
         "sp POST : error decoding incoming payload", ERROR);
 
     newSupportedProfiles = decodedProperties[SP_SUPPORTED_PROFILES];
-    newActiveProfile = decodedProperties[SP_ACTIVE_PROFILE];
+    newCurrentProfile = decodedProperties[SP_CURRENT_PROFILE];
     newCredid = decodedProperties[SP_CRED_ID];
 
     spUpdate = (OicSecSp_t *)OICCalloc(1, sizeof(OicSecSp_t));
@@ -825,20 +829,20 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
     supportedProfilesSrc = newSupportedProfiles ? spIncoming->supportedProfiles : gSp->supportedProfiles;
     spUpdate->supportedProfiles = SpSupportedProfilesDup(spUpdate->supportedLen, supportedProfilesSrc);
     VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != spUpdate),
-        "Problems duplicating active profiles list for sp POST", WARNING);
+        "Problems duplicating supported profiles list for sp POST", WARNING);
 
-    // active profile
-    activeProfileSrc = newActiveProfile ? spIncoming->activeProfile : gSp->activeProfile;
-    spUpdate->activeProfile = OICStrdup(activeProfileSrc);
-    VERIFY_NOT_NULL(TAG, spUpdate->activeProfile, ERROR);
+    // current profile
+    currentProfileSrc = newCurrentProfile ? spIncoming->currentProfile : gSp->currentProfile;
+    spUpdate->currentProfile = OICStrdup(currentProfileSrc);
+    VERIFY_NOT_NULL(TAG, spUpdate->currentProfile, ERROR);
 
-    // make sure active profile is in supported profiles list
+    // make sure current profile is in supported profiles list
     VERIFY_OR_LOG_AND_EXIT(TAG,
-        (0 <= ProfileIdx(spUpdate->supportedLen, spUpdate->supportedProfiles, spUpdate->activeProfile)),
-        "sp POST : active_profile is not contained in supported_profiles list", ERROR);
+        (0 <= ProfileIdx(spUpdate->supportedLen, spUpdate->supportedProfiles, spUpdate->currentProfile)),
+        "sp POST : currentprofile is not contained in supportedprofiles list", ERROR);
 
     // credid
-    if (true == SpRequiresCred(spUpdate->activeProfile))
+    if (true == SpRequiresCred(spUpdate->currentProfile))
     {
         spUpdate->credid = newCredid ? spIncoming->credid : gSp->credid;
     }
@@ -940,7 +944,7 @@ OCEntityHandlerResult SpEntityHandler(OCEntityHandlerFlag flag,
     return ehRet;
 }
 
-#define SP_RESOURCE_DISABLE
+//#define SP_RESOURCE_DISABLE
 OCStackResult CreateSpResource()
 {
     OCStackResult ret = OC_STACK_OK;
@@ -1064,10 +1068,10 @@ bool IsSpSame(OicSecSp_t* sp1, OicSecSp_t* sp2, bool *propertiesToCheck)
 
     }
 
-    if (true == propertiesToCheck[SP_ACTIVE_PROFILE] || (NULL == propertiesToCheck))
+    if (true == propertiesToCheck[SP_CURRENT_PROFILE] || (NULL == propertiesToCheck))
     {
-        if ((NULL == sp1->activeProfile) || (NULL == sp2->activeProfile) ||
-            (0 != strcmp(sp1->activeProfile, sp2->activeProfile)))
+        if ((NULL == sp1->currentProfile) || (NULL == sp2->currentProfile) ||
+            (0 != strcmp(sp1->currentProfile, sp2->currentProfile)))
         {
             return false;
         }
@@ -1113,8 +1117,8 @@ void LogSp(OicSecSp_t* sp, int level, const char* tag, const char* msg)
     {
         OIC_LOG_V(level, tag, "  %lu: %s", (unsigned long)i, sp->supportedProfiles[i]);
     }
-    OIC_LOG_V(level, tag, "Active security profile: %s", sp->activeProfile);
-    OIC_LOG_V(level, tag, "Active requires cred: %s", (true == SpRequiresCred(sp->activeProfile) ? "yes" : "no"));
+    OIC_LOG_V(level, tag, "Current security profile: %s", sp->currentProfile);
+    OIC_LOG_V(level, tag, "Current profile requires cred: %s", (true == SpRequiresCred(sp->currentProfile) ? "yes" : "no"));
     OIC_LOG_V(level, TAG, "credid: %hu", sp->credid);
     OIC_LOG(level, tag, "-------------------------------------------------");
 }
index 8ac49aa..20968f5 100644 (file)
@@ -127,8 +127,8 @@ const char * OIC_JSON_CM_NAME = "cm";
 const char * OIC_JSON_TM_NAME = "tm";
 const char * OIC_JSON_OM_NAME = "om";
 const char * OIC_JSON_SM_NAME = "sm";
-const char * OIC_JSON_SUPPORTED_SP_NAME = "supported_profiles";
-const char * OIC_JSON_ACTIVE_SP_NAME = "active_profile";
+const char * OIC_JSON_SUPPORTED_SP_NAME = "supportedprofiles";
+const char * OIC_JSON_CURRENT_SP_NAME = "currentprofile";
 const char * OIC_JSON_SP_CREDID_NAME = "credid";
 const char * OIC_JSON_CREDID_NAME = "credid";
 const char * OIC_JSON_SUBJECT_NAME = "subject";
index 4099071..2579755 100644 (file)
@@ -1189,7 +1189,7 @@ static OicSecSp_t *JSONToSpBin(const char *jsonStr)
 
     cJSON *jsonRoot = NULL;
     cJSON *jsonSp = NULL;
-    cJSON *jsonActiveProfileName = NULL;
+    cJSON *jsonCurrentProfileName = NULL;
     cJSON *jsonSupportedProfilesArray = NULL;
     cJSON *jsonProfileName = NULL;
     cJSON *jsonCredid = NULL;
@@ -1222,17 +1222,17 @@ static OicSecSp_t *JSONToSpBin(const char *jsonStr)
         VERIFY_NOT_NULL(TAG, (sp->supportedProfiles[i]), ERROR);
     }
 
-    // Active Profile
+    // Current Profile
 
-    jsonActiveProfileName = cJSON_GetObjectItem(jsonSp, OIC_JSON_ACTIVE_SP_NAME);
-    VERIFY_NOT_NULL(TAG, jsonActiveProfileName, ERROR);
-    VERIFY_SUCCESS(TAG, (cJSON_String == jsonActiveProfileName->type), ERROR);
-    sp->activeProfile = OICStrdup(jsonActiveProfileName->valuestring);
-    VERIFY_NOT_NULL(TAG, (sp->activeProfile), ERROR);
+    jsonCurrentProfileName = cJSON_GetObjectItem(jsonSp, OIC_JSON_CURRENT_SP_NAME);
+    VERIFY_NOT_NULL(TAG, jsonCurrentProfileName, ERROR);
+    VERIFY_SUCCESS(TAG, (cJSON_String == jsonCurrentProfileName->type), ERROR);
+    sp->currentProfile = OICStrdup(jsonCurrentProfileName->valuestring);
+    VERIFY_NOT_NULL(TAG, (sp->currentProfile), ERROR);
 
-    if (0 > ProfileIdx(sp->supportedLen, sp->supportedProfiles, sp->activeProfile))
+    if (0 > ProfileIdx(sp->supportedLen, sp->supportedProfiles, sp->currentProfile))
     {
-        OIC_LOG_V(ERROR, TAG, "sp active profile %s not contained in supported profile list", sp->activeProfile);
+        OIC_LOG_V(ERROR, TAG, "sp current profile %s not contained in supported profile list", sp->currentProfile);
         goto exit;
     }
 
@@ -1241,9 +1241,9 @@ static OicSecSp_t *JSONToSpBin(const char *jsonStr)
     jsonCredid = cJSON_GetObjectItem(jsonSp, OIC_JSON_SP_CREDID_NAME);
     if (NULL == jsonCredid)
     {
-        if (true == SpRequiresCred(sp->activeProfile))
+        if (true == SpRequiresCred(sp->currentProfile))
         {
-            OIC_LOG(ERROR, TAG, "sp active profile requires cred, but credid not present in json");
+            OIC_LOG(ERROR, TAG, "sp current profile requires cred, but credid not present in json");
             goto exit;
         }
         else
index c00a808..c5cb9f0 100644 (file)
@@ -50,7 +50,7 @@ static OicSecSp_t s_testSp =
 {
     0,                      // supportedLen
     s_profileArray,         // supportedProfiles[0]
-    NULL,                   // activeProfile
+    NULL,                   // currentProfile
     0                       // credid
 };
 
@@ -71,7 +71,7 @@ TEST(SPResourceTest, CBORFullEncodingPositive)
     s_testSp.supportedProfiles[1] = s_spBaselineName;
     s_testSp.supportedProfiles[2] = s_spBlackName;
     s_testSp.supportedProfiles[3] = s_spPurpleName;
-    s_testSp.activeProfile = s_spBlackName;
+    s_testSp.currentProfile = s_spBlackName;
     s_testSp.credid = 1;
     TestEncodeDecode(&s_testSp, propsToTest, true);
 
@@ -80,7 +80,7 @@ TEST(SPResourceTest, CBORFullEncodingPositive)
     SetAllSpProps(propsToTest, true);
     s_testSp.supportedLen = 1;
     s_testSp.supportedProfiles[0] = s_spBaselineName;
-    s_testSp.activeProfile = s_spBaselineName;
+    s_testSp.currentProfile = s_spBaselineName;
     TestEncodeDecode(&s_testSp, propsToTest, true);
 
     // one non baseline
@@ -89,7 +89,7 @@ TEST(SPResourceTest, CBORFullEncodingPositive)
     s_testSp.supportedLen = 2;
     s_testSp.supportedProfiles[0] = s_spBaselineName;
     s_testSp.supportedProfiles[1] = s_spBlackName;
-    s_testSp.activeProfile = s_spBlackName;
+    s_testSp.currentProfile = s_spBlackName;
     s_testSp.credid = 22;
     TestEncodeDecode(&s_testSp, propsToTest, true);
 }
@@ -105,10 +105,10 @@ TEST(SPResourceTest, CBORPartialEncodingPositive)
     s_testSp.supportedProfiles[0] = s_spBaselineName;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
-    // active profile only
+    // current profile only
     TestInit(&s_testSp, propsToTest);
-    propsToTest[SP_ACTIVE_PROFILE] = true;
-    s_testSp.activeProfile = s_spBlueName;
+    propsToTest[SP_CURRENT_PROFILE] = true;
+    s_testSp.currentProfile = s_spBlueName;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
     // cred profile only
@@ -117,14 +117,14 @@ TEST(SPResourceTest, CBORPartialEncodingPositive)
     s_testSp.credid = 11;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
-    // supported profiles and active profile
+    // supported profiles and current profile
     TestInit(&s_testSp, propsToTest);
     propsToTest[SP_SUPPORTED_PROFILES] = true;
-    propsToTest[SP_ACTIVE_PROFILE] = true;
+    propsToTest[SP_CURRENT_PROFILE] = true;
     s_testSp.supportedLen = 2;
     s_testSp.supportedProfiles[0] = s_spBaselineName;
     s_testSp.supportedProfiles[1] = s_spBlueName;
-    s_testSp.activeProfile = s_spBlueName;
+    s_testSp.currentProfile = s_spBlueName;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
     // supported profiles and credid
@@ -137,11 +137,11 @@ TEST(SPResourceTest, CBORPartialEncodingPositive)
     s_testSp.credid = 88;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
-    // active profiles and credid
+    // current profiles and credid
     TestInit(&s_testSp, propsToTest);
-    propsToTest[SP_ACTIVE_PROFILE] = true;
+    propsToTest[SP_CURRENT_PROFILE] = true;
     propsToTest[SP_CRED_ID] = true;
-    s_testSp.activeProfile = s_spBaselineName;
+    s_testSp.currentProfile = s_spBaselineName;
     s_testSp.credid = 22;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 }
@@ -196,7 +196,7 @@ exit:
 static void TestInit(OicSecSp_t* testSp, bool* spProps)
 {
     testSp->supportedLen = 0;
-    testSp->activeProfile = NULL;
+    testSp->currentProfile = NULL;
     testSp->credid = 0;
 
     for (size_t i = 0; i < sizeof(s_profileArray)/sizeof(s_profileArray[0]); i++)