|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "authreaduserdata.h" |
|
20 |
|
21 #include <authserver/authclient.h> |
|
22 #include <authserver/authmgrclient.h> |
|
23 #include <e32def.h> |
|
24 |
|
25 _LIT(KAuthReadUserDataSecName, "Auth ReadUserData APIs test"); |
|
26 |
|
27 using namespace AuthServer; |
|
28 |
|
29 CAuthReadUserDataSecTest* CAuthReadUserDataSecTest::NewL() |
|
30 { |
|
31 CAuthReadUserDataSecTest* self=new(ELeave) CAuthReadUserDataSecTest(); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CAuthReadUserDataSecTest::CAuthReadUserDataSecTest() |
|
39 { |
|
40 SetCapabilityRequired(ECapabilityReadUserData); |
|
41 } |
|
42 |
|
43 void CAuthReadUserDataSecTest::ConstructL() |
|
44 { |
|
45 SetNameL(KAuthReadUserDataSecName); |
|
46 } |
|
47 |
|
48 void CAuthReadUserDataSecTest::RunTestL() |
|
49 { |
|
50 AuthServer::RAuthMgrClient authMgrClient; |
|
51 User::LeaveIfError(authMgrClient.Connect()); |
|
52 CleanupClosePushL(authMgrClient); |
|
53 |
|
54 TInt err(0); |
|
55 CAuthExpression* authExpr = AuthExpr(EAuthKnowledge); |
|
56 CleanupStack::PushL(authExpr); |
|
57 |
|
58 TUid clientSid = {0}; |
|
59 |
|
60 AuthServer::CIdentity* identity = NULL; |
|
61 TRAP(err, identity = authMgrClient.AuthenticateL(*authExpr, 0, EFalse, clientSid, EFalse, KNullDesC())); |
|
62 CheckFailL(err, _L("AuthServer::AuthenticateL : Client Specific Key set to false.")); |
|
63 |
|
64 TRAP(err, identity = authMgrClient.AuthenticateL(*authExpr, 0, ETrue, clientSid, ETrue, KNullDesC())); |
|
65 CheckFailL(err, _L("AuthServer::AuthenticateL : Identity String set to true")); |
|
66 |
|
67 clientSid.iUid = 12345678; |
|
68 TRAP(err, identity = authMgrClient.AuthenticateL(*authExpr, 0, ETrue, clientSid, EFalse, KNullDesC())); |
|
69 CheckFailL(err, _L("AuthServer::AuthenticateL : ClientSid greater than zero.")); |
|
70 |
|
71 if(identity != NULL) |
|
72 { |
|
73 delete identity; |
|
74 } |
|
75 |
|
76 TIdentityId id = 5110; |
|
77 HBufC* idString = NULL; |
|
78 TRAP(err, idString = authMgrClient.IdentityStringL(id)); |
|
79 CheckFailL(err, _L("AuthServer::IdentityStringL().")); |
|
80 |
|
81 if(idString != NULL) |
|
82 { |
|
83 delete idString; |
|
84 } |
|
85 |
|
86 CleanupStack::PopAndDestroy(2, &authMgrClient); |
|
87 } |
|
88 |
|
89 |
|
90 |