|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of script manager class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef C_RTSECMGRSCRIPTMANAGER_H |
|
24 #define C_RTSECMGRSCRIPTMANAGER_H |
|
25 |
|
26 #include <e32capability.h> |
|
27 #include <rtsecmgrutility.h> |
|
28 #include <rtsecmgrscript.h> |
|
29 #include "rtsecmgrdef.h" |
|
30 #include "rtsecmgrstore.h" |
|
31 |
|
32 //Forward declarations |
|
33 class CSecMgrStore; |
|
34 class CPolicyManager; |
|
35 |
|
36 typedef RPointerArray<CScript> RScripts; |
|
37 |
|
38 /* |
|
39 * Models the cache to maintain the list of registered script |
|
40 * data. Provides operations to register script, de-register |
|
41 * script, query script related information. |
|
42 * |
|
43 * This class abstracts the underlying persistent storage to |
|
44 * store script related data. |
|
45 * |
|
46 * @see CSecMgrStore |
|
47 * @see CPolicyManager |
|
48 * @see CScript |
|
49 * |
|
50 * @exe rtsecmgrserver.exe |
|
51 */ |
|
52 class CScriptManager : public CBase |
|
53 { |
|
54 public: |
|
55 /** |
|
56 * Two-phased constructor |
|
57 * |
|
58 * Constructs a CScriptManager instance |
|
59 * |
|
60 * @param aSecMgrDB CSecMgrStore* reference to security manager store |
|
61 * @param aPolicyMgr CPolicyManager* reference to policymanager instance |
|
62 * |
|
63 * @return CScriptManager* pointer to an instance of CScriptManager |
|
64 */ |
|
65 static CScriptManager* NewL(CSecMgrStore* aSecMgrDB, |
|
66 CPolicyManager* aPolicyMgr); |
|
67 |
|
68 /** |
|
69 * Two-phased constructor |
|
70 * |
|
71 * Constructs a CScriptManager instance and leaves the created instance |
|
72 * on the cleanupstack |
|
73 * |
|
74 * @param aSecMgrDB CSecMgrStore* reference to security manager store |
|
75 * @param aPolicyMgr CPolicyManager* reference to policymanager instance |
|
76 * |
|
77 * @return CScriptManager* pointer to an instance of CScriptManager |
|
78 */ |
|
79 static CScriptManager* NewLC(CSecMgrStore* aSecMgrDB, |
|
80 CPolicyManager* aPolicyMgr); |
|
81 |
|
82 /** |
|
83 * Destructor |
|
84 * |
|
85 * Performs clean-up of transient script store cache |
|
86 * |
|
87 */ |
|
88 virtual ~CScriptManager(); |
|
89 |
|
90 /** |
|
91 * Registers a script based on a policy identified by |
|
92 * input policy identifier with security manager |
|
93 * |
|
94 * @param aPolicyID TPolicyID input policy identifier of the script |
|
95 * |
|
96 * @return TExecutableID script identifier of the registered script |
|
97 */ |
|
98 TExecutableID |
|
99 RegisterScript(TPolicyID aPolicyID); |
|
100 |
|
101 /** |
|
102 * Registers a script with hashvalue based on a policy identified by |
|
103 * input policy identifier with security manager. |
|
104 * |
|
105 * @param aPolicyID TPolicyID input policy identifier of the script |
|
106 * @param aHashValue const TDesC& hashValue of the script |
|
107 * |
|
108 * @return TExecutableID script identifier of the registered script |
|
109 */ |
|
110 TExecutableID |
|
111 RegisterScript(TPolicyID aPolicyID, const TDesC& aHashValue); |
|
112 |
|
113 /** |
|
114 * Un-Registers a script |
|
115 * |
|
116 * @param aExecID script identifier of the registered script |
|
117 * @param aPolicyID policy identifier passed while registering script |
|
118 * |
|
119 */ |
|
120 void UnRegisterScriptL(TExecutableID aExecID, TPolicyID aPolicyID); |
|
121 |
|
122 /** |
|
123 * Gets underlying script data |
|
124 * |
|
125 * @param aScriptInfo CScript& output script data |
|
126 * |
|
127 * @return KErrNone if script data could be returned; Otherwise one of |
|
128 * system error codes |
|
129 * |
|
130 */ |
|
131 TInt ScriptInfo(CScript& aScriptInfo); |
|
132 |
|
133 /** |
|
134 * Updates permanently granted or denied permission data |
|
135 * of the script |
|
136 * |
|
137 * @param aExecID TExecutableID script identifier |
|
138 * @param aPermGrant TPermGrant permanently allowed permission |
|
139 * @param aPermDenied TPermGrant permanently denied permission |
|
140 * |
|
141 */ |
|
142 void UpdatePermGrantL(TExecutableID aExecID, TPermGrant aPermGrant, |
|
143 TPermGrant aPermDenied); |
|
144 |
|
145 /** |
|
146 * Gets the script file name |
|
147 * |
|
148 * @param aExecID TExecutableID script identifier |
|
149 * @param TDes& Output file name |
|
150 * |
|
151 * @return KErrNone if operation is successful; Otherwise one of |
|
152 * system wide error codes |
|
153 * |
|
154 */ |
|
155 TInt GetScriptFile(TExecutableID aExecID, TDes& aScriptFile); |
|
156 |
|
157 private: |
|
158 |
|
159 /** |
|
160 * Overloaded constructor to initialise internal |
|
161 * state of CScriptManager |
|
162 * |
|
163 */ |
|
164 inline CScriptManager(CSecMgrStore* aSecMgrDB, CPolicyManager* aPolicyMgr) : |
|
165 iSecMgrDB(aSecMgrDB), iPolicyMgr(aPolicyMgr) |
|
166 { |
|
167 } |
|
168 |
|
169 /** |
|
170 * Two-phased constructor |
|
171 * |
|
172 */ |
|
173 void ConstructL(); |
|
174 |
|
175 /** |
|
176 * Generates a new script identifier |
|
177 * |
|
178 */ |
|
179 inline TExecutableID GetID() |
|
180 { |
|
181 if ( --iID > 0) |
|
182 return iID; |
|
183 |
|
184 return (TExecutableID)KSecurityServerUid2Int; |
|
185 } |
|
186 |
|
187 private: |
|
188 |
|
189 //list of script data structure |
|
190 RScripts iScripts; |
|
191 |
|
192 //reference to security manager store |
|
193 CSecMgrStore* iSecMgrDB; |
|
194 |
|
195 //reference to policymanager instance |
|
196 CPolicyManager* iPolicyMgr; |
|
197 |
|
198 //Last generated script identifier |
|
199 TExecutableID iID; |
|
200 }; |
|
201 |
|
202 #endif //C_RTSECMGRSCRIPTMANAGER_H |
|
203 |