chande from SP names to OIDS 49/27049/2
authorSteven Saunders <s.saunders-contractor@cablelabs.com>
Fri, 21 Sep 2018 21:55:44 +0000 (15:55 -0600)
committerSteven Saunders <s.saunders-contractor@cablelabs.com>
Tue, 2 Oct 2018 00:54:28 +0000 (18:54 -0600)
Change-Id: Idbd71399d008e8a21819b400b1f664977ca5db0f
Signed-off-by: Steven Saunders <s.saunders-contractor@cablelabs.com>
resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.json
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/src/spresource.c
resource/csdk/security/unittest/spresource.cpp

index a821fd8..041f750 100644 (file)
@@ -1,7 +1,7 @@
 {
     "sp": {
-        "supportedprofiles": [ "oic.sec.sp.baseline" ],
-        "currentprofile": "oic.sec.sp.baseline",
+        "supportedprofiles": [ "1.3.6.1.4.1.51414.0.1.0" ],
+        "currentprofile": "1.3.6.1.4.1.51414.0.1.0",
         "rowneruuid": "00000000-0000-0000-0000-000000000000",
         "rt": ["oic.r.ps"],
         "if": ["oic.if.baseline"]
index 12109be..41c3049 100644 (file)
@@ -155,22 +155,22 @@ static FILE* fopen_prvnMng(const char*, const char*);
 static int waitCallbackRet(void);
 static int selectTwoDiffNum(int*, int*, const int, const char*);
 
-char * gSupportedProfilesDefault[] = { "oic.sec.sp.baseline" };
+char * gSupportedProfilesDefault[] = { "1.3.6.1.4.1.51414.0.1.0" };
 OicSecSp_t gSpDefault =
 {
     1,                          // supportedLen
     gSupportedProfilesDefault,  // supportedProfiles[0]
-    "oic.sec.sp.baseline",      // activeProfile
+    "1.3.6.1.4.1.51414.0.1.0",      // activeProfile
 };
 
-char * gSupportedProfilesAll[] = { "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple", "oic.sec.sp.baseline",  };
+char * gSupportedProfilesAll[] = { "1.3.6.1.4.1.51414.0.2.0", "1.3.6.1.4.1.51414.0.3.0", "1.3.6.1.4.1.51414.0.4.0", "1.3.6.1.4.1.51414.0.1.0",  };
 OicSecSp_t gSpAll =
 {
     4,                      // supportedLen
     gSupportedProfilesAll,  // supportedProfiles[0]
-    "oic.sec.sp.black",     // activeProfile
+    "1.3.6.1.4.1.51414.0.2.0",     // activeProfile
 };
-char * gSupportedProfilesInvalid[] = { "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple", "oic.sec.sp.baseline",  };
+char * gSupportedProfilesInvalid[] = { "1.3.6.1.4.1.51414.0.2.0", "1.3.6.1.4.1.51414.0.3.0", "1.3.6.1.4.1.51414.0.4.0", "1.3.6.1.4.1.51414.0.1.0",  };
 OicSecSp_t gSpInvalid =
 {
     4,                         // supportedLen
index 3fafe0c..1d13cb5 100644 (file)
@@ -44,12 +44,12 @@ static OCResourceHandle    gSpHandle  = NULL;
 static OicSecSp_t         *gSp        = NULL;
 
 // Default sp values
-char * gSupportedProfiles[] = { "oic.sec.sp.baseline" };
+char * gSupportedProfiles[] = { "1.3.6.1.4.1.51414.0.1.0" };
 OicSecSp_t gDefaultSp =
 {
     1,                     // supportedLen
     gSupportedProfiles,    // supportedProfiles[0]
-    "oic.sec.sp.baseline", // currentProfile
+    "1.3.6.1.4.1.51414.0.1.0", // currentProfile
 };
 
 bool gAllProps[SP_PROPERTY_COUNT] = { true, true };
@@ -717,6 +717,9 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
     bool newSupportedProfiles = false;
     bool newCurrentProfile = false;
 
+    const char * dosNames[] = { "RESET", "RFOTM", "RFPRO", "RFNOP", "SRESET" };
+    (void) dosNames; // to avoid compiler warnings (some compilers don't recognize use in macros)
+
     uint8_t *payload = NULL;
     size_t size = 0;
     OicSecDostype_t dos;
@@ -724,7 +727,7 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
     VERIFY_OR_LOG_AND_EXIT(TAG, (OC_STACK_OK == ret),
         "Not able to get onboarding state (pstat.dos) for /sp POST request", ERROR);
 
-    OIC_LOG_V(DEBUG, TAG, "/sp POST request, pstat.dos state = %d", dos.state);
+    OIC_LOG_V(DEBUG, TAG, "/sp POST request, pstat.dos state = %s (%d)", dosNames[dos.state], dos.state);
     if ((DOS_RESET == dos.state) || (DOS_RFNOP == dos.state)) {
         OIC_LOG(ERROR, TAG, "/sp resource is read-only in RESET and RFNOP");
         ehRet = OC_EH_NOT_ACCEPTABLE;
@@ -756,11 +759,23 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
     VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != spUpdate),
         "Problems duplicating supported profiles list for sp POST", WARNING);
 
+    // log the impact of the post on supported profiles
+    OIC_LOG_V(DEBUG, TAG, "Supported security profiles to be applied as a result of update (%lu entries, %s by POST)",
+             (unsigned long)spUpdate->supportedLen, newSupportedProfiles ? "changed" : "unchanged");
+    for (size_t i = 0; i < spUpdate->supportedLen; i++)
+    {
+        OIC_LOG_V(DEBUG, TAG, "  %lu: %s", (unsigned long)i, spUpdate->supportedProfiles[i]);
+    }
+
     // current profile
     currentProfileSrc = newCurrentProfile ? spIncoming->currentProfile : gSp->currentProfile;
     spUpdate->currentProfile = OICStrdup(currentProfileSrc);
     VERIFY_NOT_NULL(TAG, spUpdate->currentProfile, ERROR);
 
+    // log the impact of the post on current profile
+    OIC_LOG_V(DEBUG, TAG, "Active profile to be applied as a result of update (%s by POST): %s",
+              newCurrentProfile ? "changed" : "unchanged", spUpdate->currentProfile);
+
     // make sure current profile is in supported profiles list
     VERIFY_OR_LOG_AND_EXIT(TAG,
         (0 <= ProfileIdx(spUpdate->supportedLen, spUpdate->supportedProfiles, spUpdate->currentProfile)),
index 93eb9eb..7deca0f 100644 (file)
@@ -40,10 +40,10 @@ static void TestInit(OicSecSp_t* testSp, bool* spProps);
 // Test data
 //*****************************************************************************
 
-static char s_spBlackName[] = "oic.sec.sp.black";
-static char s_spBlueName[] = "oic.sec.sp.blue";
-static char s_spPurpleName[] = "oic.sec.sp.purple";
-static char s_spBaselineName[] = "oic.sec.sp.baseline";
+static char s_spBlackName[] = "1.3.6.1.4.1.51414.0.2.0";
+static char s_spBlueName[] = "1.3.6.1.4.1.51414.0.3.0";
+static char s_spPurpleName[] = "1.3.6.1.4.1.51414.0.4.0";
+static char s_spBaselineName[] = "1.3.6.1.4.1.51414.0.1.0";
 
 static char* s_profileArray[] = { NULL, NULL, NULL, NULL, NULL, };
 static OicSecSp_t s_testSp =