Revert "Fix security manager socket path."
[platform/core/security/security-server.git] / src / server / service / installer.h
1 /*
2  *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Bartlomiej Grzelewski <b.grzelewski@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        installer.h
20  * @author      Michal Witanowski (m.witanowski@samsung.com)
21  * @brief       Implementation of installer service for libprivilege-control encapsulation.
22  */
23
24 #ifndef _SECURITY_SERVER_INSTALLER_
25 #define _SECURITY_SERVER_INSTALLER_
26
27 #include <service-thread.h>
28 #include <generic-socket-manager.h>
29 #include <message-buffer.h>
30 #include <connection-info.h>
31
32 namespace SecurityServer {
33
34 class InstallerException
35 {
36 public:
37     DECLARE_EXCEPTION_TYPE(SecurityServer::Exception, Base)
38     DECLARE_EXCEPTION_TYPE(Base, InvalidAction)
39 };
40
41 class InstallerService :
42     public SecurityServer::GenericSocketService,
43     public SecurityServer::ServiceThread<InstallerService>
44 {
45 public:
46     InstallerService();
47     ServiceDescriptionVector GetServiceDescription();
48
49     DECLARE_THREAD_EVENT(AcceptEvent, accept)
50     DECLARE_THREAD_EVENT(WriteEvent, write)
51     DECLARE_THREAD_EVENT(ReadEvent, process)
52     DECLARE_THREAD_EVENT(CloseEvent, close)
53
54     void accept(const AcceptEvent &event);
55     void write(const WriteEvent &event);
56     void process(const ReadEvent &event);
57     void close(const CloseEvent &event);
58
59 private:
60     ConnectionInfoMap m_connectionInfoMap;
61
62     /**
63      * Handle request from a client
64      *
65      * @param  conn        Socket connection information
66      * @param  buffer      Raw received data buffer
67      * @param  interfaceID identifier used to distinguish source socket
68      * @return             true on success
69      */
70     bool processOne(const ConnectionID &conn, MessageBuffer &buffer, InterfaceID interfaceID);
71
72     /**
73      * Process application installation
74      *
75      * @param  buffer Raw received data buffer
76      * @param  send   Raw data buffer to be sent
77      * @return        true on success
78      */
79     bool processAppInstall(MessageBuffer &buffer, MessageBuffer &send);
80
81     /**
82      * Process libprivilege-control action and store result in a bufer
83      *
84      * @param  buffer Raw received data buffer
85      * @param  send   Raw data buffer to be sent
86      * @return        true on success
87      */
88     bool processAppUninstall(MessageBuffer &buffer, MessageBuffer &send);
89 };
90
91 } // namespace SecurityServer
92
93 #endif // _SECURITY_SERVER_INSTALLER_