Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / resource / csdk / security / src / credresource.c
index e7235b5..660164b 100644 (file)
@@ -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