Added security-manager API
[platform/core/security/security-server.git] / src / include / security-manager.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  *      Security Manager library header
19  */
20 /*
21  * @file        security-manager.h
22  * @author      Pawel Polawski (p.polawski@samsung.com)
23  * @version     1.0
24  * @brief       This file contains header of security-manager API
25  */
26
27 #ifndef SECURITY_MANAGER_H_
28 #define SECURITY_MANAGER_H_
29
30 #include <sys/types.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*! \brief return code of API functions */
37 enum lib_retcode {
38     SECURITY_MANAGER_SUCCESS,
39     SECURITY_MANAGER_ERROR_UNKNOWN,
40     SECURITY_MANAGER_ERROR_INPUT_PARAM,
41     SECURITY_MANAGER_ERROR_MEMORY,
42     SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE
43 };
44
45 /*! \brief accesses types for application installation paths*/
46 enum app_install_path_type {
47     //accessible read-write only for applications with same package id
48     SECURITY_MANAGER_PATH_PRIVATE,
49     //read-write access for all applications
50     SECURITY_MANAGER_PATH_PUBLIC,
51     //read only access for all applications
52     SECURITY_MANAGER_PATH_PUBLIC_RO,
53     //this is only for range limit
54     SECURITY_MANAGER_ENUM_END
55 };
56
57 /*! \brief data structure responsible for handling informations
58  * required to install / uninstall application */
59 struct app_inst_req;
60 typedef struct app_inst_req app_inst_req;
61
62 /*
63  * This function is responsible for initialize app_inst_req data structure
64  * It uses dynamic allocation inside and user responsibility is to call
65  * app_inst_req_free() for freeing allocated resources
66  *
67  * \param[in] Address of pointer for handle app_inst_req structure
68  * \return API return code or error code
69  */
70 int security_manager_app_inst_req_new(app_inst_req **pp_req);
71
72 /*
73  * This function is used to free resources allocated by calling app_inst_req_new()
74  *  \param[in] Pointer handling allocated app_inst_req structure
75  */
76 void security_manager_app_inst_req_free(app_inst_req *p_req);
77
78 /*
79  * This function is used to set up application identifier in app_inst_req structure
80  *
81  * \param[in] Pointer handling app_inst_req structure
82  * \param[in] Application identifier
83  * \return API return code or error code
84  */
85 int security_manager_app_inst_req_set_app_id(app_inst_req *p_req, const char *app_id);
86
87 /*
88  * This function is used to set up package identifier in app_inst_req structure
89  *
90  * \param[in] Pointer handling app_inst_req structure
91  * \param[in] Package identifier
92  * \return API return code or error code
93  */
94 int security_manager_app_inst_req_set_pkg_id(app_inst_req *p_req, const char *pkg_id);
95
96 /*
97  * This function is used to add allowed user to app_inst_req structure,
98  * it can be called multiple times
99  *
100  * \param[in] Pointer handling app_inst_req structure
101  * \param[in] Privileged user identifier
102  * \return API return code or error code
103  */
104 int security_manager_app_inst_req_add_allowed_user(app_inst_req *p_req, const uid_t user_id);
105
106 /*
107  * This function is used to add privilege to app_inst_req structure,
108  * it can be called multiple times
109  *
110  * \param[in] Pointer handling app_inst_req structure
111  * \param[in] Application privilager
112  * \return API return code or error code
113  */
114 int security_manager_app_inst_req_add_privilege(app_inst_req *p_req, const char *privilege);
115
116 /*
117  * This function is used to add application path to app_inst_req structure,
118  * it can be called multiple times
119  *
120  * \param[in] Pointer handling app_inst_req structure
121  * \param[in] Application path
122  * \param[in] Application path type
123  * \return API return code or error code
124  */
125 int security_manager_app_inst_req_add_path(app_inst_req *p_req, const char *path, const int path_type);
126
127 /*
128  * This function is used to install application based on
129  * using filled up app_inst_req data structure
130  *
131  * \param[in] Pointer handling app_inst_req structure
132  * \return API return code or error code
133  */
134 int security_manager_app_install(const app_inst_req *p_req);
135
136 /*
137  * This function is used to uninstall application based on
138  * using filled up app_inst_req data structure
139  *
140  * \param[in] Pointer handling app_inst_req structure
141  * \return API return code or error code
142  */
143 int security_manager_app_uninstall(const app_inst_req *p_req);
144
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /* SECURITY_MANAGER_H_ */