tizen 2.4 release
[framework/security/key-manager.git] / src / include / ckm / ckm-control.h
1 /*
2  *  Copyright (c) 2000 - 2013 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        ckm-manager.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Main header file for client library.
21  */
22 #pragma once
23
24 #include <string>
25 #include <memory>
26
27 #include <ckm/ckm-error.h>
28 #include <ckm/ckm-client-info.h>
29 #include <ckm/ckm-type.h>
30
31 // Central Key Manager namespace
32 namespace CKM {
33
34 class Control;
35 typedef std::shared_ptr<Control> ControlShPtr;
36
37 // used by login manager to unlock user data with global password
38 class KEY_MANAGER_API Control
39 {
40 public:
41     // decrypt user key with password
42     virtual int unlockUserKey(const ClientInfo &clientInfo, const Password &password) = 0;
43
44     // remove user key from memory
45     virtual int lockUserKey(const ClientInfo &clientInfo) = 0;
46
47     // remove user data from Store and erase key used for encryption
48     virtual int removeUserData(const ClientInfo &clientInfo) = 0;
49
50     // change password for user
51     virtual int changeUserPassword(const ClientInfo &clientInfo, const Password &oldPassword, const Password &newPassword) = 0;
52
53     // This is work around for security-server api - resetPassword that may be called without passing oldPassword.
54     // This api should not be supported on tizen 3.0
55     // User must be already logged in and his DKEK is already loaded into memory in plain text form.
56     // The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
57     virtual int resetUserPassword(const ClientInfo &clientInfo, const Password &newPassword) = 0;
58
59     // Required for tizen 2.3.
60     // It will remove all application data owned by application identified
61     // by smackLabel. This function will remove application data from unlocked
62     // database only. This function may be used during application uninstallation.
63     virtual int removeApplicationData(const std::string &zone, const Label &smackLabel) = 0;
64
65     virtual int updateCCMode() = 0;
66
67     virtual int setPermission(const ClientInfo &clientInfo,
68                               const Alias &alias,
69                               const Label &accessor,
70                               PermissionMask permissionMask) = 0;
71
72     virtual ~Control(){}
73
74     static ControlShPtr create();
75 };
76
77 } // namespace CKM
78