1 /* |
|
2 * Copyright (c) 2006-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 * CTestStep derived implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "tAuthSvrStep.h" |
|
21 |
|
22 #include "authserver/authclient.h" |
|
23 #include "authserver/authmgrclient.h" |
|
24 |
|
25 using namespace AuthServer; |
|
26 |
|
27 //==================================================================================================== |
|
28 CTRemoveAuthMethod::CTRemoveAuthMethod(CTAuthSvrServer& aParent): iParent(aParent) |
|
29 /** |
|
30 Constructor |
|
31 */ |
|
32 { |
|
33 // Call base class method to set up the human readable name for logging |
|
34 SetTestStepName(KTForgetPlugin); |
|
35 } |
|
36 |
|
37 CTRemoveAuthMethod::~CTRemoveAuthMethod() |
|
38 /** |
|
39 Destructor |
|
40 */ |
|
41 { |
|
42 } |
|
43 |
|
44 TVerdict CTRemoveAuthMethod::doTestStepPreambleL() |
|
45 /** |
|
46 @return - TVerdict code |
|
47 Override of base class virtual |
|
48 */ |
|
49 { |
|
50 //Call the parent class preamble, setting up the file server, etc |
|
51 CTStepActSch::doTestStepPreambleL(); |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 TVerdict CTRemoveAuthMethod::doTestStepL() |
|
56 /** |
|
57 @return - Test step result (EPass or EFail) |
|
58 */ |
|
59 { |
|
60 SetTestStepResult(EPass); |
|
61 __UHEAP_MARK; // Check for memory leaks |
|
62 |
|
63 //----------------------------------------------------------------------------------------------------- |
|
64 InitAuthServerFromFileL(); // Set things like 'iSupportsDefaultData' and 'DefaultPlugin' |
|
65 |
|
66 CActiveScheduler::Install(iActSchd); |
|
67 //Connect to the AuthServer |
|
68 AuthServer::RAuthMgrClient authMgrClient1; |
|
69 TInt connectVal = authMgrClient1.Connect(); |
|
70 if (KErrNotFound == connectVal) |
|
71 { |
|
72 //Retry after a delay |
|
73 TTimeIntervalMicroSeconds32 timeInterval = 2000; //2 Milliseconds |
|
74 User::After(timeInterval); |
|
75 connectVal = authMgrClient1.Connect(); |
|
76 } |
|
77 if (KErrNone != connectVal) |
|
78 { |
|
79 ERR_PRINTF2(_L("Unable to start a session or other connection error. Err = %d"), connectVal); |
|
80 User::LeaveIfError(connectVal); |
|
81 } |
|
82 |
|
83 CleanupClosePushL(authMgrClient1); |
|
84 //----------------------------------------------------------------------------------------------------- |
|
85 TBool statusAll = EFalse; |
|
86 statusAll = CheckPluginStatusAllL(authMgrClient1); |
|
87 |
|
88 TRAPD(res2, RemoveAuthMethodL(authMgrClient1) ); |
|
89 if(KErrNone != res2) |
|
90 { |
|
91 ERR_PRINTF2(_L("RemoveAuthMethodL() performed a Leave with code %d"), res2 ); |
|
92 SetTestStepError(res2); |
|
93 SetTestStepResult(EFail); |
|
94 } |
|
95 statusAll = CheckPluginStatusAllL(authMgrClient1); |
|
96 if (!statusAll) |
|
97 { |
|
98 SetTestStepResult(EFail); |
|
99 } |
|
100 |
|
101 CleanupStack::PopAndDestroy(&authMgrClient1); // authClient1 |
|
102 //Garbage collect the last previously destroyed implementation |
|
103 // and close the REComSession if no longer in use |
|
104 REComSession::FinalClose(); |
|
105 __UHEAP_MARKEND; |
|
106 return TestStepResult(); |
|
107 } |
|
108 |
|
109 |
|
110 TVerdict CTRemoveAuthMethod::doTestStepPostambleL() |
|
111 /** |
|
112 @return - Pass or fail value of test step result |
|
113 */ |
|
114 { |
|
115 //Call the parent postamble, releasing the file handle, etc |
|
116 CTStepActSch::doTestStepPostambleL(); |
|
117 return TestStepResult(); |
|
118 } |
|
119 |
|
120 |
|
121 void CTRemoveAuthMethod::RemoveAuthMethodL (RAuthMgrClient& mgc) |
|
122 { |
|
123 //If the pluginId is quoted in the ini file, check it's training status |
|
124 TInt forgetPluginValue = 0; |
|
125 TBool forgetUnknownId = EFalse; |
|
126 |
|
127 |
|
128 TBool ok = |
|
129 GetHexFromConfig(ConfigSection(),_L("forgetPlugin"), forgetPluginValue); |
|
130 |
|
131 GetBoolFromConfig(ConfigSection(),_L("forgetUnknown"), forgetUnknownId); |
|
132 |
|
133 if (ok) |
|
134 { |
|
135 // Get the most recently authenticated identity, which we want this plugin to forget. |
|
136 TIdentityId identity = 0; |
|
137 |
|
138 if (forgetUnknownId) |
|
139 { |
|
140 INFO_PRINTF1(_L("Forgetting for unknown identity!")); |
|
141 identity = 0; |
|
142 } |
|
143 else |
|
144 { |
|
145 identity = getLastAuthId(); |
|
146 } |
|
147 |
|
148 // now forget the plugin |
|
149 RDebug::Printf("Forget %d, %d", identity, forgetPluginValue); |
|
150 mgc.ForgetPluginL(identity, forgetPluginValue); |
|
151 RDebug::Printf("DONE: Forget %d, %d", identity, forgetPluginValue); |
|
152 } |
|
153 else |
|
154 { |
|
155 INFO_PRINTF1(_L("missing parameters in the ini file!")); |
|
156 SetTestStepResult(EFail); |
|
157 } |
|
158 } |
|