From: Kyungsun Cho Date: Wed, 11 Nov 2015 15:06:29 +0000 (+0900) Subject: [IOT-830] Added remove API for all credentials on |credresource| X-Git-Tag: 1.2.0+RC1~826 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=254ea95520dddfd4e39628293125b7c330529fa9;p=platform%2Fupstream%2Fiotivity.git [IOT-830] Added remove API for all credentials on |credresource| added all credentials remove API for iotivity client with provisioning feature. considering commercialization, iotivity client needs not only to reset SVR data, e.g. doxm, acl and cred resources, but also to remove only all credential data for its owned servers. for the former case legacy API(s) could be supported but for the latter case additional API is needed. the added API for this supports to remove all credentials and update persistent storage in running iotivity client. Jira-issue: https://jira.iotivity.org/browse/IOT-830 Change-Id: Icb41023f9acb6498c96e2b089a73daf4f39dd354 Signed-off-by: Kyungsun Cho Reviewed-on: https://gerrit.iotivity.org/gerrit/4147 Tested-by: jenkins-iotivity Reviewed-by: dongik Lee Reviewed-by: Sachin Agrawal --- diff --git a/resource/csdk/security/include/internal/credresource.h b/resource/csdk/security/include/internal/credresource.h index ae092df..74ea373 100644 --- a/resource/csdk/security/include/internal/credresource.h +++ b/resource/csdk/security/include/internal/credresource.h @@ -110,6 +110,15 @@ OCStackResult AddCredential(OicSecCred_t * cred); */ OCStackResult RemoveCredential(const OicUuid_t* credId); +/** + * Remove all credential data on credential resource and persistent storage + * + * @retval + * OC_STACK_OK - no errors + * OC_STACK_ERROR - stack process error + */ +OCStackResult RemoveAllCredentials(void); + #if defined(__WITH_DTLS__) /** * This internal callback is used by lower stack (i.e. CA layer) to diff --git a/resource/csdk/security/src/credresource.c b/resource/csdk/security/src/credresource.c index e7235b5..660164b 100644 --- a/resource/csdk/security/src/credresource.c +++ b/resource/csdk/security/src/credresource.c @@ -570,6 +570,14 @@ exit: return 0; } +/** + * Get the default value + * @retval NULL for now. Update it when we finalize the default info. + */ +static OicSecCred_t* GetCredDefault() +{ + return NULL; +} /** * This function adds the new cred to the credential list. @@ -631,6 +639,25 @@ OCStackResult RemoveCredential(const OicUuid_t *subject) } +/** + * Remove all credential data on credential resource and persistent storage + * + * @retval + * OC_STACK_OK - no errors + * OC_STACK_ERROR - stack process error + */ +OCStackResult RemoveAllCredentials(void) +{ + DeleteCredList(gCred); + gCred = GetCredDefault(); + + if(!UpdatePersistentStorage(gCred)) + { + return OC_STACK_ERROR; + } + return OC_STACK_OK; +} + static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * ehRequest) { OCEntityHandlerResult ret = OC_EH_ERROR; @@ -758,15 +785,6 @@ OCStackResult CreateCredResource() } /** - * Get the default value - * @retval NULL for now. Update it when we finalize the default info. - */ -static OicSecCred_t* GetCredDefault() -{ - return NULL; -} - -/** * Initialize Cred resource by loading data from persistent storage. * * @retval