|
1 /* |
|
2 * Copyright (c) 2002-2004 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 "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: $Description: $ |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "TARMDmAdapter.h" |
|
22 #include <PolicyEngineClient.h> |
|
23 #include <SettingEnforcementInfo.h> |
|
24 #include <DMCert.h> |
|
25 #include <PolicyEngineXACML.h> |
|
26 #include "debug.h" |
|
27 #include <smldmadapter.h> |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 |
|
33 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
34 // |
|
35 // CTARMDmAdapter |
|
36 // |
|
37 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CTARMDmAdapter:: |
|
41 // |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CTARMDmAdapter::CTARMDmAdapter( MSmlDmCallback* aCallback ) |
|
45 : CSmlDmAdapter( aCallback ) |
|
46 , iInitialized( EFalse ) |
|
47 { |
|
48 RDEBUG( "CTARMDmAdapter::CTARMDmAdapter" ); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CTARMDmAdapter:: |
|
53 // |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 /* |
|
57 void CTARMDmAdapter::ConstructL() |
|
58 { |
|
59 User::LeaveIfError( iPE.Connect() ); |
|
60 User::LeaveIfError( iPR.Open( iPE ) ); |
|
61 } |
|
62 */ |
|
63 |
|
64 void CTARMDmAdapter::InitializeL() |
|
65 { |
|
66 RDEBUG( "CTARMDmAdapter::InitializeL >" ); |
|
67 if ( !iInitialized ) |
|
68 { |
|
69 User::LeaveIfError( iPE.Connect() ); |
|
70 User::LeaveIfError( iPR.Open( iPE ) ); |
|
71 iInitialized = ETrue; |
|
72 } |
|
73 RDEBUG( "CTARMDmAdapter::InitializeL <" ); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CTARMDmAdapter:: |
|
78 // |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CTARMDmAdapter::~CTARMDmAdapter() |
|
82 { |
|
83 RDEBUG( "CTARMDmAdapter::~CTARMDmAdapter >" ); |
|
84 if ( iInitialized ) |
|
85 { |
|
86 iPR.Close(); |
|
87 iPE.Close(); |
|
88 } |
|
89 RDEBUG( "CTARMDmAdapter::~CTARMDmAdapter <" ); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CTARMDmAdapter:: |
|
94 // |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CTARMDmAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType, TInt aStatusRef ) |
|
98 { |
|
99 RDEBUG( "CTARMDmAdapter::UpdateLeafObjectL >" ); |
|
100 if (CheckPolicyL( aURI ) != KErrNone) |
|
101 { |
|
102 Callback().SetStatusL( aStatusRef, EError ); |
|
103 return; |
|
104 } |
|
105 _UpdateLeafObjectL( aURI, aLUID, aObject, aType, aStatusRef ); |
|
106 RDEBUG( "CTARMDmAdapter::UpdateLeafObjectL <" ); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CTARMDmAdapter:: |
|
111 // |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CTARMDmAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef ) |
|
115 { |
|
116 RDEBUG( "CTARMDmAdapter::UpdateLeafObjectL >" ); |
|
117 if (CheckPolicyL( aURI ) != KErrNone) |
|
118 { |
|
119 Callback().SetStatusL( aStatusRef, EError ); |
|
120 return; |
|
121 } |
|
122 _UpdateLeafObjectL( aURI, aLUID, aStream, aType, aStatusRef ); |
|
123 RDEBUG( "CTARMDmAdapter::UpdateLeafObjectL <" ); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CTARMDmAdapter:: |
|
128 // |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CTARMDmAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, TInt aStatusRef ) |
|
132 { |
|
133 RDEBUG( "CTARMDmAdapter::DeleteObjectL >" ); |
|
134 if (CheckPolicyL( aURI ) != KErrNone) |
|
135 { |
|
136 Callback().SetStatusL( aStatusRef, EError ); |
|
137 return; |
|
138 } |
|
139 _DeleteObjectL( aURI, aLUID, aStatusRef ); |
|
140 RDEBUG( "CTARMDmAdapter::DeleteObjectL <" ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CTARMDmAdapter:: |
|
145 // |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CTARMDmAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef ) |
|
149 { |
|
150 RDEBUG( "CTARMDmAdapter::FetchLeafObjectL >" ); |
|
151 if (CheckPolicyL( aURI ) != KErrNone) |
|
152 { |
|
153 Callback().SetStatusL( aStatusRef, EError ); |
|
154 return; |
|
155 } |
|
156 _FetchLeafObjectL( aURI, aLUID, aType, aResultsRef, aStatusRef ); |
|
157 RDEBUG( "CTARMDmAdapter::FetchLeafObjectL <" ); |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CTARMDmAdapter:: |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CTARMDmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef ) |
|
166 { |
|
167 RDEBUG( "CTARMDmAdapter::FetchLeafObjectSizeL >" ); |
|
168 if (CheckPolicyL( aURI ) != KErrNone) |
|
169 { |
|
170 Callback().SetStatusL( aStatusRef, EError ); |
|
171 return; |
|
172 } |
|
173 _FetchLeafObjectSizeL( aURI, aLUID, aType, aResultsRef, aStatusRef ); |
|
174 RDEBUG( "CTARMDmAdapter::FetchLeafObjectSizeL <" ); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CTARMDmAdapter:: |
|
179 // |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CTARMDmAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, TInt aResultsRef, TInt aStatusRef ) |
|
183 { |
|
184 RDEBUG( "CTARMDmAdapter::ChildURIListL >" ); |
|
185 if (CheckPolicyL( aURI ) != KErrNone) |
|
186 { |
|
187 Callback().SetStatusL( aStatusRef, EError ); |
|
188 return; |
|
189 } |
|
190 _ChildURIListL( aURI, aLUID, aPreviousURISegmentList, aResultsRef, aStatusRef ); |
|
191 RDEBUG( "CTARMDmAdapter::ChildURIListL <" ); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CTARMDmAdapter:: |
|
196 // |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CTARMDmAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, TInt aStatusRef ) |
|
200 { |
|
201 RDEBUG( "CTARMDmAdapter::AddNodeObjectL >" ); |
|
202 if (CheckPolicyL( aURI ) != KErrNone) |
|
203 { |
|
204 Callback().SetStatusL( aStatusRef, EError ); |
|
205 return; |
|
206 } |
|
207 _AddNodeObjectL( aURI, aParentLUID, aStatusRef ); |
|
208 RDEBUG( "CTARMDmAdapter::AddNodeObjectL <" ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CTARMDmAdapter:: |
|
213 // |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CTARMDmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, const TDesC8& aType, TInt aStatusRef ) |
|
217 { |
|
218 RDEBUG( "CTARMDmAdapter::ExecuteCommandL >" ); |
|
219 if (CheckPolicyL( aURI ) != KErrNone) |
|
220 { |
|
221 Callback().SetStatusL( aStatusRef, EError ); |
|
222 return; |
|
223 } |
|
224 _ExecuteCommandL( aURI, aLUID, aArgument, aType, aStatusRef ); |
|
225 RDEBUG( "CTARMDmAdapter::ExecuteCommandL <" ); |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CTARMDmAdapter:: |
|
230 // |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void CTARMDmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef ) |
|
234 { |
|
235 RDEBUG( "CTARMDmAdapter::ExecuteCommandL (stream) >" ); |
|
236 if (CheckPolicyL( aURI ) != KErrNone) |
|
237 { |
|
238 Callback().SetStatusL( aStatusRef, EError ); |
|
239 return; |
|
240 } |
|
241 _ExecuteCommandL( aURI, aLUID, aStream, aType, aStatusRef ); |
|
242 RDEBUG( "CTARMDmAdapter::ExecuteCommandL (stream) <" ); |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CTARMDmAdapter:: |
|
247 // |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CTARMDmAdapter::CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID, const TDesC8& aSourceURI, const TDesC8& aSourceLUID, const TDesC8& aType, TInt aStatusRef ) |
|
251 { |
|
252 RDEBUG( "CTARMDmAdapter::CopyCommandL >" ); |
|
253 if (CheckPolicyL( aTargetURI ) != KErrNone) |
|
254 { |
|
255 Callback().SetStatusL( aStatusRef, EError ); |
|
256 return; |
|
257 } |
|
258 _CopyCommandL( aTargetURI, aTargetLUID, aSourceURI, aSourceLUID, aType, aStatusRef ); |
|
259 RDEBUG( "CTARMDmAdapter::CopyCommandL <" ); |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CTARMDmAdapter:: |
|
264 // |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 TInt CTARMDmAdapter::CheckPolicyL( const TDesC8& aURI ) |
|
268 { |
|
269 RDEBUG( "CTARMDmAdapter::CheckPolicyL >" ); |
|
270 InitializeL(); |
|
271 TPtrC8 resource = PolicyRequestResourceL( aURI ); |
|
272 |
|
273 //sf TPolicyRequestParams params = iAdapter->CreatePolicyRequestParamsL( aURI ); |
|
274 TInt ret = CheckPolicy2L( resource ); |
|
275 RDEBUG_2( "CTARMDmAdapter::CheckPolicyL < %d", ret ); |
|
276 return ret; |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CTARMDmAdapter:: |
|
281 // |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TInt CTARMDmAdapter::CheckPolicy2L( const TDesC8& aResource ) |
|
285 { |
|
286 RDEBUG( "CTARMDmAdapter::CheckPolicy2L >" ); |
|
287 TInt ret = KErrNone; |
|
288 |
|
289 TRequestContext context; |
|
290 TResponse response; |
|
291 |
|
292 // Get Certificate |
|
293 RDMCert dmcert; |
|
294 TCertInfo ci; |
|
295 ret = dmcert.Get( ci ); |
|
296 |
|
297 // If got certificate then put is as subject to policy request |
|
298 if (ret == KErrNone) |
|
299 { |
|
300 context.AddSubjectAttributeL( PolicyEngineXACML::KTrustedSubject, ci ); |
|
301 } |
|
302 else if (ret == KErrNotFound) |
|
303 { |
|
304 ret = KErrNone; |
|
305 } |
|
306 //sf- User::LeaveIfError( ret ); |
|
307 |
|
308 // Check Policy |
|
309 if (ret == KErrNone) |
|
310 { |
|
311 context.AddResourceAttributeL( |
|
312 PolicyEngineXACML::KResourceId, |
|
313 aResource, |
|
314 PolicyEngineXACML::KStringDataType ); |
|
315 ret = iPR.MakeRequest( context, response ); |
|
316 } |
|
317 //sf- User::LeaveIfError( ret ); |
|
318 |
|
319 // Check Policy request result |
|
320 if (ret == KErrNone) |
|
321 { |
|
322 TResponseValue resp = response.GetResponseValue(); |
|
323 switch( resp ) |
|
324 { |
|
325 case EResponsePermit: |
|
326 ret = KErrNone; |
|
327 break; |
|
328 case EResponseDeny: |
|
329 case EResponseNotApplicable: |
|
330 case EResponseIndeterminate: |
|
331 default: |
|
332 ret = KErrAccessDenied; |
|
333 break; |
|
334 } |
|
335 } |
|
336 |
|
337 RDEBUG_2( "CTARMDmAdapter::CheckPolicy2L < %d", ret ); |
|
338 return ret; |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // xxx:: |
|
343 // |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 |
|
347 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // ?function_name implements... |
|
351 // ?implementation_description. |
|
352 // Returns: ?value_1: ?description |
|
353 // ?value_n: ?description |
|
354 // ?description |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 //?type ?function_name( |
|
358 // ?arg_type arg, // ?description |
|
359 // ?arg_type arg ) // ?description |
|
360 // { |
|
361 // |
|
362 // ?code |
|
363 // |
|
364 // } |
|
365 |
|
366 // End of File |