Merge "Migrate to openssl3" into tizen
[platform/core/security/ode.git] / lib / key-client.cpp
1 /*
2  *  Copyright (c) 2017 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 #include "key-client.h"
17 #include "rmi/common.h"
18
19 namespace ode {
20
21 KeyClient::KeyClient(RmiClientPtr& ctx) :
22         context(ctx)
23 {
24 }
25
26 KeyClient::~KeyClient()
27 {
28 }
29
30 int KeyClient::isInitialized(const std::string& device)
31 {
32         try {
33                 return context->methodCall<int>("KeyServer::isInitialized", device);
34         } catch (runtime::Exception& e) {
35                 return error::Unknown;
36         }
37 }
38
39 int KeyClient::init(const std::string& device,
40                                         const std::string& password,
41                                         int params)
42 {
43         try {
44                 return context->methodCall<int>("KeyServer::init",
45                                                                                 device,
46                                                                                 password,
47                                                                                 params);
48         } catch (runtime::Exception& e) {
49                 return error::Unknown;
50         }
51 }
52
53 int KeyClient::remove(const std::string& device, const std::string& password)
54 {
55         try {
56                 return context->methodCall<int>("KeyServer::remove", device, password);
57         } catch (runtime::Exception& e) {
58                 return error::Unknown;
59         }
60 }
61
62 int KeyClient::changePassword(const std::string& device,
63                                                           const std::string& curPassword,
64                                                           const std::string& newPassword)
65 {
66         try {
67                 return context->methodCall<int>("KeyServer::changePassword",
68                                                                                 device,
69                                                                                 curPassword,
70                                                                                 newPassword);
71         } catch (runtime::Exception& e) {
72                 return error::Unknown;
73         }
74 }
75
76 int KeyClient::verifyPassword(const std::string& device,
77                                                           const std::string& password)
78 {
79         try {
80                 return context->methodCall<int>("KeyServer::verifyPassword",
81                                                                                 device,
82                                                                                 password);
83         } catch (runtime::Exception& e) {
84                 return error::Unknown;
85         }
86 }
87
88 int KeyClient::storeMasterKey(const std::string& device,
89                                                           const std::string& password)
90 {
91         try {
92                 return context->methodCall<int>("KeyServer::storeMasterKey",
93                                                                                 device,
94                                                                                 password);
95         } catch (runtime::Exception& e) {
96                 return error::Unknown;
97         }
98 }
99
100 int KeyClient::removeMasterKey(const std::string& device)
101 {
102         try {
103                 return context->methodCall<int>("KeyServer::removeMasterKey",
104                                                                                 device);
105         } catch (runtime::Exception& e) {
106                 return error::Unknown;
107         }
108 }
109
110 } // namespace ode