438bd61903ace93b9070839c5b2da0dd442d286c
[platform/framework/native/appfw.git] / src / security / inc / FSec_AccessController.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FSec_AccessController.h
20  * @brief       This is the header file for the _AccessController.
21  * This header file contains the declarations of the _AccessController.
22  */
23
24 #ifndef _FSEC_INTERNAL_ACCESS_CONTROLLER_H_
25 #define _FSEC_INTERNAL_ACCESS_CONTROLLER_H_
26
27 #include <FOspConfig.h>
28
29 #include "FSec_AccessControlTypes.h"
30
31 namespace Tizen { namespace Security
32 {
33
34 class _PrivilegeManager;
35
36 /**
37  * @class       _AccessController
38  * @brief       This class provides a way to check the privilege and visibility.
39  * @since       2.0
40  *
41  * This class provides a way to check the privilege and visibility.
42  */
43 class _OSP_EXPORT_ _AccessController
44 {
45
46 public:
47         /**
48          * Checks whether the application has a privilege and a visibility to invoke the API.
49          *
50          * @since               2.0
51          * @return              An error code
52          * @param[in]   packageId                               The package ID.
53          * @param[in]   privilege                               A value of enumerator of the specified privilege.
54          * @exception   E_SUCCESS                               The method is successful and request is granted.
55          * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
56          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
57          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
58          * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
59          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
60          */
61         static result CheckSystemPrivilege(const Tizen::App::PackageId& packageId, _Privilege privilege);
62
63         /**
64          * Checks whether the application has either a privilege1 or a privilege2 and a visibility to invoke the API.
65          *
66          * @since               2.1
67          * @return              An error code
68          * @param[in]   packageId                               The package ID.
69          * @param[in]   privilege1                              A value of enumerator of the specified privilege.
70          * @param[in]   privilege2                              A value of enumerator of the specified privilege.
71          * @exception   E_SUCCESS                               The method is successful and request is granted.
72          * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
73          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
74          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
75          * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
76          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
77          */
78         static result CheckSystemPrivilege(const Tizen::App::PackageId& packageId, _Privilege privilege1, _Privilege privilege2);
79
80         /**
81          * Checks whether the application has a privilege to invoke the API.
82          *
83          * @since               2.1
84          * @return              An error code
85          * @param[in]   packageId                               The package ID.
86          * @param[in]   privilege                               A string of the specified privilege.
87          * @exception   E_SUCCESS                               The method is successful and request is granted.
88          * @exception   E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
89          * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
90          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
91          * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
92          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
93          */
94          static result CheckPrivilege(const Tizen::App::PackageId& packageId, const Tizen::Base::String& privilege);
95
96
97         /**
98          * Checks whether the application has a privilege and a visibility to invoke the API.
99          *
100          * @since               2.0
101          * @return              An error code
102          * @param[in]   privilege                               A value of enumerator of the specified privilege.
103          * @exception   E_SUCCESS                               The method is successful and request is granted.
104          * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
105          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
106          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
107          * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
108          * @exception   E_SYSTEM                                An unexpected system error occurred.
109          */
110         static result CheckUserPrivilege(_Privilege privilege);
111
112         /**
113          * Checks whether the application has either a privilege1 or a privilege2 and a visibility to invoke the API.
114          *
115          * @since               2.1
116          * @return              An error code
117          * @param[in]   privilege1                              A value of enumerator of the specified privilege.
118          * @param[in]   privilege2                              A value of enumerator of the specified privilege.
119          * @exception   E_SUCCESS                               The method is successful and request is granted.
120          * @exception   E_DATA_NOT_FOUND                The privilege information does not exist.
121          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
122          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege.
123          * @exception   E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
124          * @exception   E_SYSTEM                                An unexpected system error occurred.
125          */
126         static result CheckUserPrivilege(_Privilege privilege1, _Privilege privilege2);
127
128     /**
129      * Checks whether the application has a privilege to invoke the API.
130      *
131      * @since           2.1
132      * @return          An error code
133      * @param[in]       privilege                               A string of the specified privilege.
134      * @exception       E_SUCCESS                               The method is successful and request is granted.
135      * @exception       E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
136      * @exception       E_DATA_NOT_FOUND                The privilege information does not exist.
137      * @exception       E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
138      * @exception       E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
139      * @exception       E_SYSTEM                                The method cannot proceed due to a severe system error.
140      */
141     static result CheckPrivilege(const Tizen::Base::String& privilege);
142
143
144 private:
145
146         _AccessController(void);
147         ~_AccessController(void);
148
149         _AccessController(const _AccessController& rhs);
150         _AccessController& operator =(const _AccessController& rhs);
151
152         static result CheckPrivacy(const Tizen::App::PackageId& packageId, _Privilege privilege);
153         static result CheckPrivacy(const Tizen::App::PackageId& packageId, const Tizen::Base::String& privilege);
154
155         static void Initialize(void);
156
157         static _PrivilegeManager* __pPrivilegeManager;
158
159 };  // _AccessController
160
161 }} // Tizen::Security
162
163 #endif // _FSEC_INTERNAL_ACCESS_CONTROLLER_H_