Modification about smack label of db file belong to process.
[platform/framework/web/wrt-security.git] / ace_install / include / ace_api_install.h
1 /*
2  * Copyright (c) 2011 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        ace_api_setup.h
18  * @author      Tomasz Swierczek (t.swierczek@samsung.com)
19  * @version     1.0
20  * @brief       This is C api for Access Control Engine (ACE), installer mode
21  *              (RW part).
22  *
23  */
24
25 #ifndef ACE_API_H
26 #define ACE_API_H
27
28 #include <ace_api_common.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*
35  * API defined in this header should be used only from one thread. If used
36  * otherwise, unexpected behaviour may occur, including segmentation faults and
37  * escalation of global warming. Be warned.
38  */
39
40 // --------------- Initialization and policy update ----------------------------
41
42 /*
43  * Initializes ACE - connects (RW) to the database. Must be called only once.
44  * Returns ACE_OK or error
45  */
46 ace_return_t ace_install_initialize(void);
47
48 /*
49  * Deinitializes ACE - deinitialize internal structures, detach DB, etc.
50  * Must be called only once.
51  * Returns ACE_OK or error
52  */
53 ace_return_t ace_install_shutdown(void);
54
55 /*
56  * Updates policy - parses XML files from known locations (reason for no arguments),
57  * also clears policy and prompt caches.
58  * Returns ACE_OK or error
59  */
60 ace_return_t ace_update_policy(void);
61
62 // --------------- Requested device capabilities API for installer -------------
63
64 typedef struct
65 {
66     ace_string_t   device_capability;
67     ace_bool_t     smack_granted;
68 } ace_requested_dev_cap_t;
69
70 typedef struct
71 {
72     ace_size_t              count;
73     ace_requested_dev_cap_t*  items;
74 } ace_requested_dev_cap_list_t;
75
76 /*
77  * Deletes data allocated by ace_get_requested_dev_caps - a helper function
78  */
79 ace_return_t ace_free_requested_dev_caps(ace_requested_dev_cap_list_t* caps);
80
81 /*
82  * Returns ACE_OK or error; 'caps' will hold device capabilities information.
83  * To free allcated resources in 'caps', use ace_free_requested_dev_caps
84  */
85 ace_return_t ace_get_requested_dev_caps(ace_widget_handle_t handle,
86                                         ace_requested_dev_cap_list_t* caps);
87
88 /*
89  * Returns error or ACE_OK
90  */
91 ace_return_t ace_set_requested_dev_caps(ace_widget_handle_t handle,
92                                         const ace_requested_dev_cap_list_t* caps);
93
94 ace_return_t ace_rem_requested_dev_caps(ace_widget_handle_t handle);
95
96 // ---------------- Accepted Api featuresk API for installer ----------------
97
98
99 ace_return_t ace_set_accepted_feature(ace_widget_handle_t handle,
100                                       const ace_feature_list_t* flist);
101
102 ace_return_t ace_rem_accepted_feature(ace_widget_handle_t handle);
103
104 // --------------- Widget data setup for installation --------------------------
105
106 typedef enum
107 {
108     WAC20 = 0,
109     Tizen
110 } ace_widget_type_t;
111
112 struct widget_info {
113     ace_widget_type_t type;
114     ace_string_t id;
115     ace_string_t version;
116     ace_string_t author;
117     ace_string_t shareHerf;
118 };
119
120 typedef enum
121 {
122     AUTHOR,
123     DISTRIBUTOR,
124     UNKNOWN
125 } ace_cert_owner_t;
126
127 typedef enum
128 {
129     ROOT,
130     ENDENTITY
131 } ace_cert_type_t;
132
133 typedef struct certificate_data {
134     ace_cert_owner_t owner;
135     ace_cert_type_t type;
136     int chain_id;
137     ace_string_t md5_fp;
138     ace_string_t sha1_fp;
139     ace_string_t common_name;
140 } ace_certificate_data;
141
142 /*
143  * Register widget info into database.
144  * @param cert_data NULL terminated list of widget certificates
145  */
146
147 ace_return_t ace_register_widget(ace_widget_handle_t handle,
148                                  struct widget_info* info,
149                                  ace_certificate_data* cert_data[]);
150
151 ace_return_t ace_unregister_widget(ace_widget_handle_t handle);
152
153 ace_return_t ace_is_widget_installed(ace_widget_handle_t handle, bool *installed);
154
155 /*
156  * Gets widget type in 'type'. Use in installer to determine which policy will be used
157  * by ACE for this widget.
158  * Returns error or ACE_OK
159  */
160 ace_return_t ace_get_widget_type(ace_widget_handle_t handle,
161                                  ace_widget_type_t* type);
162
163 // --------------- Installation time policy check ------------------------------
164
165 typedef enum
166 {
167     ACE_PERMIT,
168     ACE_DENY,
169     ACE_PROMPT,
170     ACE_UNDEFINED
171 } ace_policy_result_t;
172
173 /*
174  * Gets current policy evaluation for given device capability and given widget.
175  * Returns error or ACE_OK
176  */
177 ace_return_t ace_get_policy_result(const ace_resource_t,
178                                    ace_widget_handle_t handle,
179                                    ace_policy_result_t* result);
180
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif // ACE_API_H