Revert "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 class PrivilegeService;
43
44 namespace Tizen { namespace Security
45 {
46
47 class _PrivilegeCache;
48 class _PrivilegeInfo;
49
50 /**
51  * @class       _PrivilegeManager
52  * @brief       This class provides a way to manage the privilege information.
53  * @since       2.0
54  *
55  * This class provides a way to manage the privilege information.
56  *
57  */
58
59 class _OSP_EXPORT_ _PrivilegeManager
60         : public Tizen::Base::Object
61         , public Tizen::App::Package::IPackageInstallationEventListener
62 {
63
64 public:
65
66         /**
67          * Gets the list of privilege string.
68          *
69          * @since               2.0
70          * @return              A list of privilege string
71          * @param[in]   appId                           The application ID.
72          * @exception   E_SUCCESS                       The method is successful.
73          * @exception   E_DATA_NOT_FOUND        The privilege information does not exist.
74          * @exception   E_SYSTEM                        An unexpected system error occurred.
75          * @remarks     The specific error code can be accessed using the GetLastResult() method.
76          */
77         static Tizen::Base::Collection::IList* GetPrivilegeListN(const Tizen::App::AppId& appId);
78
79         virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult);
80         virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress) {}
81         virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult) {}
82
83
84 private:
85
86         _PrivilegeManager(void);
87         virtual ~_PrivilegeManager(void);
88
89         result Construct(void);
90         static _PrivilegeManager* GetInstance(void);
91
92         static result RetrieveCipherPrivilegeN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
93         static result RetrieveCipherPrivilegeExN(const Tizen::App::AppId& appId, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::ArrayList*& pPrivilegeList);
94         _PrivilegeInfo* RetrievePrivilegeInfoN(const Tizen::App::AppId& appId) const;
95
96         static Tizen::Base::Collection::IList* UnpackPrivilegeN(const byte* pBitwisePrivilege);
97
98         _PrivilegeManager(const _PrivilegeManager& rhs);
99         _PrivilegeManager& operator =(const _PrivilegeManager& rhs);
100
101         static void InitInstance(void);
102
103 private:
104
105         _PrivilegeCache* __pPrivilegeCache;
106         static _PrivilegeManager* __pPrivilegeManagerInstance;
107
108         friend class ::PrivilegeService;
109         friend class _AccessController;
110         friend class AccessController;
111
112 };  // _PrivilegeManager
113
114 }} // Tizen::Security
115
116 #endif // _FSEC_INTERNAL_PRIVILEGE_MANAGER_H_