sync with tizen_2.0
[platform/framework/native/appfw.git] / src / security / FSec_PrivilegeCache.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        FSecurity_PrivilegeCache.h
20  * @brief       This is the header file for the _PrivilegeCache.
21  *
22  * This header file contains the declarations of the _PrivilegeCache.
23  */
24
25 #ifndef _FSEC_INTERNAL_PRIVILEGE_CACHE_H_
26 #define _FSEC_INTERNAL_PRIVILEGE_CACHE_H_
27
28 #include <unique_ptr.h>
29 #include <FOspConfig.h>
30 #include "FSec_AccessControlTypes.h"
31
32 namespace Tizen { namespace Base { namespace Runtime
33 {
34 class Mutex;
35 }}}
36
37 namespace Tizen { namespace Security
38 {
39
40 class _PrivilegeInfo;
41
42 /**
43  * @class       _PrivilegeCache
44  * @brief       This class provides a way to access the privilege cache.
45  * @since       2.0
46  *
47  * This class provides a way to access the privilege cache.
48  *
49  */
50 class _PrivilegeCache
51         : public Tizen::Base::Object
52 {
53
54 public:
55
56         _PrivilegeCache(void);
57         virtual ~_PrivilegeCache(void);
58
59         result Construct(void);
60
61         /**
62          * Adds the specified privilege information to the privilege cache.
63          *
64          * @since               2.0
65          * @return              An error code
66          * @param[in]   privilegeInfo           An instance of _PrivilegeInfo.
67          * @exception   E_SUCCESS                       The method is successful.
68          * @exception   E_INVALID_ARG           A specified input parameter is invalid.
69          * @exception   E_SYSTEM                        An unexpected system error occurred.
70          */
71         result AddPrivilegeInfo(const _PrivilegeInfo& privilegeInfo);
72
73         /**
74          * Removes the specified information in the privilege cache.
75          *
76          * @since               2.0
77          * @return              An error code
78          * @param[in]   appId                           The application ID.
79          * @exception   E_SUCCESS                       The method is successful.
80          * @exception   E_SYSTEM                        An unexpected system error occurred.
81          */
82         result RemovePrivilegeInfo(const Tizen::App::AppId& appId);
83
84         /**
85          * Gets the privilege information of the specified application.
86          *
87          * @since               2.0
88          * @return              A _PrivilegeInfo instance
89          * @param[in]   appId                           The application ID.
90          * @param[out]  privilegeInfo           An instance of _PrivilegeInfo.
91          * @exception   E_SUCCESS                       The method is successful.
92          * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
93          * @exception   E_SYSTEM                        An unexpected system error occurred.
94          */
95         _PrivilegeInfo* GetPrivilegeInfoN(const Tizen::App::AppId& appId) const;
96 private:
97
98         _PrivilegeCache(const _PrivilegeCache& rhs);
99         _PrivilegeCache& operator =(const _PrivilegeCache& rhs);
100
101 private:
102         std::unique_ptr<Tizen::Base::Collection::HashMap> __pPrivilegeList;
103         static std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
104
105 };  // _PrivilegeCache
106
107 }} // Tizen::Security
108
109 #endif // _FSEC_INTERNAL_PRIVILEGE_CACHE_H_