53561d607383113e2aca08c63110092fb0a40349
[platform/core/security/key-manager.git] / src / manager / service / file-system.h
1 /*
2  *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  *
16  *
17  * @file        FileSystem.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Sample service implementation.
21  */
22 #pragma once
23
24 #include <ckm/ckm-type.h>
25 #include <string>
26
27 namespace CKM {
28
29 typedef std::vector<std::string> AppLabelVector;
30 typedef std::vector<uid_t> UidVector;
31
32 class FileSystem {
33 public:
34     FileSystem(uid_t uid);
35
36     std::string getDBPath() const;
37
38     // Domain Key Encryption Key
39     RawBuffer getDKEK() const;
40     bool saveDKEK(const RawBuffer &buffer) const;
41
42     // Database Data Encryption Key
43     RawBuffer getDBDEK() const;
44     bool saveDBDEK(const RawBuffer &buffer) const;
45
46     // Remove all ckm data related to user
47     int removeUserData() const;
48
49     bool addRemovedApp(const std::string &smackLabel) const;
50     AppLabelVector clearRemovedsApps() const;
51
52     static int init();
53     static UidVector getUIDsFromDBFile();
54
55     virtual ~FileSystem(){}
56 protected:
57     std::string getDKEKPath() const;
58     std::string getDBDEKPath() const;
59     RawBuffer loadFile(const std::string &path) const;
60     bool saveFile(const std::string &path, const RawBuffer &buffer) const;
61     std::string getRemovedAppsPath() const;
62
63     uid_t m_uid;
64 };
65
66 }
67