Merge "[ACR][01/10/2013][Add|Deprecate]Adding ToInt8() method in Number, Int8, Intege...
[platform/framework/native/appfw.git] / src / security / inc / FSec_PrivilegeManager.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file        FSec_PrivilegeManager.h
19  * @brief       This is the header file for the _PrivilegeManager.
20  * This header file contains the declarations of the _PrivilegeManager.
21  */
22
23 #ifndef _FSEC_INTERNAL_PRIVILEGE_MANAGER_H_
24 #define _FSEC_INTERNAL_PRIVILEGE_MANAGER_H_
25
26 #include <FOspConfig.h>
27 #include <FAppPkgIPackageInstallationEventListener.h>
28
29 #include "FSec_AccessControlTypes.h"
30
31 namespace Tizen { namespace Base { namespace Collection
32 {
33 class IList;
34 }}}
35
36 namespace Tizen { namespace Base
37 {
38 class String;
39 }}
40
41  namespace Tizen { namespace Security
42 {
43
44 class _PrivilegeCache;
45 class _PrivilegeInfo;
46
47 /**
48  * @class       _PrivilegeManager
49  * @brief       This class provides a way to manage the privilege information.
50  * @since       2.0
51  *
52  * This class provides a way to manage the privilege information.
53  *
54  */
55
56 class _OSP_EXPORT_ _PrivilegeManager
57         : public Tizen::Base::Object
58         , public Tizen::App::Package::IPackageInstallationEventListener
59 {
60
61 public:
62
63         /**
64          * Gets the list of privilege string.
65          *
66          * @since               2.0
67          * @return              A list of privilege string
68          * @param[in]   appId                           The application ID.
69          * @exception   E_SUCCESS                       The method is successful.
70          * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
71          * @exception   E_SYSTEM                        An unexpected system error occurred.
72          * @remarks     The specific error code can be accessed using the GetLastResult() method.
73          */
74         static Tizen::Base::Collection::IList* GetPrivilegeListN(const Tizen::App::AppId& appId);
75
76         virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult);
77         virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress) {}
78         virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult) {}
79
80
81 private:
82
83         _PrivilegeManager(void);
84         virtual ~_PrivilegeManager(void);
85
86         result Construct(void);
87         static _PrivilegeManager* GetInstance(void);
88
89         static result RetrieveCipherPrivilegeN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
90         static result RetrieveCipherPrivilegeExN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
91         _PrivilegeInfo* RetrievePrivilegeInfoN(const Tizen::App::AppId& appId) const;
92
93         static Tizen::Base::Collection::IList* UnpackPrivilegeN(const byte* pBitwisePrivilege);
94
95         _PrivilegeManager(const _PrivilegeManager& rhs);
96         _PrivilegeManager& operator =(const _PrivilegeManager& rhs);
97
98         static void InitInstance(void);
99
100 private:
101
102         _PrivilegeCache* __pPrivilegeCache;
103         static _PrivilegeManager* __pPrivilegeManagerInstance;
104
105         friend class _PrivilegeManagerServer;
106         friend class _AccessController;
107         friend class AccessController;
108
109 };  // _PrivilegeManager
110
111 }} // Tizen::Security
112
113 #endif // _FSEC_INTERNAL_PRIVILEGE_MANAGER_H_