1 /* |
|
2 * Copyright (c) 2002 - 2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <badesca.h> |
|
26 #include <bautils.h> |
|
27 // [INCLUDE FILES] - do not remove |
|
28 #include <e32svr.h> |
|
29 #include <StifParser.h> |
|
30 #include <StifTestInterface.h> |
|
31 #include "ui_tsecuritymanager.h" |
|
32 #include<coemain.h> |
|
33 |
|
34 #include <e32base.h> |
|
35 #include <e32std.h> |
|
36 #include <f32file.h> |
|
37 #include <rtsecmanager.h> |
|
38 #include <rtsecmgrutility.h> |
|
39 #include <rtsecmgrscriptsession.h> |
|
40 #include <rtsecmgrcommondef.h> |
|
41 //#include <rtsecmgrclient.h> |
|
42 #include<w32std.h> |
|
43 _LIT(KSecMgrServerExeName, "RTSecMgrServer.exe"); |
|
44 _LIT(KServerStartFailed, "Security manager server starting failed"); |
|
45 _LIT(KSecServerProcessName, "SecurityManagerServer"); |
|
46 const TUint KDefaultMessageSlots= 16; |
|
47 const TUint KRTSecMgrServMajorVersionNumber=0; |
|
48 const TUint KRTSecMgrServMinorVersionNumber=1; |
|
49 const TUint KRTSecMgrServBuildVersionNumber=1; |
|
50 |
|
51 |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Cui_tsecuritymanager::Delete |
|
57 // Delete here all resources allocated and opened from test methods. |
|
58 // Called from destructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void Cui_tsecuritymanager::Delete() |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Cui_tsecuritymanager::RunMethodL |
|
68 // Run specified method. Contains also table of test mothods and their names. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TInt Cui_tsecuritymanager::RunMethodL( |
|
72 CStifItemParser& aItem ) |
|
73 { |
|
74 |
|
75 static TStifFunctionInfo const KFunctions[] = |
|
76 { |
|
77 // Copy this line for every implemented function. |
|
78 // First string is the function name used in TestScripter script file. |
|
79 // Second is the actual implementation member function. |
|
80 ENTRY( "serverstart1", Cui_tsecuritymanager::serverstart1 ), |
|
81 ENTRY( "serverstart2", Cui_tsecuritymanager::serverstart2 ), |
|
82 ENTRY( "secclient1", Cui_tsecuritymanager::secclient1 ), |
|
83 ENTRY( "secclient2", Cui_tsecuritymanager::secclient2 ), |
|
84 ENTRY( "secclient3",Cui_tsecuritymanager::secclient3), |
|
85 ENTRY( "secclient4",Cui_tsecuritymanager::secclient4), |
|
86 ENTRY( "secclient5",Cui_tsecuritymanager::secclient5), |
|
87 ENTRY( "secclient6",Cui_tsecuritymanager::secclient6), |
|
88 ENTRY( "secclient7",Cui_tsecuritymanager::secclient7), |
|
89 ENTRY( "secclient8",Cui_tsecuritymanager::secclient8), |
|
90 ENTRY( "secclient9",Cui_tsecuritymanager::secclient9), |
|
91 ENTRY( "secclient10",Cui_tsecuritymanager::secclient10), |
|
92 ENTRY( "secclient11",Cui_tsecuritymanager::secclient11), |
|
93 ENTRY( "secclient12",Cui_tsecuritymanager::secclient12), |
|
94 ENTRY( "secclient13",Cui_tsecuritymanager::secclient13), |
|
95 |
|
96 // [test cases entries] - Do not remove |
|
97 |
|
98 }; |
|
99 const TInt count = sizeof( KFunctions ) / |
|
100 sizeof( TStifFunctionInfo ); |
|
101 |
|
102 return RunInternalL( KFunctions, count, aItem ); |
|
103 |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // Cui_tsecuritymanager::serverstart1 |
|
108 // Example test method function. |
|
109 // (other items were commented in a header). |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TInt Cui_tsecuritymanager::serverstart1( CStifItemParser& aItem ) |
|
113 { |
|
114 __UHEAP_MARK; |
|
115 |
|
116 TInt retry(2); // Try this twice |
|
117 TInt err(KErrNone); |
|
118 |
|
119 while (retry>KErrNone) |
|
120 { |
|
121 // Try to create a Server session |
|
122 err = CreateSession ( KSecServerProcessName, Version (), |
|
123 KDefaultMessageSlots); |
|
124 |
|
125 if ( err != KErrNotFound && err != KErrServerTerminated) |
|
126 { |
|
127 // KErrNone or unrecoverable error |
|
128 if ( err != KErrNone) |
|
129 { |
|
130 } |
|
131 retry = 0; |
|
132 } |
|
133 else |
|
134 { |
|
135 // Return code was KErrNotFound or KErrServerTerminated. |
|
136 // Try to start a new security manager server instance |
|
137 |
|
138 err = StartSecManagerServer (); |
|
139 |
|
140 |
|
141 |
|
142 if ( err != KErrNone && err != KErrAlreadyExists) |
|
143 { |
|
144 // Unrecoverable error |
|
145 |
|
146 retry = 0; |
|
147 } |
|
148 } |
|
149 |
|
150 retry--; |
|
151 } |
|
152 |
|
153 |
|
154 // __UHEAP_MARKEND; |
|
155 |
|
156 |
|
157 |
|
158 return KErrNone; |
|
159 |
|
160 } |
|
161 |
|
162 |
|
163 TVersion Cui_tsecuritymanager::Version(void) const |
|
164 { |
|
165 return (TVersion(KRTSecMgrServMajorVersionNumber,KRTSecMgrServMinorVersionNumber,KRTSecMgrServBuildVersionNumber)); |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 TInt Cui_tsecuritymanager::StartSecManagerServer() const |
|
171 { |
|
172 |
|
173 RProcess server ,server1; |
|
174 const TUidType serverUid( KNullUid, KSecMgrServerUid2, KNullUid); |
|
175 TInt err = server.Create ( ServerLocation (), |
|
176 KNullDesC, |
|
177 serverUid, |
|
178 EOwnerProcess); |
|
179 |
|
180 TInt err1 = server1.Create ( ServerLocation (), |
|
181 KNullDesC, |
|
182 serverUid, |
|
183 EOwnerProcess); |
|
184 |
|
185 // Return error code if we the process couldn't be created |
|
186 if ( KErrNone == err) |
|
187 { |
|
188 // Rendezvous is used to detect server start |
|
189 TRequestStatus status; |
|
190 server.Rendezvous ( status); |
|
191 |
|
192 if ( status != KRequestPending) |
|
193 { |
|
194 |
|
195 server.Kill ( 0); // Abort startup |
|
196 } |
|
197 else |
|
198 { |
|
199 server.Resume (); // Logon OK - start the server |
|
200 } |
|
201 User::WaitForRequest (status); // Wait for start or death |
|
202 |
|
203 if ( server.ExitType ()== EExitPanic) |
|
204 { |
|
205 |
|
206 err = KErrGeneral; |
|
207 } |
|
208 else |
|
209 { |
|
210 err = status.Int (); |
|
211 } |
|
212 |
|
213 // We can close the handle now |
|
214 server.Close (); |
|
215 |
|
216 } |
|
217 return err; |
|
218 } |
|
219 |
|
220 |
|
221 TFullName Cui_tsecuritymanager::ServerLocation() const |
|
222 { |
|
223 TFullName fullPathAndName; |
|
224 fullPathAndName.Append ( KSecMgrServerExeName); |
|
225 return fullPathAndName; |
|
226 } |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // Cui_tsecuritymanager::serverstart1 |
|
237 // Example test method function. |
|
238 // (other items were commented in a header). |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 TInt Cui_tsecuritymanager::serverstart2( CStifItemParser& aItem ) |
|
242 { |
|
243 __UHEAP_MARK; |
|
244 CRTSecMgrClientProxy *proxy; |
|
245 RSecMgrSession *isecmgrsession; |
|
246 // Connect(); |
|
247 // proxy->ConstructL(); |
|
248 |
|
249 // __UHEAP_MARKEND; |
|
250 |
|
251 |
|
252 |
|
253 return KErrNone; |
|
254 |
|
255 } |
|
256 |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // Cui_tsecuritymanager::secclient1 |
|
260 // Example test method function. |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt Cui_tsecuritymanager::secclient1( CStifItemParser& aItem ) |
|
265 { |
|
266 |
|
267 |
|
268 TInt cnt = User::CountAllocCells(); |
|
269 // __UHEAP_MARK; |
|
270 TInt32 exId; |
|
271 TPtrC sptr; |
|
272 |
|
273 aItem.GetNextString(sptr); |
|
274 |
|
275 iSession = CRTSecManager::NewL (); |
|
276 // iSession2 = CRTSecManager::NewL (); |
|
277 iTrust = CTrustInfo::NewL (); |
|
278 |
|
279 |
|
280 |
|
281 RFs fileSession; |
|
282 if ( KErrNone==fileSession.Connect ()) |
|
283 { |
|
284 CleanupClosePushL (fileSession); |
|
285 if(KErrNone==fileSession.ShareProtected()) |
|
286 { |
|
287 RFile secPolicyFile; |
|
288 |
|
289 |
|
290 TBuf8<5000> aFilebuffer ; |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 aItem.GetNextString(sptr); |
|
297 |
|
298 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
299 EFileShareAny)) |
|
300 { |
|
301 |
|
302 |
|
303 CleanupClosePushL (secPolicyFile); |
|
304 |
|
305 |
|
306 |
|
307 if(!sptr.Compare(_L("File"))) |
|
308 { |
|
309 |
|
310 |
|
311 |
|
312 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
313 } |
|
314 if(!sptr.Compare(_L("Buffer"))) |
|
315 { |
|
316 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
317 { |
|
318 |
|
319 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 |
|
325 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
326 } |
|
327 } |
|
328 CleanupStack::PopAndDestroy ();//fileSession |
|
329 } |
|
330 |
|
331 |
|
332 aItem.GetNextString(sptr); |
|
333 |
|
334 if(!sptr.Compare(_L("nohash"))) |
|
335 { |
|
336 |
|
337 |
|
338 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
339 } |
|
340 |
|
341 if(!sptr.Compare(_L("hash"))) |
|
342 { |
|
343 |
|
344 _LIT(KHash,"sdsds"); |
|
345 TBuf<10> aHash; |
|
346 aHash.Copy(_L("sdsds")); |
|
347 exId = iSession->RegisterScript(iPolicyId,aHash,*iTrust); |
|
348 |
|
349 } |
|
350 |
|
351 |
|
352 |
|
353 CRTSecMgrScriptSession* scriptSession; |
|
354 |
|
355 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
356 |
|
357 |
|
358 |
|
359 //#endif |
|
360 |
|
361 |
|
362 |
|
363 if(scriptSession) |
|
364 { |
|
365 CleanupStack::PushL (scriptSession); |
|
366 RCapabilityArray caps; |
|
367 caps.Append (ECapabilityWriteUserData); |
|
368 caps.Append (ECapabilityReadUserData); |
|
369 caps.Append (ECapabilityLocation); |
|
370 caps.Append (ECapabilityUserEnvironment); |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 caps.Close(); |
|
381 |
|
382 CleanupStack::PopAndDestroy ();//scriptSession |
|
383 } |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 //delete scriptSession1; |
|
398 delete iSession; |
|
399 //delete iSession2; |
|
400 delete iTrust; |
|
401 |
|
402 cnt = User::CountAllocCells(); |
|
403 //__UHEAP_MARKEND; |
|
404 return KErrNone; |
|
405 } |
|
406 |
|
407 |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // Cui_tsecuritymanager::secclient2 |
|
411 // Example test method function. |
|
412 // (other items were commented in a header). |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 TInt Cui_tsecuritymanager::secclient2( CStifItemParser& aItem ) |
|
416 { |
|
417 |
|
418 __UHEAP_MARK; |
|
419 |
|
420 iSession = CRTSecManager::NewL (); |
|
421 iSession2 = CRTSecManager::NewL (); // 2nd session |
|
422 iTrust = CTrustInfo::NewL (); |
|
423 |
|
424 |
|
425 |
|
426 RFs fileSession; |
|
427 if ( KErrNone==fileSession.Connect ()) |
|
428 { |
|
429 CleanupClosePushL (fileSession); |
|
430 if(KErrNone==fileSession.ShareProtected()) |
|
431 { |
|
432 RFile secPolicyFile; |
|
433 |
|
434 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
435 EFileShareAny)) |
|
436 { |
|
437 CleanupClosePushL (secPolicyFile); |
|
438 |
|
439 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
440 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
441 } |
|
442 } |
|
443 CleanupStack::PopAndDestroy ();//fileSession |
|
444 } |
|
445 |
|
446 |
|
447 TInt32 exId = iSession2->RegisterScript (iPolicyId, *iTrust); |
|
448 |
|
449 CRTSecMgrScriptSession* scriptSession; |
|
450 |
|
451 //#ifdef AUTO_TESTING |
|
452 // scriptSession = iSession->GetScriptSessionL(iPolicyId, exId, *iTrust, this); |
|
453 //#else |
|
454 |
|
455 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
456 //#endif |
|
457 |
|
458 |
|
459 |
|
460 if(scriptSession) |
|
461 { |
|
462 CleanupStack::PushL (scriptSession); |
|
463 RCapabilityArray caps; |
|
464 caps.Append (ECapabilityWriteUserData); |
|
465 caps.Append (ECapabilityReadUserData); |
|
466 caps.Append (ECapabilityLocation); |
|
467 caps.Append (ECapabilityUserEnvironment); |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 caps.Close(); |
|
478 |
|
479 CleanupStack::PopAndDestroy ();//scriptSession |
|
480 } |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 TInt result = iSession->UnSetPolicy (iPolicyId); |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 //delete scriptSession1; |
|
495 delete iSession; |
|
496 delete iSession2; |
|
497 delete iTrust; |
|
498 //__UHEAP_MARKEND; |
|
499 return KErrNone; |
|
500 } |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // Cui_tsecuritymanager::secclient3 |
|
509 // Example test method function. |
|
510 // (other items were commented in a header). |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 TInt Cui_tsecuritymanager::secclient3( CStifItemParser& aItem ) |
|
514 { |
|
515 |
|
516 __UHEAP_MARK; |
|
517 |
|
518 iSession = CRTSecManager::NewL (); |
|
519 iSession2 = CRTSecManager::NewL (); // 2nd session |
|
520 iTrust = CTrustInfo::NewL (); |
|
521 |
|
522 |
|
523 |
|
524 RFs fileSession; |
|
525 if ( KErrNone==fileSession.Connect ()) |
|
526 { |
|
527 CleanupClosePushL (fileSession); |
|
528 if(KErrNone==fileSession.ShareProtected()) |
|
529 { |
|
530 RFile secPolicyFile; |
|
531 |
|
532 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
533 EFileShareAny)) |
|
534 { |
|
535 CleanupClosePushL (secPolicyFile); |
|
536 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
537 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
538 } |
|
539 } |
|
540 CleanupStack::PopAndDestroy ();//fileSession |
|
541 } |
|
542 |
|
543 |
|
544 TInt32 exId = iSession2->RegisterScript (iPolicyId, *iTrust); |
|
545 |
|
546 CRTSecMgrScriptSession* scriptSession; |
|
547 |
|
548 |
|
549 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 if(scriptSession) |
|
555 { |
|
556 CleanupStack::PushL (scriptSession); |
|
557 RCapabilityArray caps; |
|
558 caps.Append (ECapabilityWriteUserData); |
|
559 caps.Append (ECapabilityReadUserData); |
|
560 caps.Append (ECapabilityLocation); |
|
561 caps.Append (ECapabilityUserEnvironment); |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 caps.Close(); |
|
572 |
|
573 CleanupStack::PopAndDestroy ();//scriptSession |
|
574 } |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 TInt result = iSession->UnSetPolicy (iPolicyId); |
|
580 |
|
581 |
|
582 TExecutableID exId2 = iSession2->RegisterScript (iPolicyId, *iTrust); |
|
583 |
|
584 |
|
585 // TInt32 x = -108; |
|
586 if(exId2 != ErrRegisterScriptFailed) |
|
587 { |
|
588 delete iSession; |
|
589 delete iSession2; |
|
590 delete iTrust; |
|
591 return exId2; |
|
592 |
|
593 } |
|
594 |
|
595 |
|
596 |
|
597 //delete scriptSession1; |
|
598 delete iSession; |
|
599 delete iSession2; |
|
600 delete iTrust; |
|
601 //__UHEAP_MARKEND; |
|
602 return KErrNone; |
|
603 } |
|
604 |
|
605 |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // Cui_tsecuritymanager::secclient4 |
|
609 // Example test method function. |
|
610 // (other items were commented in a header). |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 TInt Cui_tsecuritymanager::secclient4(CStifItemParser& aItem ) |
|
614 { |
|
615 |
|
616 __UHEAP_MARK; |
|
617 |
|
618 iSession = CRTSecManager::NewL (); |
|
619 iSession2 = CRTSecManager::NewL (); // 2nd session |
|
620 iTrust = CTrustInfo::NewL (); |
|
621 |
|
622 |
|
623 |
|
624 RFs fileSession; |
|
625 if ( KErrNone==fileSession.Connect ()) |
|
626 { |
|
627 CleanupClosePushL (fileSession); |
|
628 if(KErrNone==fileSession.ShareProtected()) |
|
629 { |
|
630 RFile secPolicyFile; |
|
631 |
|
632 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
633 EFileShareAny)) |
|
634 { |
|
635 CleanupClosePushL (secPolicyFile); |
|
636 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
637 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
638 } |
|
639 } |
|
640 CleanupStack::PopAndDestroy ();//fileSession |
|
641 } |
|
642 |
|
643 |
|
644 TInt32 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
645 |
|
646 CRTSecMgrScriptSession* scriptSession; |
|
647 |
|
648 |
|
649 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 if(scriptSession) |
|
655 { |
|
656 CleanupStack::PushL (scriptSession); |
|
657 RCapabilityArray caps; |
|
658 caps.Append (ECapabilityWriteUserData); |
|
659 caps.Append (ECapabilityReadUserData); |
|
660 caps.Append (ECapabilityLocation); |
|
661 caps.Append (ECapabilityUserEnvironment); |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 caps.Close(); |
|
672 |
|
673 CleanupStack::PopAndDestroy ();//scriptSession |
|
674 } |
|
675 |
|
676 |
|
677 |
|
678 TInt result = iSession->UnRegisterScript (exId, iPolicyId); |
|
679 |
|
680 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
681 |
|
682 if(scriptSession) |
|
683 |
|
684 { |
|
685 return KErrGeneral; |
|
686 } |
|
687 |
|
688 |
|
689 //delete scriptSession1; |
|
690 delete iSession; |
|
691 delete iSession2; |
|
692 delete iTrust; |
|
693 //__UHEAP_MARKEND; |
|
694 return KErrNone; |
|
695 } |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 // ----------------------------------------------------------------------------- |
|
701 // Cui_tsecuritymanager::secclient5 |
|
702 // Example test method function. |
|
703 // (other items were commented in a header). |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 TInt Cui_tsecuritymanager::secclient5(CStifItemParser& aItem ) |
|
707 { |
|
708 |
|
709 __UHEAP_MARK; |
|
710 |
|
711 |
|
712 int i= 0; |
|
713 |
|
714 |
|
715 CRTSecManager *iSession[10]; |
|
716 |
|
717 while(i<10) |
|
718 { |
|
719 |
|
720 |
|
721 iSession[i] = CRTSecManager::NewL (); |
|
722 i++; |
|
723 } |
|
724 |
|
725 |
|
726 |
|
727 iTrust = CTrustInfo::NewL (); |
|
728 |
|
729 |
|
730 |
|
731 RFs fileSession; |
|
732 if ( KErrNone==fileSession.Connect ()) |
|
733 { |
|
734 CleanupClosePushL (fileSession); |
|
735 if(KErrNone==fileSession.ShareProtected()) |
|
736 { |
|
737 RFile secPolicyFile; |
|
738 |
|
739 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
740 EFileShareAny)) |
|
741 { |
|
742 CleanupClosePushL (secPolicyFile); |
|
743 iPolicyId = iSession[0]->SetPolicy (secPolicyFile); |
|
744 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
745 } |
|
746 } |
|
747 CleanupStack::PopAndDestroy ();//fileSession |
|
748 } |
|
749 |
|
750 |
|
751 TInt32 exId = iSession[1]->RegisterScript (iPolicyId, *iTrust); |
|
752 |
|
753 CRTSecMgrScriptSession* scriptSession; |
|
754 |
|
755 |
|
756 scriptSession = iSession[2]->GetScriptSessionL(iPolicyId, exId); |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 if(scriptSession) |
|
762 { |
|
763 CleanupStack::PushL (scriptSession); |
|
764 RCapabilityArray caps; |
|
765 caps.Append (ECapabilityWriteUserData); |
|
766 caps.Append (ECapabilityReadUserData); |
|
767 caps.Append (ECapabilityLocation); |
|
768 caps.Append (ECapabilityUserEnvironment); |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 caps.Close(); |
|
779 |
|
780 CleanupStack::PopAndDestroy ();//scriptSession |
|
781 } |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 int j = 0; |
|
788 |
|
789 while(j<10) |
|
790 { |
|
791 |
|
792 delete iSession[j] ; |
|
793 j++; |
|
794 } |
|
795 |
|
796 |
|
797 delete iTrust; |
|
798 //__UHEAP_MARKEND; |
|
799 return KErrNone; |
|
800 } |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 // ----------------------------------------------------------------------------- |
|
807 // Cui_tsecuritymanager::secclient6 |
|
808 // Example test method function. |
|
809 // (other items were commented in a header). |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 TInt Cui_tsecuritymanager::secclient6(CStifItemParser& aItem ) |
|
813 { |
|
814 |
|
815 __UHEAP_MARK; |
|
816 |
|
817 iSession = CRTSecManager::NewL (); |
|
818 iSession2 = CRTSecManager::NewL (); // 2nd session |
|
819 iTrust = CTrustInfo::NewL (); |
|
820 |
|
821 |
|
822 |
|
823 RFs fileSession; |
|
824 if ( KErrNone==fileSession.Connect ()) |
|
825 { |
|
826 CleanupClosePushL (fileSession); |
|
827 if(KErrNone==fileSession.ShareProtected()) |
|
828 { |
|
829 RFile secPolicyFile; |
|
830 |
|
831 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
832 EFileReadDirectIO)) |
|
833 { |
|
834 CleanupClosePushL (secPolicyFile); |
|
835 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
836 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
837 } |
|
838 } |
|
839 CleanupStack::PopAndDestroy ();//fileSession |
|
840 } |
|
841 |
|
842 |
|
843 TInt32 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
844 |
|
845 CRTSecMgrScriptSession* scriptSession; |
|
846 |
|
847 |
|
848 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 if(scriptSession) |
|
854 { |
|
855 CleanupStack::PushL (scriptSession); |
|
856 RCapabilityArray caps; |
|
857 caps.Append (ECapabilityWriteUserData); |
|
858 caps.Append (ECapabilityReadUserData); |
|
859 caps.Append (ECapabilityLocation); |
|
860 caps.Append (ECapabilityUserEnvironment); |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 caps.Close(); |
|
871 |
|
872 CleanupStack::PopAndDestroy ();//scriptSession |
|
873 } |
|
874 |
|
875 |
|
876 |
|
877 TInt result = iSession->UnRegisterScript (exId, iPolicyId); |
|
878 |
|
879 TInt result1 = iSession->UnRegisterScript (exId, iPolicyId); |
|
880 |
|
881 |
|
882 if(result1 != ErrUnRegisterScriptFailed ) |
|
883 { |
|
884 |
|
885 delete iSession; |
|
886 delete iSession2; |
|
887 delete iTrust; |
|
888 return result1; |
|
889 } |
|
890 |
|
891 //delete scriptSession1; |
|
892 delete iSession; |
|
893 delete iSession2; |
|
894 delete iTrust; |
|
895 //__UHEAP_MARKEND; |
|
896 return KErrNone; |
|
897 } |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 // ----------------------------------------------------------------------------- |
|
904 // Cui_tsecuritymanager::secclient7 |
|
905 // Example test method function. |
|
906 // (other items were commented in a header). |
|
907 // ----------------------------------------------------------------------------- |
|
908 // |
|
909 TInt Cui_tsecuritymanager::secclient7(CStifItemParser& aItem ) |
|
910 { |
|
911 |
|
912 __UHEAP_MARK; |
|
913 TPtrC sptr; |
|
914 TInt32 exId; |
|
915 aItem.GetNextString(sptr); |
|
916 |
|
917 iSession = CRTSecManager::NewL (); |
|
918 iSession2 = CRTSecManager::NewL (); // 2nd session |
|
919 iTrust = CTrustInfo::NewL (); |
|
920 RFile secPolicyFile; |
|
921 |
|
922 |
|
923 RFs fileSession; |
|
924 if ( KErrNone==fileSession.Connect ()) |
|
925 { |
|
926 CleanupClosePushL (fileSession); |
|
927 if(KErrNone==fileSession.ShareProtected()) |
|
928 { |
|
929 |
|
930 |
|
931 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
932 EFileShareAny)) |
|
933 { |
|
934 CleanupClosePushL (secPolicyFile); |
|
935 // iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
936 iPolicyId = iSession->UpdatePolicy(iPolicyId,secPolicyFile); |
|
937 |
|
938 |
|
939 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
940 } |
|
941 } |
|
942 CleanupStack::PopAndDestroy ();//fileSession |
|
943 } |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 if(iPolicyId!= ErrInvalidPolicyID) |
|
951 return KErrGeneral; |
|
952 |
|
953 if(!sptr.Compare(_L("gsswithtrust"))) |
|
954 { |
|
955 |
|
956 |
|
957 scriptSession = iSession->GetScriptSessionL(iPolicyId,*iTrust ); |
|
958 if(scriptSession != NULL) |
|
959 return KErrGeneral; |
|
960 } |
|
961 |
|
962 if(!sptr.Compare(_L("gsswithouttrust"))) |
|
963 { |
|
964 exId = iSession->RegisterScript(iPolicyId, *iTrust); |
|
965 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
966 |
|
967 if(scriptSession != NULL) |
|
968 return KErrGeneral; |
|
969 } |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 //delete scriptSession1; |
|
975 delete iSession; |
|
976 delete iSession2; |
|
977 delete iTrust; |
|
978 //__UHEAP_MARKEND; |
|
979 return KErrNone; |
|
980 } |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 // ----------------------------------------------------------------------------- |
|
988 // Cui_tsecuritymanager::secclient8 |
|
989 // Example test method function. |
|
990 // (other items were commented in a header). |
|
991 // ----------------------------------------------------------------------------- |
|
992 // |
|
993 TInt Cui_tsecuritymanager::secclient8( CStifItemParser& aItem ) |
|
994 { |
|
995 |
|
996 __UHEAP_MARK; |
|
997 TInt32 exId; |
|
998 TPtrC sptr; |
|
999 |
|
1000 aItem.GetNextString(sptr); |
|
1001 CRTSecMgrScriptSession* scriptSession; |
|
1002 iSession = CRTSecManager::NewL (); |
|
1003 // iSession2 = CRTSecManager::NewL (); |
|
1004 iTrust = CTrustInfo::NewL (); |
|
1005 |
|
1006 |
|
1007 |
|
1008 RFs fileSession; |
|
1009 if ( KErrNone==fileSession.Connect ()) |
|
1010 { |
|
1011 CleanupClosePushL (fileSession); |
|
1012 if(KErrNone==fileSession.ShareProtected()) |
|
1013 { |
|
1014 RFile secPolicyFile; |
|
1015 |
|
1016 TBuf8<5000> aFilebuffer ; |
|
1017 |
|
1018 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
1019 EFileShareAny)) |
|
1020 { |
|
1021 |
|
1022 |
|
1023 CleanupClosePushL (secPolicyFile); |
|
1024 |
|
1025 |
|
1026 |
|
1027 if(!sptr.Compare(_L("File"))) |
|
1028 { |
|
1029 |
|
1030 |
|
1031 |
|
1032 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
1033 |
|
1034 iPolicyId = iSession->UpdatePolicy(iPolicyId,secPolicyFile); |
|
1035 |
|
1036 |
|
1037 |
|
1038 } |
|
1039 |
|
1040 if(!sptr.Compare(_L("Buffer"))) |
|
1041 { |
|
1042 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1043 { |
|
1044 |
|
1045 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1046 iPolicyId = iSession->UpdatePolicy(iPolicyId,aFilebuffer); |
|
1047 |
|
1048 |
|
1049 } |
|
1050 } |
|
1051 |
|
1052 |
|
1053 |
|
1054 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1055 } |
|
1056 } |
|
1057 CleanupStack::PopAndDestroy ();//fileSession |
|
1058 } |
|
1059 |
|
1060 aItem.GetNextString(sptr); |
|
1061 |
|
1062 if(!sptr.Compare(_L("registerscript"))) |
|
1063 { |
|
1064 |
|
1065 |
|
1066 exId = iSession->RegisterScript(iPolicyId, *iTrust); |
|
1067 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1068 } |
|
1069 |
|
1070 if(!sptr.Compare(_L("noregisterscript"))) |
|
1071 { |
|
1072 //no implementaion |
|
1073 |
|
1074 scriptSession = iSession->GetScriptSessionL(iPolicyId,*iTrust ); |
|
1075 } |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 //#endif |
|
1087 |
|
1088 |
|
1089 |
|
1090 if(scriptSession) |
|
1091 { |
|
1092 CleanupStack::PushL (scriptSession); |
|
1093 RCapabilityArray caps ; |
|
1094 caps.Append (ECapabilityWriteUserData); |
|
1095 caps.Append (ECapabilityReadUserData); |
|
1096 caps.Append (ECapabilityLocation); |
|
1097 caps.Append (ECapabilityUserEnvironment); |
|
1098 aItem.GetNextString(sptr); |
|
1099 if(!sptr.Compare(_L("advancedprompt"))) |
|
1100 { |
|
1101 |
|
1102 scriptSession->PromptHandler()->SetPromptOption(RTPROMPTUI_ADVANCED); |
|
1103 } |
|
1104 |
|
1105 |
|
1106 RCapabilityArray unMatchedCapabilities; |
|
1107 TInt isAllowed(scriptSession->IsAllowed (caps,unMatchedCapabilities)); |
|
1108 |
|
1109 // TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 caps.Close(); |
|
1115 |
|
1116 CleanupStack::PopAndDestroy ();//scriptSession |
|
1117 } |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 //delete scriptSession1; |
|
1132 delete iSession; |
|
1133 //delete iSession2; |
|
1134 delete iTrust; |
|
1135 //__UHEAP_MARKEND; |
|
1136 return KErrNone; |
|
1137 } |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 // ----------------------------------------------------------------------------- |
|
1143 // Cui_tsecuritymanager::secclient1 |
|
1144 // Example test method function. |
|
1145 // (other items were commented in a header). |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 TInt Cui_tsecuritymanager::secclient9( CStifItemParser& aItem ) |
|
1149 { |
|
1150 |
|
1151 __UHEAP_MARK; |
|
1152 TInt32 exId; |
|
1153 TPtrC sptr; |
|
1154 |
|
1155 |
|
1156 |
|
1157 iSession = CRTSecManager::NewL (); |
|
1158 // iSession2 = CRTSecManager::NewL (); |
|
1159 iTrust = CTrustInfo::NewL (); |
|
1160 |
|
1161 |
|
1162 |
|
1163 RFs fileSession; |
|
1164 if ( KErrNone==fileSession.Connect ()) |
|
1165 { |
|
1166 CleanupClosePushL (fileSession); |
|
1167 if(KErrNone==fileSession.ShareProtected()) |
|
1168 { |
|
1169 RFile secPolicyFile; |
|
1170 |
|
1171 |
|
1172 TBuf8<5000> aFilebuffer ; |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
1181 EFileShareAny)) |
|
1182 { |
|
1183 |
|
1184 |
|
1185 CleanupClosePushL (secPolicyFile); |
|
1186 |
|
1187 |
|
1188 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1189 { |
|
1190 |
|
1191 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1192 } |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1198 } |
|
1199 } |
|
1200 CleanupStack::PopAndDestroy ();//fileSession |
|
1201 } |
|
1202 |
|
1203 |
|
1204 aItem.GetNextString(sptr); |
|
1205 |
|
1206 if(!sptr.Compare(_L("nohash"))) |
|
1207 { |
|
1208 |
|
1209 |
|
1210 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
1211 scriptSession = iSession->GetScriptSessionL(iPolicyId,*iTrust ); |
|
1212 } |
|
1213 |
|
1214 if(!sptr.Compare(_L("hash"))) |
|
1215 { |
|
1216 |
|
1217 _LIT(KHash,"sdsds"); |
|
1218 TBuf<10> aHash; |
|
1219 aHash.Copy(_L("sdsds")); |
|
1220 exId = iSession->RegisterScript(iPolicyId,aHash,*iTrust); |
|
1221 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1222 } |
|
1223 |
|
1224 |
|
1225 |
|
1226 // CRTSecMgrScriptSession* scriptSession; |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 //#endif |
|
1233 |
|
1234 |
|
1235 |
|
1236 if(scriptSession) |
|
1237 { |
|
1238 CleanupStack::PushL (scriptSession); |
|
1239 RCapabilityArray caps; |
|
1240 caps.Append (ECapabilityWriteUserData); |
|
1241 caps.Append (ECapabilityReadUserData); |
|
1242 caps.Append (ECapabilityLocation); |
|
1243 caps.Append (ECapabilityUserEnvironment); |
|
1244 |
|
1245 |
|
1246 // RCapabilityArray caps; |
|
1247 RCapabilityArray unMatchedCapabilities; |
|
1248 TInt isAllowed(scriptSession->IsAllowed (caps,unMatchedCapabilities)); |
|
1249 |
|
1250 // TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 caps.Close(); |
|
1256 |
|
1257 CleanupStack::PopAndDestroy ();//scriptSession |
|
1258 } |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 //delete scriptSession1; |
|
1273 delete iSession; |
|
1274 //delete iSession2; |
|
1275 delete iTrust; |
|
1276 //__UHEAP_MARKEND; |
|
1277 return KErrNone; |
|
1278 } |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 // ----------------------------------------------------------------------------- |
|
1286 // Cui_tsecuritymanager::secclient10 |
|
1287 // Example test method function. |
|
1288 // (other items were commented in a header). |
|
1289 // ----------------------------------------------------------------------------- |
|
1290 // |
|
1291 TInt Cui_tsecuritymanager::secclient10( CStifItemParser& aItem ) |
|
1292 { |
|
1293 |
|
1294 __UHEAP_MARK; |
|
1295 TInt32 exId; |
|
1296 TPtrC sptr; |
|
1297 |
|
1298 aItem.GetNextString(sptr); |
|
1299 CRTSecMgrScriptSession* scriptSession; |
|
1300 iSession = CRTSecManager::NewL (); |
|
1301 // iSession2 = CRTSecManager::NewL (); |
|
1302 iTrust = CTrustInfo::NewL (); |
|
1303 |
|
1304 |
|
1305 |
|
1306 RFs fileSession; |
|
1307 if ( KErrNone==fileSession.Connect ()) |
|
1308 { |
|
1309 CleanupClosePushL (fileSession); |
|
1310 if(KErrNone==fileSession.ShareProtected()) |
|
1311 { |
|
1312 RFile secPolicyFile; |
|
1313 |
|
1314 TBuf8<5000> aFilebuffer ; |
|
1315 |
|
1316 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
1317 EFileShareAny)) |
|
1318 { |
|
1319 |
|
1320 |
|
1321 CleanupClosePushL (secPolicyFile); |
|
1322 |
|
1323 |
|
1324 |
|
1325 if(!sptr.Compare(_L("File"))) |
|
1326 { |
|
1327 |
|
1328 |
|
1329 |
|
1330 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
1331 |
|
1332 iPolicyId = iSession->UpdatePolicy(iPolicyId,secPolicyFile); |
|
1333 |
|
1334 |
|
1335 |
|
1336 } |
|
1337 |
|
1338 if(!sptr.Compare(_L("Buffer"))) |
|
1339 { |
|
1340 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1341 { |
|
1342 |
|
1343 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1344 iPolicyId = iSession->UpdatePolicy(iPolicyId,aFilebuffer); |
|
1345 |
|
1346 |
|
1347 } |
|
1348 } |
|
1349 |
|
1350 |
|
1351 |
|
1352 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1353 } |
|
1354 } |
|
1355 CleanupStack::PopAndDestroy ();//fileSession |
|
1356 } |
|
1357 |
|
1358 aItem.GetNextString(sptr); |
|
1359 |
|
1360 if(!sptr.Compare(_L("registerscript"))) |
|
1361 { |
|
1362 |
|
1363 |
|
1364 exId = iSession->RegisterScript(iPolicyId, *iTrust); |
|
1365 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1366 } |
|
1367 |
|
1368 if(!sptr.Compare(_L("noregisterscript"))) |
|
1369 { |
|
1370 //no implementaion |
|
1371 |
|
1372 scriptSession = iSession->GetScriptSessionL(iPolicyId,*iTrust ); |
|
1373 } |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 //#endif |
|
1385 |
|
1386 |
|
1387 |
|
1388 if(scriptSession) |
|
1389 { |
|
1390 CleanupStack::PushL (scriptSession); |
|
1391 RCapabilityArray caps ; |
|
1392 caps.Append (ECapabilityWriteUserData); |
|
1393 caps.Append (ECapabilityReadUserData); |
|
1394 caps.Append (ECapabilityLocation); |
|
1395 caps.Append (ECapabilityUserEnvironment); |
|
1396 // caps.Append(ECapabilitySurroundingsDD); |
|
1397 aItem.GetNextString(sptr); |
|
1398 if(!sptr.Compare(_L("advancedprompt"))) |
|
1399 { |
|
1400 |
|
1401 scriptSession->PromptHandler()->SetPromptOption(RTPROMPTUI_ADVANCED); |
|
1402 } |
|
1403 |
|
1404 |
|
1405 RCapabilityArray unMatchedCapabilities; |
|
1406 unMatchedCapabilities.Append (ECapabilitySurroundingsDD); |
|
1407 TInt isAllowed(scriptSession->IsAllowed (caps,unMatchedCapabilities)); |
|
1408 |
|
1409 // TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 caps.Close(); |
|
1415 |
|
1416 CleanupStack::PopAndDestroy ();//scriptSession |
|
1417 } |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 //delete scriptSession1; |
|
1432 delete iSession; |
|
1433 //delete iSession2; |
|
1434 delete iTrust; |
|
1435 //__UHEAP_MARKEND; |
|
1436 return KErrNone; |
|
1437 } |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 // ----------------------------------------------------------------------------- |
|
1445 // Cui_tsecuritymanager::secclient1 |
|
1446 // Example test method function. |
|
1447 // (other items were commented in a header). |
|
1448 // ----------------------------------------------------------------------------- |
|
1449 // |
|
1450 TInt Cui_tsecuritymanager::secclient11( CStifItemParser& aItem ) |
|
1451 { |
|
1452 |
|
1453 |
|
1454 TInt cnt = User::CountAllocCells(); |
|
1455 // __UHEAP_MARK; |
|
1456 TInt32 exId; |
|
1457 TPtrC sptr; |
|
1458 |
|
1459 aItem.GetNextString(sptr); |
|
1460 |
|
1461 iSession = CRTSecManager::NewL (); |
|
1462 // iSession2 = CRTSecManager::NewL (); |
|
1463 iTrust = CTrustInfo::NewL (); |
|
1464 |
|
1465 // isubsession = RSecMgrSubSession::NewL(); |
|
1466 // SubSessionHandle(); |
|
1467 |
|
1468 RFs fileSession; |
|
1469 if ( KErrNone==fileSession.Connect ()) |
|
1470 { |
|
1471 CleanupClosePushL (fileSession); |
|
1472 if(KErrNone==fileSession.ShareProtected()) |
|
1473 { |
|
1474 RFile secPolicyFile; |
|
1475 |
|
1476 |
|
1477 TBuf8<5000> aFilebuffer ; |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 aItem.GetNextString(sptr); |
|
1484 |
|
1485 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
1486 EFileShareAny)) |
|
1487 { |
|
1488 |
|
1489 |
|
1490 CleanupClosePushL (secPolicyFile); |
|
1491 |
|
1492 |
|
1493 |
|
1494 if(!sptr.Compare(_L("File"))) |
|
1495 { |
|
1496 |
|
1497 |
|
1498 |
|
1499 iPolicyId = iSession->SetPolicy (secPolicyFile); |
|
1500 } |
|
1501 if(!sptr.Compare(_L("Buffer"))) |
|
1502 { |
|
1503 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1504 { |
|
1505 |
|
1506 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1507 } |
|
1508 } |
|
1509 |
|
1510 |
|
1511 |
|
1512 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1513 } |
|
1514 } |
|
1515 CleanupStack::PopAndDestroy ();//fileSession |
|
1516 } |
|
1517 |
|
1518 |
|
1519 aItem.GetNextString(sptr); |
|
1520 |
|
1521 if(!sptr.Compare(_L("nohash"))) |
|
1522 { |
|
1523 |
|
1524 |
|
1525 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
1526 } |
|
1527 |
|
1528 if(!sptr.Compare(_L("hash"))) |
|
1529 { |
|
1530 |
|
1531 _LIT(KHash,"sdsds"); |
|
1532 TBuf<10> aHash; |
|
1533 aHash.Copy(_L("sdsds")); |
|
1534 exId = iSession->RegisterScript(iPolicyId,aHash,*iTrust); |
|
1535 |
|
1536 } |
|
1537 |
|
1538 |
|
1539 |
|
1540 CRTSecMgrScriptSession* scriptSession; |
|
1541 |
|
1542 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1543 |
|
1544 |
|
1545 |
|
1546 //#endif |
|
1547 |
|
1548 |
|
1549 |
|
1550 if(scriptSession) |
|
1551 { |
|
1552 CleanupStack::PushL (scriptSession); |
|
1553 RCapabilityArray caps; |
|
1554 // caps.Append (ECapabilityWriteUserData); |
|
1555 // caps.Append (ECapabilityReadUserData); |
|
1556 // caps.Append (ECapabilityLocation); |
|
1557 caps.Append (ECapabilityNetworkServices); |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 caps.Close(); |
|
1568 |
|
1569 CleanupStack::PopAndDestroy ();//scriptSession |
|
1570 } |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 //delete scriptSession1; |
|
1585 delete iSession; |
|
1586 //delete iSession2; |
|
1587 delete iTrust; |
|
1588 |
|
1589 cnt = User::CountAllocCells(); |
|
1590 //__UHEAP_MARKEND; |
|
1591 return KErrNone; |
|
1592 } |
|
1593 |
|
1594 |
|
1595 // ----------------------------------------------------------------------------- |
|
1596 // Cui_tsecuritymanager::secclient12 |
|
1597 // Example test method function. |
|
1598 // (other items were commented in a header). |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // |
|
1601 TInt Cui_tsecuritymanager::secclient12( CStifItemParser& aItem ) |
|
1602 { |
|
1603 |
|
1604 |
|
1605 TInt cnt = User::CountAllocCells(); |
|
1606 // __UHEAP_MARK; |
|
1607 TInt32 exId; |
|
1608 TPtrC sptr; |
|
1609 |
|
1610 aItem.GetNextString(sptr); |
|
1611 |
|
1612 iSession = CRTSecManager::NewL (); |
|
1613 // iSession2 = CRTSecManager::NewL (); |
|
1614 iTrust = CTrustInfo::NewL (); |
|
1615 |
|
1616 |
|
1617 |
|
1618 RFs fileSession; |
|
1619 if ( KErrNone==fileSession.Connect ()) |
|
1620 { |
|
1621 CleanupClosePushL (fileSession); |
|
1622 if(KErrNone==fileSession.ShareProtected()) |
|
1623 { |
|
1624 RFile secPolicyFile; |
|
1625 |
|
1626 |
|
1627 TBuf8<500> aFilebuffer ; |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 aItem.GetNextString(sptr); |
|
1634 |
|
1635 if ( KErrNone == secPolicyFile.Open (fileSession, _L("c:\\data\\Others\\accesspolicy.xml"), |
|
1636 EFileShareAny)) |
|
1637 { |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 CleanupClosePushL (secPolicyFile); |
|
1645 |
|
1646 |
|
1647 |
|
1648 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1649 { |
|
1650 |
|
1651 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1652 } |
|
1653 |
|
1654 if(iPolicyId!=ErrInvalidPolicyFormat ) |
|
1655 return KErrGeneral; |
|
1656 |
|
1657 |
|
1658 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1659 } |
|
1660 } |
|
1661 CleanupStack::PopAndDestroy ();//fileSession |
|
1662 } |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
1669 |
|
1670 if(exId!=ErrInvalidPolicyID) |
|
1671 return KErrGeneral; |
|
1672 |
|
1673 |
|
1674 CRTSecMgrScriptSession* scriptSession; |
|
1675 |
|
1676 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1677 |
|
1678 |
|
1679 |
|
1680 //#endif |
|
1681 |
|
1682 |
|
1683 |
|
1684 if(scriptSession) |
|
1685 { |
|
1686 CleanupStack::PushL (scriptSession); |
|
1687 RCapabilityArray caps; |
|
1688 caps.Append (ECapabilityWriteUserData); |
|
1689 caps.Append (ECapabilityReadUserData); |
|
1690 caps.Append (ECapabilityLocation); |
|
1691 caps.Append (ECapabilityUserEnvironment); |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 caps.Close(); |
|
1702 |
|
1703 CleanupStack::PopAndDestroy ();//scriptSession |
|
1704 } |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 //delete scriptSession1; |
|
1719 delete iSession; |
|
1720 //delete iSession2; |
|
1721 delete iTrust; |
|
1722 |
|
1723 cnt = User::CountAllocCells(); |
|
1724 //__UHEAP_MARKEND; |
|
1725 return KErrNone; |
|
1726 } |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 // ----------------------------------------------------------------------------- |
|
1733 // Cui_tsecuritymanager::secclient13 |
|
1734 // Example test method function. |
|
1735 // (other items were commented in a header). |
|
1736 // ----------------------------------------------------------------------------- |
|
1737 // |
|
1738 TInt Cui_tsecuritymanager::secclient13( CStifItemParser& aItem ) |
|
1739 { |
|
1740 |
|
1741 |
|
1742 TInt cnt = User::CountAllocCells(); |
|
1743 // __UHEAP_MARK; |
|
1744 TInt32 exId; |
|
1745 TPtrC sptr; |
|
1746 |
|
1747 TBuf<50> path; |
|
1748 aItem.GetNextString(sptr); |
|
1749 |
|
1750 |
|
1751 |
|
1752 // _LIT(path,"c:\\data\\Others\\accesspolicy_1.xml"); |
|
1753 |
|
1754 if(!sptr.Compare(_L("1"))) |
|
1755 { |
|
1756 path.Copy(_L("c:\\data\\Others\\accesspolicy_1.xml")) ; |
|
1757 } |
|
1758 |
|
1759 if(!sptr.Compare(_L("2"))) |
|
1760 { |
|
1761 |
|
1762 path.Copy(_L("c:\\data\\Others\\accesspolicy_2.xml")) ; |
|
1763 } |
|
1764 if(!sptr.Compare(_L("3"))) |
|
1765 { |
|
1766 |
|
1767 path.Copy(_L("c:\\data\\Others\\accesspolicy_3.xml")) ; |
|
1768 } |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 iSession = CRTSecManager::NewL (); |
|
1775 iTrust = CTrustInfo::NewL (); |
|
1776 |
|
1777 |
|
1778 |
|
1779 RFs fileSession; |
|
1780 if ( KErrNone==fileSession.Connect ()) |
|
1781 { |
|
1782 CleanupClosePushL (fileSession); |
|
1783 if(KErrNone==fileSession.ShareProtected()) |
|
1784 { |
|
1785 RFile secPolicyFile; |
|
1786 |
|
1787 |
|
1788 TBuf8<5000> aFilebuffer ; |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 if ( KErrNone == secPolicyFile.Open (fileSession,path, |
|
1796 EFileShareAny)) |
|
1797 { |
|
1798 |
|
1799 |
|
1800 |
|
1801 CleanupClosePushL (secPolicyFile); |
|
1802 |
|
1803 |
|
1804 |
|
1805 if(KErrNone == secPolicyFile.Read(aFilebuffer)) |
|
1806 { |
|
1807 |
|
1808 iPolicyId = iSession->SetPolicy (aFilebuffer); |
|
1809 } |
|
1810 |
|
1811 if(iPolicyId!=ErrInvalidPolicyFormat ) |
|
1812 return KErrGeneral; |
|
1813 |
|
1814 |
|
1815 CleanupStack::PopAndDestroy ();//secPolicyFile |
|
1816 } |
|
1817 } |
|
1818 CleanupStack::PopAndDestroy ();//fileSession |
|
1819 } |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 exId = iSession->RegisterScript (iPolicyId, *iTrust); |
|
1826 |
|
1827 if(exId!=ErrInvalidPolicyID) |
|
1828 return KErrGeneral; |
|
1829 |
|
1830 |
|
1831 CRTSecMgrScriptSession* scriptSession; |
|
1832 |
|
1833 scriptSession = iSession->GetScriptSessionL(iPolicyId, exId); |
|
1834 |
|
1835 |
|
1836 |
|
1837 //#endif |
|
1838 |
|
1839 |
|
1840 |
|
1841 if(scriptSession) |
|
1842 { |
|
1843 CleanupStack::PushL (scriptSession); |
|
1844 RCapabilityArray caps; |
|
1845 caps.Append (ECapabilityWriteUserData); |
|
1846 caps.Append (ECapabilityReadUserData); |
|
1847 caps.Append (ECapabilityLocation); |
|
1848 caps.Append (ECapabilityUserEnvironment); |
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 TInt IsAllowed(scriptSession->IsAllowed(caps)); |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 caps.Close(); |
|
1859 |
|
1860 CleanupStack::PopAndDestroy ();//scriptSession |
|
1861 |
|
1862 return KErrGeneral; |
|
1863 } |
|
1864 |
|
1865 |
|
1866 |
|
1867 // TInt result = iSession->UnSetPolicy (iPolicyId); |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 //delete scriptSession1; |
|
1877 delete iSession; |
|
1878 //delete iSession2; |
|
1879 delete iTrust; |
|
1880 |
|
1881 cnt = User::CountAllocCells(); |
|
1882 //__UHEAP_MARKEND; |
|
1883 return KErrNone; |
|
1884 } |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|