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