1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 ******************************************************************/
21 #include "JniOcSecurity.h"
22 #include "JniOcStack.h"
25 * TODO: Persistant Storage Handling should be done by App.
26 * For 0.9.2 , Handling is done at JNI. As of now Plaform Config only
27 * SVR Database fileName(fullpath) is passed.
30 namespace PH = std::placeholders;
33 string& JniOcSecurity::store_path()
35 static string s_dbPath;
39 void JniOcSecurity::StoreDbPath(const string &path)
44 OCPersistentStorage* JniOcSecurity::getOCPersistentStorage()
46 if (store_path().empty())
50 static OCPersistentStorage s_ps { &JniOcSecurity::client_open, fread,
51 fwrite, fclose, unlink };
55 FILE* JniOcSecurity::client_open(const char *path, const char *mode)
57 LOGI("Opening SVR Database file '%s' with mode '%s'\n", store_path().c_str(), mode);
58 return fopen(store_path().c_str(), mode);