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