1 /* |
|
2 * Copyright (c) 2005-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 class CAuthActive : CActive |
|
29 { |
|
30 public: |
|
31 CAuthActive(RAuthMgrClient& aClient, TPluginId plugin1IdValue, TInt aFresh, TBool aStop = ETrue) : |
|
32 CActive(EPriorityNormal), |
|
33 iClient(aClient), |
|
34 iResult(EFail), |
|
35 iRunCount(0), |
|
36 iStop(aStop), |
|
37 pluginIdVal(plugin1IdValue), |
|
38 iFresh(aFresh) |
|
39 |
|
40 { |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 void doAuth() |
|
44 { |
|
45 SetActive(); |
|
46 TRequestStatus* status = &iStatus; |
|
47 User::RequestComplete(status, KErrNone); |
|
48 iRunCount = 0; |
|
49 } |
|
50 void DoCancel() |
|
51 { |
|
52 } |
|
53 void RunL() |
|
54 { |
|
55 iErr = iStatus.Int(); |
|
56 if (iStatus.Int() != KErrNone) |
|
57 { |
|
58 } |
|
59 switch (iRunCount) |
|
60 { |
|
61 case 0: |
|
62 iStatus = KRequestPending; |
|
63 iAe = AuthExpr(pluginIdVal); |
|
64 iId = 0; |
|
65 |
|
66 iClient.AuthenticateL(*iAe, iFresh, EFalse, EFalse, iId, iStatus); |
|
67 SetActive(); |
|
68 |
|
69 break; |
|
70 case 1: |
|
71 delete iAe; |
|
72 iStatus = KRequestPending; |
|
73 TRequestStatus* status; |
|
74 status = &iStatus; |
|
75 User::RequestComplete(status, iErr); |
|
76 SetActive(); |
|
77 |
|
78 break; |
|
79 case 2: |
|
80 iResult = iStatus.Int() == KErrNone ? EPass : EFail; |
|
81 iErr = iStatus.Int(); |
|
82 if (iStop) |
|
83 { |
|
84 CActiveScheduler::Stop(); |
|
85 } |
|
86 |
|
87 break; |
|
88 default: |
|
89 iResult = EFail; |
|
90 |
|
91 if (iStop) |
|
92 { |
|
93 CActiveScheduler::Stop(); |
|
94 } |
|
95 } |
|
96 ++iRunCount; |
|
97 } |
|
98 RAuthMgrClient& iClient; |
|
99 TVerdict iResult; |
|
100 TInt iRunCount; |
|
101 CAuthExpression* iAe; |
|
102 CIdentity* iId; |
|
103 TBool iStop; |
|
104 TInt iErr; |
|
105 TPluginId pluginIdVal; |
|
106 TInt iFresh; |
|
107 }; |
|
108 */ |
|
109 //==================================================================================================== |
|
110 CTRemoveIdentity::CTRemoveIdentity(CTAuthSvrServer& aParent): iParent(aParent) |
|
111 /** |
|
112 * Constructor |
|
113 */ |
|
114 { |
|
115 // Call base class method to set up the human readable name for logging |
|
116 SetTestStepName(KTRemoveIdentity); |
|
117 } |
|
118 |
|
119 CTRemoveIdentity::~CTRemoveIdentity() |
|
120 /** |
|
121 * Destructor |
|
122 */ |
|
123 {} |
|
124 |
|
125 TVerdict CTRemoveIdentity::doTestStepPreambleL() |
|
126 /** |
|
127 * @return - TVerdict code |
|
128 * Override of base class virtual |
|
129 */ |
|
130 { |
|
131 //Call the parent class preamble, setting up the file server, etc |
|
132 CTStepActSch::doTestStepPreambleL(); |
|
133 |
|
134 //SetTestStepResult(EPass); |
|
135 return TestStepResult(); |
|
136 } |
|
137 |
|
138 TVerdict CTRemoveIdentity::doTestStepL() |
|
139 /** |
|
140 * @return - TVerdict code |
|
141 * Override of base class pure virtual |
|
142 * |
|
143 */ |
|
144 { |
|
145 //INFO_PRINTF1(_L("In CTRemoveIdentity doTestStepL")); |
|
146 |
|
147 //User::SetJustInTime(ETrue); //a panic will kill just the thread, not the whole emulator. |
|
148 |
|
149 //If any test step leaves or panics, the test step thread won't exit, further calls are made. |
|
150 // but the html log is updated, so that subsequent failures could be traced here if necessary. |
|
151 if (TestStepResult() != EPass) |
|
152 { |
|
153 ERR_PRINTF1(_L("There was an error in a previous test step")); |
|
154 //return TestStepResult(); |
|
155 } |
|
156 |
|
157 SetTestStepResult(EPass); |
|
158 |
|
159 __UHEAP_MARK; // Check for memory leaks |
|
160 |
|
161 //----------------------------------------------------------------------------------------------------- |
|
162 InitAuthServerFromFileL(); // Set things like 'iSupportsDefaultData' and 'DefaultPlugin' |
|
163 |
|
164 CActiveScheduler::Install(iActSchd); |
|
165 //Connect to the AuthServer |
|
166 AuthServer::RAuthMgrClient authMgrClient1; |
|
167 TInt connectVal = authMgrClient1.Connect(); |
|
168 if (KErrNotFound == connectVal) |
|
169 { |
|
170 //Retry after a delay |
|
171 TTimeIntervalMicroSeconds32 timeInterval = 2000; //2 Milliseconds |
|
172 User::After(timeInterval); |
|
173 connectVal = authMgrClient1.Connect(); |
|
174 } |
|
175 if (KErrNone != connectVal) |
|
176 { |
|
177 ERR_PRINTF2(_L("Unable to start a session or other connection error. Err = %d"), connectVal); |
|
178 User::LeaveIfError(connectVal); |
|
179 } |
|
180 |
|
181 CleanupClosePushL(authMgrClient1); |
|
182 //----------------------------------------------------------------------------------------------------- |
|
183 /* |
|
184 //Examine the authserver and see what's there |
|
185 RAuthClient ac; |
|
186 User::LeaveIfError(ac.Connect()); |
|
187 CleanupClosePushL(ac); |
|
188 RPluginDescriptions pluginList1; |
|
189 TCleanupItem cleanup(CleanupEComArray, &pluginList1); |
|
190 CleanupStack::PushL(cleanup); |
|
191 |
|
192 ac.PluginsL(pluginList1); |
|
193 TInt numTotalPlugins = pluginList1.Count(); |
|
194 for(TInt i = 0; i < numTotalPlugins; i++) |
|
195 { |
|
196 TInt presentPluginIdVal = pluginList1[i]->Id(); |
|
197 TInt presentPluginStatus = pluginList1[i]->TrainingStatus(); |
|
198 INFO_PRINTF3(_L("PluginId=%x,status =%i"), presentPluginIdVal,presentPluginStatus); |
|
199 } |
|
200 CleanupStack::PopAndDestroy(&pluginList1); //infoArray, results in a call to CleanupEComArray |
|
201 |
|
202 //Check the username of the second identity and then attempt to set it. |
|
203 //SetTestStepResult(checkAndSetUserNameL(ac, 0)); |
|
204 |
|
205 CleanupStack::PopAndDestroy(&ac); // authClient |
|
206 //----------------------------------------------------------------------------------------------------- |
|
207 */ |
|
208 |
|
209 TBool statusAll = EFalse; |
|
210 statusAll = CheckPluginStatusAllL(authMgrClient1); |
|
211 |
|
212 // Authenticate by reading the user input |
|
213 // Then call the removeIdentityL function |
|
214 |
|
215 TRAPD(res2, doRemoveIdentityL(authMgrClient1) ); |
|
216 if(KErrNone != res2) |
|
217 { |
|
218 ERR_PRINTF2(_L("doRemoveIdentityL() performed a Leave with code %d"), res2 ); |
|
219 //SetTestStepResult(EPass); |
|
220 SetTestStepError(res2); |
|
221 } |
|
222 |
|
223 /* |
|
224 TRAPD(res1, CheckSpecifiedPluginStatusL()); |
|
225 if(KErrNone != res1) |
|
226 { |
|
227 ERR_PRINTF2(_L("checkSpecifiedPluginStatusL() performed a Leave with code %d"), res1 ); |
|
228 } |
|
229 */ |
|
230 |
|
231 statusAll = CheckPluginStatusAllL(authMgrClient1); |
|
232 if (!statusAll) |
|
233 { |
|
234 SetTestStepResult(EFail); |
|
235 } |
|
236 else |
|
237 { |
|
238 INFO_PRINTF1(_L("Plugin Status OK !!")); |
|
239 } |
|
240 |
|
241 CleanupStack::PopAndDestroy(&authMgrClient1); // authClient1 |
|
242 //Garbage collect the last previously destroyed implementation |
|
243 // and close the REComSession if no longer in use |
|
244 REComSession::FinalClose(); |
|
245 __UHEAP_MARKEND; |
|
246 return TestStepResult(); |
|
247 } |
|
248 |
|
249 |
|
250 TVerdict CTRemoveIdentity::doTestStepPostambleL() |
|
251 /** |
|
252 * @return - TVerdict code |
|
253 * Override of base class virtual |
|
254 */ |
|
255 { |
|
256 //Call the parent postamble, releasing the file handle, etc |
|
257 CTStepActSch::doTestStepPostambleL(); |
|
258 //INFO_PRINTF1(_L("Test Step Postamble")); |
|
259 return TestStepResult(); |
|
260 } |
|
261 |
|
262 |
|
263 // |
|
264 // |
|
265 void CTRemoveIdentity::doRemoveIdentityL (RAuthMgrClient& mgc) |
|
266 { |
|
267 |
|
268 //If the pluginId is quoted in the ini file, check it's training status |
|
269 TInt plugin1IdValue = 0; |
|
270 if (GetHexFromConfig(ConfigSection(),_L("plugin1Id"), plugin1IdValue) != EFalse) // the tag 'pluginId1' was present |
|
271 { |
|
272 //Read the identityId to be trained |
|
273 TIdentityId idToRemove = getLastAuthId(); |
|
274 |
|
275 mgc.RemoveIdentityL(idToRemove); |
|
276 |
|
277 //Check to see if a retry is recommended |
|
278 TBool retryRemoveValue = EFalse; |
|
279 if (GetBoolFromConfig(ConfigSection(),_L("retryRemove"), retryRemoveValue) != EFalse) |
|
280 { |
|
281 if (retryRemoveValue) |
|
282 { mgc.RemoveIdentityL(idToRemove); } |
|
283 } |
|
284 } |
|
285 |
|
286 else |
|
287 { |
|
288 INFO_PRINTF1(_L("plugin1Id was not specified in the ini file")); |
|
289 } |
|
290 |
|
291 } |
|