Merge "GetErrorMessage() to print the error log" into tizen_2.1
[platform/framework/native/appfw.git] / inc / FSecAccessController.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        FSecAccessController.h
20  * @brief       This is the header file for the %AccessController class.
21  *
22  * This header file contains the declarations of the %AccessController class.
23  */
24
25 #ifndef _FSEC_ACCESS_CONTROLLER_H_
26 #define _FSEC_ACCESS_CONTROLLER_H_
27
28 #include <FOspConfig.h>
29 #include <FAppTypes.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 of privileged API.
39  * @since       2.0
40  *
41  * The %AccessController class provides a way to check the privilege of privileged API.
42  */
43 class _OSP_EXPORT_ AccessController
44 {
45
46 public:
47
48         /**
49          * Checks whether the application has a privilege to invoke the privileged API.
50          *
51          * @since 2.0
52          * @return              An error code
53          * @param[in]   privilege                               A value of enumerator of the specified @c privilege
54          * @exception   E_SUCCESS                               The method is successful and the 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 to call this method.
58      * @exception       E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
59          * @exception   E_SYSTEM                                An unexpected system error has occurred.
60          */
61         static result CheckPrivilege(int privilege);
62
63     /**
64     * Checks whether the application has a privilege to invoke the privileged API.
65     *
66     * @since 2.1
67     * @return           An error code
68     * @param[in]        privilege                               A string of the specified privilege
69     * @exception        E_SUCCESS                               The method is successful and the request is granted.
70     * @exception        E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
71     * @exception        E_DATA_NOT_FOUND                The privilege information does not exist.
72     * @exception        E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
73     * @exception        E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
74     * @exception        E_SYSTEM                                The method cannot proceed due to a severe system error.
75     */
76     static result CheckPrivilege(const Tizen::Base::String& privilege);
77
78
79     /**
80     * Checks whether the client application which has @c appId has a privilege to invoke the privileged API.
81     *
82     * @since 2.1
83     * @return           An error code
84     * @param[in]        packageId                                       The package ID
85     * @param[in]        privilege                               A string of the specified privilege
86     * @exception        E_SUCCESS                               The method is successful and the request is granted.
87     * @exception        E_INVALID_ARG                   The specified @c privilege is invalid privilege string.
88     * @exception        E_DATA_NOT_FOUND                The privilege information does not exist.
89     * @exception        E_PRIVILEGE_DENIED              The application does not have the privilege to call the method.
90     * @exception        E_USER_NOT_CONSENTED    The user blocks an application from calling the method.
91     * @exception        E_SYSTEM                                The method cannot proceed due to a severe system error.
92     */
93     static result CheckPrivilege(const Tizen::App::PackageId& packageId, const Tizen::Base::String& privilege);
94
95 private:
96
97     /**
98      * This default constructor is intentionally declared as private because this class cannot be constructed.
99      */
100         AccessController(void);
101
102     /**
103      * This destructor is intentionally declared as private because this class cannot be constructed.
104      */
105         ~AccessController(void);
106
107     /**
108      * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
109      */
110         AccessController(const AccessController& rhs);
111
112     /**
113      * The implementation of this copy assignment operator is intentionally blank and delcared as private to prohibit copying of objects.
114      */
115         AccessController& operator =(const AccessController& rhs);
116
117         static void Initialize(void);
118
119 private:
120         static _PrivilegeManager* __pPrivilegeManager;
121
122 };  // AccessController
123
124 }} // Tizen::Security
125
126 #endif // _FSEC_ACCESS_CONTROLLER_H_