Commit 1f5dc564 authored by Steven Saunders's avatar Steven Saunders

chande from SP names to OIDS

Change-Id: Idbd71399d008e8a21819b400b1f664977ca5db0f
Signed-off-by: default avatarSteven Saunders <s.saunders-contractor@cablelabs.com>
parent f20e3801
{
"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"]
......
......@@ -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
......
......@@ -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)),
......
......@@ -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 =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment