Add support for requestXXXAliasVector methods.
[platform/core/security/key-manager.git] / src / manager / service / ckm-logic.cpp
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        ckm-logic.cpp
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Sample service implementation.
21  */
22 #include <dpl/serialization.h>
23
24 #include <ckm/ckm-error.h>
25 #include <ckm/ckm-type.h>
26
27 #include <ckm-logic.h>
28 namespace CKM {
29
30 CKMLogic::CKMLogic(){}
31 CKMLogic::~CKMLogic(){}
32
33 RawBuffer CKMLogic::unlockUserKey(const std::string &user, const std::string &password) {
34     (void)user;
35     (void)password;
36
37     MessageBuffer response;
38     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
39     return response.Pop();
40 }
41
42 RawBuffer CKMLogic::lockUserKey(const std::string &user) {
43     (void)user;
44
45     MessageBuffer response;
46     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
47     return response.Pop();
48 }
49
50 RawBuffer CKMLogic::removeUserData(const std::string &user) {
51     (void)user;
52
53     MessageBuffer response;
54     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
55     return response.Pop();
56 }
57
58 RawBuffer CKMLogic::changeUserPassword(
59     const std::string &user,
60     const std::string &oldPassword,
61     const std::string &newPassword)
62 {
63     (void)user;
64     (void)oldPassword;
65     (void)newPassword;
66
67     MessageBuffer response;
68     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
69     return response.Pop();
70 }
71
72 RawBuffer CKMLogic::resetUserPassword(
73     const std::string &user,
74     const std::string &newPassword)
75 {
76     (void)user;
77     (void)newPassword;
78
79     MessageBuffer response;
80     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
81     return response.Pop();
82 }
83
84 RawBuffer CKMLogic::saveData(
85     Credentials &cred,
86     int commandId,
87     DBDataType dataType,
88     const Alias &alias,
89     const RawBuffer &key,
90     const PolicySerializable &policy)
91 {
92     (void)cred;
93     (void)alias;
94     (void)key;
95     (void)policy;
96
97     MessageBuffer response;
98     Serialization::Serialize(response, static_cast<int>(LogicCommand::SAVE));
99     Serialization::Serialize(response, commandId);
100     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
101     Serialization::Serialize(response, static_cast<int>(dataType));
102
103     return response.Pop();
104 }
105
106 RawBuffer CKMLogic::removeData(
107     Credentials &cred,
108     int commandId,
109     DBDataType dataType,
110     const Alias &alias)
111 {
112     (void)cred;
113     (void)alias;
114
115     MessageBuffer response;
116     Serialization::Serialize(response, static_cast<int>(LogicCommand::REMOVE));
117     Serialization::Serialize(response, commandId);
118     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
119     Serialization::Serialize(response, static_cast<int>(dataType));
120
121     return response.Pop();
122 }
123
124 RawBuffer CKMLogic::getData(
125     Credentials &cred,
126     int commandId,
127     DBDataType dataType,
128     const Alias &alias,
129     const std::string &password)
130 {
131     (void)cred;
132     (void)alias;
133     (void)password;
134
135     MessageBuffer response;
136     Serialization::Serialize(response, static_cast<int>(LogicCommand::GET));
137     Serialization::Serialize(response, commandId);
138     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
139     Serialization::Serialize(response, static_cast<int>(dataType));
140     Serialization::Serialize(response, RawBuffer());
141     return response.Pop();
142 }
143
144 RawBuffer CKMLogic::getDataList(
145     Credentials &cred,
146     int commandId,
147     DBDataType dataType)
148 {
149     (void)cred;
150
151     MessageBuffer response;
152     Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_LIST));
153     Serialization::Serialize(response, commandId);
154     Serialization::Serialize(response, static_cast<int>(KEY_MANAGER_API_SUCCESS));
155     Serialization::Serialize(response, static_cast<int>(dataType));
156     Serialization::Serialize(response, AliasVector());
157     return response.Pop();
158 }
159
160 } // namespace CKM
161