Fix encryption request handling
[platform/core/security/key-manager.git] / src / manager / main / service-messages.h
1 /*
2  *  Copyright (c) 2000 - 2015 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       service-messages.h
18  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
19  * @version    1.0
20  */
21
22 #pragma once
23
24 #include <memory>
25 #include <string>
26
27 #include <credentials.h>
28 #include <ckm/ckm-type.h>
29 #include <protocols.h>
30 #include <ckm/ckm-error.h>
31 #include <communication-manager.h>
32 #include <generic-backend/gobj.h>
33
34 namespace CKM {
35
36 // inter-service communication message base class
37 struct MsgBase {
38         explicit MsgBase(unsigned id) : id(id) {}
39         virtual ~MsgBase() {}
40
41         unsigned id;
42 };
43
44 // key request
45 struct MsgKeyRequest : public MsgBase {
46         MsgKeyRequest(unsigned id, const Credentials &cred, const Name &name,
47                                   const ClientId &explicitOwner, const Password &password) :
48                 MsgBase(id),
49                 cred(cred),
50                 name(name),
51                 explicitOwner(explicitOwner),
52                 password(password)
53         {}
54
55         Credentials cred;
56         Name name;
57         ClientId explicitOwner;
58         Password password;
59 };
60
61 // key response
62 struct MsgKeyResponse : public MsgBase {
63         MsgKeyResponse(unsigned id, const Crypto::GObjShPtr &key,
64                                    int errorCode = CKM_API_SUCCESS) :
65                 MsgBase(id), key(key), error(errorCode) {}
66
67         Crypto::GObjShPtr key;
68         int error;
69 };
70
71 struct MsgRemoveAppData {
72         explicit MsgRemoveAppData(std::string pkgIdT) :
73                 pkgId(std::move(pkgIdT)) {}
74
75         std::string pkgId;
76 };
77
78 using CommMgr =
79         CommunicationManager<MsgKeyRequest, MsgKeyResponse, MsgRemoveAppData>;
80
81 } /* namespace CKM */