Convert ServiceImpl namespace to a class
[platform/core/security/security-manager.git] / src / server / service / include / service.h
1 /*
2  *  Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Rafal Krypa <r.krypa@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18 /*
19  * @file        service.h
20  * @author      Michal Witanowski <m.witanowski@samsung.com>
21  * @author      Rafal Krypa <r.krypa@samsung.com>
22  * @brief       Implementation of security-manager service
23  */
24
25 #ifndef _SECURITY_MANAGER_SERVICE_
26 #define _SECURITY_MANAGER_SERVICE_
27
28 #include "base-service.h"
29 #include "service_impl.h"
30
31 namespace SecurityManager {
32
33 class ServiceException
34 {
35 public:
36     DECLARE_EXCEPTION_TYPE(SecurityManager::Exception, Base)
37     DECLARE_EXCEPTION_TYPE(Base, InvalidAction)
38 };
39
40 class Service :
41     public SecurityManager::BaseService
42 {
43 public:
44     Service(const bool isSlave);
45     ServiceDescriptionVector GetServiceDescription();
46
47 private:
48     const bool m_isSlave;
49     ServiceImpl serviceImpl;
50
51     /**
52      * Handle request from a client
53      *
54      * @param  conn        Socket connection information
55      * @param  buffer      Raw received data buffer
56      * @param  interfaceID identifier used to distinguish source socket
57      * @return             true on success
58      */
59     bool processOne(const ConnectionID &conn, MessageBuffer &buffer, InterfaceID interfaceID);
60
61     /**
62      * Process application installation
63      *
64      * @param  buffer Raw received data buffer
65      * @param  send   Raw data buffer to be sent
66      * @param  uid    User's identifier for whom application will be installed
67      */
68     void processAppInstall(MessageBuffer &buffer, MessageBuffer &send, uid_t uid);
69
70     /**
71      * Process application uninstallation
72      *
73      * @param  buffer Raw received data buffer
74      * @param  send   Raw data buffer to be sent
75      * @param  uid    User's identifier for whom application will be uninstalled
76      */
77     void processAppUninstall(MessageBuffer &buffer, MessageBuffer &send, uid_t uid);
78
79     /**
80      * Process getting package id from app id
81      *
82      * @param  buffer Raw received data buffer
83      * @param  send   Raw data buffer to be sent
84      */
85     void processGetPkgId(MessageBuffer &buffer, MessageBuffer &send);
86
87     /**
88      * Process getting permitted group ids for app id
89      *
90      * @param  buffer Raw received data buffer
91      * @param  send   Raw data buffer to be sent
92      * @param  uid    User's identifier for whom application will be launched
93      * @param  pid    Process id in which application will be launched
94      */
95     void processGetAppGroups(MessageBuffer &buffer, MessageBuffer &send, uid_t uid, pid_t pid);
96
97     void processUserAdd(MessageBuffer &buffer, MessageBuffer &send, uid_t uid);
98
99     void processUserDelete(MessageBuffer &buffer, MessageBuffer &send, uid_t uid);
100
101     /**
102      * Process policy update request
103      *
104      * @param  buffer Raw received data buffer
105      * @param  send   Raw data buffer to be sent
106      * @param  uid    Identifier of the user who sent the request
107      * @param  pid    PID of the process which sent the request
108      * @param  smackLabel smack label of requesting app
109      */
110     void processPolicyUpdate(MessageBuffer &buffer, MessageBuffer &send, uid_t uid, pid_t pid, const std::string &smackLabel);
111
112     /**
113      * List all privileges for specific user, placed in Cynara's PRIVACY_MANAGER
114      * or ADMIN's bucket - choice based on forAdmin parameter
115      *
116      * @param  buffer Raw received data buffer
117      * @param  send   Raw data buffer to be sent
118      * @param  uid    Identifier of the user who sent the request
119      * @param  pid    PID of the process which sent the request
120      * @param  smackLabel smack label of requesting app
121      * @param  forAdmin determines internal type of request
122      */
123     void processGetConfiguredPolicy(MessageBuffer &buffer, MessageBuffer &send, uid_t uid, pid_t pid, const std::string &smackLabel, bool forAdmin);
124
125     /**
126      * Get whole policy for specific user. Whole policy is a list of all apps,
127      * and their permissions (based on what they've stated in their manifests).
128      * If uid is unprivileged, then only privileges for the caller uid will be
129      * listed. If uid is privileged, then apps for all the users will be listed.
130      *
131      * @param  buffer Raw received data buffer
132      * @param  send     Raw data buffer to be sent
133      * @param  uid      Identifier of the user who sent the request
134      * @param  pid      PID of the process which sent the request
135      * @param  smackLabel smack label of requesting app
136      */
137     void processGetPolicy(MessageBuffer &buffer, MessageBuffer &send, uid_t uid, pid_t pid, const std::string &smackLabel);
138
139     /**
140      * Process getting policies descriptions as strings from Cynara
141      *
142      * @param  recv   Raw received data buffer
143      * @param  send   Raw data buffer to be sent
144      */
145     void processPolicyGetDesc(MessageBuffer &send);
146
147     /**
148      * Process getting privileges mapping. This retrieves and sends to clinet vector of privileges
149      * which are mapped to given privileges between two given privilege versions.
150      *
151      * @oaran  send   Raw data buffer to be sent
152      */
153     void processPrivilegesMappings(MessageBuffer &recv, MessageBuffer &send);
154
155     /**
156      * Process getting groups bound with privileges
157      *
158      * @param  send   Raw data buffer to be sent
159      */
160     void processGroupsGet(MessageBuffer &send);
161 };
162
163 } // namespace SecurityManager
164
165 #endif // _SECURITY_MANAGER_SERVICE_