|
1 /* |
|
2 * Copyright (c) 2006-2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 // INCLUDE FILES |
|
29 #include "wsstartrustclient.h" |
|
30 |
|
31 #include <s32mem.h> |
|
32 #include <f32file.h> |
|
33 #include <s32file.h> |
|
34 #include <SenXmlUtils.h> |
|
35 #include "sencryptoutils.h" |
|
36 |
|
37 #include "wsstarservicesession.h" |
|
38 #include "SenXmlUtils.h" |
|
39 #include "msencoreservicemanager.h" |
|
40 #include "sendebug.h" |
|
41 #include "senlogger.h" |
|
42 #include "MSenServiceDescription.h" |
|
43 #include "senlogger.h" |
|
44 #include "SenServiceConnection.h" |
|
45 #include "seninternalserviceconsumer.h" |
|
46 #include "wsstarrstresponse.h" |
|
47 #include <SenCredential.h> |
|
48 #include "wsstarpolicy.h" |
|
49 #include "wsstarplugin.h" |
|
50 #include <SenTransportProperties.h> |
|
51 #include "senwspattern.h" |
|
52 |
|
53 using namespace WSTrust; |
|
54 using namespace WSPolicy; |
|
55 |
|
56 _LIT8(KRemoteConsumer, "RemoteConsumer"); |
|
57 |
|
58 //--------------------------------------------------------------------------- |
|
59 // Creates and returns a new instace of this class. |
|
60 //--------------------------------------------------------------------------- |
|
61 // |
|
62 CWSStarTrustClient* CWSStarTrustClient::NewL( |
|
63 CSIF& aSIF, |
|
64 RFileLogger& aLogger) |
|
65 { |
|
66 CWSStarTrustClient* pNew = NewLC(aSIF, aLogger); |
|
67 CleanupStack::Pop(pNew); |
|
68 return pNew; |
|
69 } |
|
70 |
|
71 //--------------------------------------------------------------------------- |
|
72 // Creates and returns a new instace of this class and leaves the object on the cleanup stack |
|
73 //--------------------------------------------------------------------------- |
|
74 // |
|
75 CWSStarTrustClient* CWSStarTrustClient::NewLC( |
|
76 CSIF& aSIF, |
|
77 RFileLogger& aLogger) |
|
78 { |
|
79 CWSStarTrustClient* pNew = |
|
80 new (ELeave) CWSStarTrustClient( |
|
81 aSIF, |
|
82 MSenServiceDescription::EWSStarSTSClient, |
|
83 aLogger); |
|
84 |
|
85 CleanupStack::PushL(pNew); |
|
86 pNew->BaseConstructL(); |
|
87 return pNew; |
|
88 } |
|
89 |
|
90 //--------------------------------------------------------------------------- |
|
91 // Constructor |
|
92 //--------------------------------------------------------------------------- |
|
93 // |
|
94 CWSStarTrustClient::CWSStarTrustClient( |
|
95 CSIF& aSIF, |
|
96 TDescriptionClassType aType, |
|
97 RFileLogger& aLogger) |
|
98 : CSenInternalServiceConsumer(aType, aSIF), |
|
99 iLog(aLogger) |
|
100 { |
|
101 } |
|
102 |
|
103 void CWSStarTrustClient::BaseConstructL() |
|
104 { |
|
105 CSenInternalServiceConsumer::ConstructL(); |
|
106 iTpCounter = 0; |
|
107 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarTrustClient::ConstructL()"))); |
|
108 } |
|
109 |
|
110 //--------------------------------------------------------------------------- |
|
111 // Destructor |
|
112 //--------------------------------------------------------------------------- |
|
113 // |
|
114 CWSStarTrustClient::~CWSStarTrustClient() |
|
115 { |
|
116 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::~CWSStarTrustClient"); |
|
117 delete iSTSSession; |
|
118 delete iEntropyClient; |
|
119 delete iAppliesTo; |
|
120 delete ipTransport; |
|
121 delete iTokenType; |
|
122 delete iSTSOrginalEndpoint; |
|
123 } |
|
124 |
|
125 |
|
126 //--------------------------------------------------------------------------- |
|
127 // The most siginificant method of this class. Make validation of session, |
|
128 // credentails obtained if needed. |
|
129 // Sequential logic, synchronized, step bye SOAP exchange scenrio. |
|
130 //--------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CWSStarTrustClient::ValidateL( CWSStarServiceSession& aSession, |
|
133 TBool aRenewing, |
|
134 HBufC8*& aErrorMessage, |
|
135 TBool aOnlySharing ) |
|
136 { |
|
137 iSTSSession->CompleteServerMessagesOnOffL(ETrue); |
|
138 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL(..)"); |
|
139 TInt retVal(KErrNone); // for returning error codes |
|
140 iWSStarServiceSession = &aSession; // save session |
|
141 |
|
142 //---------------------- |
|
143 //0 token sharing |
|
144 //---------------------- |
|
145 TBool sharingSucceed = EFalse; |
|
146 HBufC8* clusterUsed = CWSStarPolicy::GetPolicyValueL(KIssuedToken, KRPSCluster, *iHndCtx, iSTSSession); |
|
147 CleanupStack::PushL(clusterUsed); |
|
148 |
|
149 //its mean - if our provider uses cluster template, |
|
150 //so we can try copy MT and SCT form other msn services which use same provider ID |
|
151 if (clusterUsed) |
|
152 { |
|
153 RPointerArray<CSenWSDescription> msnSDs; |
|
154 CleanupClosePushL(msnSDs); |
|
155 CSenWSPattern* pattern = CSenWSPattern::NewLC(); |
|
156 |
|
157 //select * from session_of_SD where session is (ws* framework, and has same provideId) |
|
158 //here we assume that provider use cluster template |
|
159 |
|
160 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
161 pattern->AsElement().AddElementL(KSenIdpProviderIdLocalname).SetContentL(iIdentityProvider->ProviderID()); |
|
162 //pattern->AsElement().AddElementL(WSStarSession::KProviderIdElementLocalName).SetContentL(iIdentityProvider->ProviderID()); |
|
163 //seeking |
|
164 CWSStarServiceSession* msnSession = NULL; |
|
165 TRAPD(leaveError, retVal = Framework().Manager().ServiceDescriptionsL(msnSDs, *pattern)); |
|
166 if(!retVal && !leaveError) |
|
167 { |
|
168 TInt count = msnSDs.Count(); |
|
169 TBool pMTwasReplaceBySCT = EFalse; |
|
170 TBool seekSCT = EFalse; |
|
171 for(TInt i = 0; i < msnSDs.Count(); i++) |
|
172 { |
|
173 //all sessions (so in practice we have also access to SCT, not only MT), |
|
174 // to eliminate client, just for case we check type |
|
175 TDescriptionClassType dt = msnSDs[i]->DescriptionClassType(); |
|
176 if (dt == MSenServiceDescription::EWSStarServiceSession) |
|
177 { |
|
178 msnSession = (CWSStarServiceSession*)msnSDs[i]; |
|
179 //dont share to itself |
|
180 if (msnSession != iWSStarServiceSession) |
|
181 { |
|
182 TRAPD(err, retVal = msnSession->ShareTokenWithL( |
|
183 iWSStarServiceSession, pMTwasReplaceBySCT, |
|
184 seekSCT)); |
|
185 if ((retVal == KErrNone) && (err == KErrNone)) |
|
186 { |
|
187 sharingSucceed = ETrue; |
|
188 if (pMTwasReplaceBySCT) |
|
189 { |
|
190 break; |
|
191 } |
|
192 else |
|
193 { |
|
194 seekSCT = ETrue;//in order to find other session which can have additioanly SCT |
|
195 } |
|
196 } |
|
197 } |
|
198 } |
|
199 } |
|
200 if ( !pMTwasReplaceBySCT && !sharingSucceed ) |
|
201 { |
|
202 // Did not find valid MT (<=> sharingSucceed == EFalse) |
|
203 // AND did not find valid SCT (<=> pMTwasReplaceBySCT == EFalse) |
|
204 // |
|
205 // Try to search valid MT directly from CredentialManager |
|
206 // (This is needed especially in case when MT is imported |
|
207 // through Public API |
|
208 // => There is not yet Session which holds imported MT) |
|
209 if ( iWSStarServiceSession->TryToSearchValidCredentialL() == KErrNone ) //codescannerwarnings |
|
210 { |
|
211 iWSStarServiceSession->SetStatusL(); |
|
212 iWSStarServiceSession->AddSecurityTokenToContextL(); |
|
213 sharingSucceed = ETrue; |
|
214 } |
|
215 } |
|
216 } |
|
217 CleanupStack::PopAndDestroy(2, &msnSDs); |
|
218 } |
|
219 CleanupStack::PopAndDestroy(clusterUsed); |
|
220 |
|
221 if (sharingSucceed) |
|
222 { |
|
223 iWSStarServiceSession->SetTrustAnchorL(iIdentityProvider->ProviderID()); |
|
224 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL(..) - sharing succed, we don't need more validation"); |
|
225 return KErrNone; |
|
226 } |
|
227 if (aOnlySharing) |
|
228 { |
|
229 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL(..) - only sharing was allowed so NO continuation"); |
|
230 return KErrNone; |
|
231 } |
|
232 |
|
233 |
|
234 //----------------- |
|
235 //1 Init session |
|
236 //----------------- |
|
237 |
|
238 if (!iSTSSession)// if trustClient has NOT been registered earlier |
|
239 { |
|
240 iSTSSession = CWSStarServiceSession::NewL(Framework()); |
|
241 iSTSSession->InitializeFromL(*this); |
|
242 iSTSSession->SetEndPointL(iIdentityProvider->Endpoint()); |
|
243 iSTSSession->SetContractL(KWSStarSTSContract); |
|
244 iSTSSession->AddConsumerL(*this); |
|
245 } |
|
246 CSenXmlReader* reader = Framework().Manager().XMLReader(); |
|
247 CWSStarSessionContext* stsSsnContext = iSTSSession->SessionContext(); |
|
248 iPassportMode = CWSStarPolicy::CheckPolicyValueL(KPassportExtensions, iSTSSession); |
|
249 if (iPassportMode) |
|
250 { |
|
251 stsSsnContext->Update(WSStarContextKeys::KPassportEnabled, ETrue); |
|
252 aRenewing = FALSE; //MS passport doesn't support renewing binding. So we force here issue binding |
|
253 } |
|
254 iRenewingMode = aRenewing; |
|
255 |
|
256 //----------------- |
|
257 //2.preparing context |
|
258 //-----------------------WS-TRUST 2005-02 chapter 6 - RST issue------------------------- |
|
259 stsSsnContext->Update(WSStarContextKeys::KAction, GetAction()); |
|
260 |
|
261 TInt retryCounter(0); |
|
262 TBool retry(ETrue); |
|
263 TBool authenticationInfoPromptedFromUser(EFalse); |
|
264 TPckgBuf<TSenAuthentication> authInfo; |
|
265 HBufC8* responseXML = NULL; |
|
266 HBufC8* pBodyXML = NULL; |
|
267 MSenRemoteServiceConsumer* pConsumer = NULL; |
|
268 |
|
269 while ( retry ) // Authentication loop starts |
|
270 { |
|
271 retry = EFalse; |
|
272 |
|
273 //setting secure profile of authentication with sts, can X509, so in future some factory calling |
|
274 if (CWSStarPolicy::CheckPolicyValueL(KUsernameTokenOverTLS, iSTSSession)) |
|
275 { |
|
276 HBufC8* token = NULL; |
|
277 if ( authenticationInfoPromptedFromUser ) |
|
278 { |
|
279 CSenWsSecurityHeader::UsernameTokenL(authInfo().iUsername, |
|
280 authInfo().iPassword, |
|
281 token); |
|
282 } |
|
283 else |
|
284 { |
|
285 CSenWsSecurityHeader::UsernameTokenL(iIdentityProvider->UserName(), |
|
286 iIdentityProvider->Password(), |
|
287 token); |
|
288 } |
|
289 stsSsnContext->Update(WSStarContextKeys::KSecurityToken, *token); |
|
290 delete token; |
|
291 token = NULL; |
|
292 } |
|
293 |
|
294 //building body |
|
295 CWSStarPlugin& frmWSStar = (CWSStarPlugin&)Framework(); |
|
296 CSenElement* pBody = CreateBodyL(); |
|
297 stsSsnContext->Update(WSStarContextKeys::KBodyElement, pBody); |
|
298 pBodyXML = pBody->AsXmlL(); |
|
299 CleanupStack::PushL(pBodyXML); |
|
300 //----------------- |
|
301 //_____________________________________SYNC Sending____________________________________________ |
|
302 |
|
303 CSenTransportProperties* transProp = CSenTransportProperties::NewLC(); |
|
304 const TDesC8* value =stsSsnContext->GetDesC8L(WSStarContextKeys::KAction); |
|
305 if(value) |
|
306 transProp->SetSoapActionL(*value); |
|
307 |
|
308 // IAP dialog used to appear though IAP id is provided as a part of Service Description |
|
309 // Get the IAP setting and accordingly set the transport properties |
|
310 TUint32 id = 0; |
|
311 TInt getIapRetCode = IapId(id); |
|
312 |
|
313 ; |
|
314 // Check whether IAP ID is pre-defined, and copy it only if such property value is found |
|
315 //if ( getIapRetCode == KErrNone && id < 4294967295) // unsigned 4294967295 == -1 signed |
|
316 if ( getIapRetCode == KErrNone && id < (TUint32)KErrNotFound) // unsigned 4294967295 == -1 signed |
|
317 { |
|
318 transProp->SetIapIdL(id); |
|
319 } |
|
320 // ETMI-6WAGDB end |
|
321 |
|
322 //limit http timeout, |
|
323 // if sts hangs and can not send any response, then we block every async client method. |
|
324 // Possibel revalidation during sendL can take too long time therefore we create new limit |
|
325 transProp->SetMaxTimeToLiveL(WSStarSession::KMaxHttpTimeOut); |
|
326 |
|
327 HBufC8* transPropAsXml = transProp->AsUtf8LC(); |
|
328 /* |
|
329 if( iWSStarServiceSession ) |
|
330 { |
|
331 iWSStarServiceSession->SendStatusToConsumerL( KSenStatusAuthentication ); |
|
332 } |
|
333 */ |
|
334 //overwrite passport endpoint (provided by GUI) by endpoint provided by policy |
|
335 AdaptStsEndpointL(); //codescannerwarnings |
|
336 iTpCounter++; |
|
337 retVal = iSTSSession->SubmitL(*pBodyXML, *transPropAsXml, *this, responseXML); |
|
338 iTpCounter--; |
|
339 CWSStarSessionContext* pSessionCtxt = iWSStarServiceSession->SessionContext();// redundant code |
|
340 TAny* ptr = pSessionCtxt->GetAnyL(KRemoteConsumer()); //codescannerwarnings |
|
341 if ( ptr ) |
|
342 { |
|
343 pConsumer = REINTERPRET_CAST(MSenRemoteServiceConsumer*, ptr); |
|
344 } |
|
345 else |
|
346 { |
|
347 pConsumer = iWSStarServiceSession->Consumer(); |
|
348 } |
|
349 |
|
350 pConsumer->SetDataTrafficDetails(iTrustDetails); |
|
351 AdaptStsEndpointL(ETrue); |
|
352 CleanupStack::PopAndDestroy(transPropAsXml); |
|
353 CleanupStack::PopAndDestroy(transProp); |
|
354 CleanupStack::PopAndDestroy(pBodyXML); |
|
355 |
|
356 CleanupStack::PushL(responseXML); |
|
357 |
|
358 if ( retVal == KErrSenSoapFault ) |
|
359 { |
|
360 //CREDLOG_L(KSenCredsLogLevelNormal,".......failed (SOAP Fault)"); |
|
361 CWSStarSessionContext* pSessionContext = iWSStarServiceSession->SessionContext(); |
|
362 TAny* ptr = pSessionContext->GetAnyL(KRemoteConsumer()); //codescannerwarnings |
|
363 if ( ptr ) |
|
364 { |
|
365 pConsumer = REINTERPRET_CAST(MSenRemoteServiceConsumer*, ptr); |
|
366 } |
|
367 else |
|
368 { |
|
369 pConsumer = iWSStarServiceSession->Consumer(); |
|
370 } |
|
371 |
|
372 if ( pConsumer && !pConsumer->HasAuthenticationCallback() && |
|
373 retryCounter < 3 ) |
|
374 { |
|
375 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - Consumer does not have AuthenticationCallback"); |
|
376 |
|
377 const TDesC8* pValue = iIdentityProvider->AsElement().AttrValue( KSenAttrPromptUserInfo ); |
|
378 |
|
379 #ifdef _RD_SEN_WS_STAR_DO_NOT_PROMPT_AUTHINFO_BY_DEFAULT |
|
380 if ( pValue && *pValue != _L8("false") ) |
|
381 // attribute has to exist, otherwise logic defaults to: DO NOT PROMPT |
|
382 #else |
|
383 if ( !pValue || *pValue != _L8("false") ) |
|
384 // even when attribute does NOT exist, or when it does and has any other value but "false", default to: PROMPT |
|
385 #endif |
|
386 { |
|
387 const TBool* renewingPtr = stsSsnContext->GetIntL(WSStarContextKeys::KReAuthNeeded); |
|
388 if ( renewingPtr ) |
|
389 { |
|
390 if ( *renewingPtr ) |
|
391 { |
|
392 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"- Prompt is used to get AuthenticationInfo"); |
|
393 TInt ret = (Framework().Manager()).AuthenticationForL(*iIdentityProvider, |
|
394 authInfo); |
|
395 if ( ret == KErrNone ) |
|
396 { |
|
397 retryCounter++; |
|
398 retry = ETrue; |
|
399 authenticationInfoPromptedFromUser = ETrue; |
|
400 } |
|
401 } |
|
402 } |
|
403 } |
|
404 else |
|
405 { |
|
406 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::ValidateL - promptUserInfo = false"); |
|
407 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel," => prompt is not used."); |
|
408 } |
|
409 } |
|
410 if ( pConsumer && pConsumer->HasAuthenticationCallback() && |
|
411 retryCounter < 3 ) |
|
412 { |
|
413 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::ValidateL - Consumer has AuthenticationCallback"); |
|
414 |
|
415 const TDesC8* pValue = iIdentityProvider->AsElement().AttrValue( KSenAttrPromptUserInfo ); |
|
416 |
|
417 if ( !pValue || *pValue != _L8("false") ) |
|
418 { |
|
419 const TBool* renewingPtr = stsSsnContext->GetIntL(WSStarContextKeys::KReAuthNeeded); |
|
420 if ( renewingPtr && *renewingPtr ) |
|
421 { |
|
422 const TBool* renewingByCredObserv = iWSStarServiceSession->SessionContext()->GetIntL(WSStarContextKeys::KReAuthNeededFromCredObserv); |
|
423 if( renewingByCredObserv != NULL && *renewingByCredObserv ) |
|
424 { |
|
425 // Credential Observer -> call reauthenticatino through connection agent |
|
426 CSenIdentityProvider* newIdP = iIdentityProvider; |
|
427 TRAPD(error, retVal = pConsumer->ReauthenticationNeededL(newIdP)); |
|
428 if(error == KErrNone && retVal == KErrNone) |
|
429 { |
|
430 // Update identity provider in case old one got corrupted |
|
431 iIdentityProvider = newIdP; |
|
432 retryCounter++; |
|
433 retry = ETrue; |
|
434 } |
|
435 else |
|
436 { |
|
437 retVal = KErrSenFailedAuthentication; |
|
438 } |
|
439 } |
|
440 else |
|
441 { |
|
442 retVal = KErrSenFailedAuthentication; |
|
443 } |
|
444 } |
|
445 } |
|
446 else |
|
447 { |
|
448 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::ValidateL - UserInfoPrompt = false"); |
|
449 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel," => AuthenticationCallback is not used."); |
|
450 } |
|
451 |
|
452 } |
|
453 } |
|
454 |
|
455 if ( retry ) |
|
456 { |
|
457 CleanupStack::PopAndDestroy(responseXML); |
|
458 } |
|
459 } // Authentication loop ends |
|
460 |
|
461 if (!retVal) |
|
462 { |
|
463 const TDesC8* responseAction = stsSsnContext->GetDesC8L(WSStarContextKeys::KResponseAction); |
|
464 if (responseAction && |
|
465 responseAction->Length()) |
|
466 { |
|
467 if (*responseAction != GetActionResponse()) |
|
468 { |
|
469 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::ValidateL - wrong action in response"); |
|
470 |
|
471 retVal = KErrNotFound; |
|
472 //no ws-trust specifiv fault defined for invalid RESPONSE. I can only answer iwth addressign fault |
|
473 //but no access to addressing handler directly |
|
474 } |
|
475 } |
|
476 } |
|
477 if (retVal != KErrNone) |
|
478 { |
|
479 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarTrustClient::ValidateL - error when submit to STS %d"), retVal)); |
|
480 |
|
481 if (responseXML) |
|
482 { |
|
483 aErrorMessage = responseXML; |
|
484 } |
|
485 |
|
486 CleanupStack::Pop(responseXML); |
|
487 if (! iTpCounter) |
|
488 { |
|
489 //we don't have to keep transport. Important expecially during night test, |
|
490 // when transport and its RConnection exceed idle timeout |
|
491 delete ipTransport; |
|
492 ipTransport = NULL; |
|
493 } |
|
494 return retVal; |
|
495 } |
|
496 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - response from STS is a valid SOAP"); |
|
497 #ifdef RD_SEN_VTCP_SUPPORT |
|
498 //#ifdef RD_SEN_CO_BRAND_SUPPORT |
|
499 //stsSsnContext->Update(WSStarContextKeys::KBrandIDEnabled, EFalse); |
|
500 const TDesC8* mainBrandID = stsSsnContext->GetDesC8L(WSStarContextKeys::KMainBrandID); |
|
501 if (mainBrandID && mainBrandID->Length()) |
|
502 { |
|
503 if(iPassportMode) |
|
504 { |
|
505 //Call Back Consumer |
|
506 CWSStarSessionContext* pSessionContext = iWSStarServiceSession->SessionContext(); |
|
507 TAny* ptr = pSessionContext->GetAnyL(KRemoteConsumer()); //codescannerwarnings |
|
508 if ( ptr ) |
|
509 { |
|
510 pConsumer = REINTERPRET_CAST(MSenRemoteServiceConsumer*, ptr); |
|
511 } |
|
512 else |
|
513 { |
|
514 pConsumer = iWSStarServiceSession->Consumer(); |
|
515 } |
|
516 |
|
517 if ( pConsumer && pConsumer->HasCoBrandingCallback() ) |
|
518 { |
|
519 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::HasCoBrandingCallback"); |
|
520 const TDesC8* brandIDList = stsSsnContext->GetDesC8L(WSStarContextKeys::KBrandIDList); |
|
521 |
|
522 RBuf8 selectedBrandId; |
|
523 //User will reply with go/no go optoin |
|
524 if(pConsumer->OnGetBrandIdL(*brandIDList,selectedBrandId)) |
|
525 { |
|
526 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::Brand ID Is Enabled"); |
|
527 // co-branding - Add co branding details in context |
|
528 stsSsnContext->Update(WSStarContextKeys::KBrandIDEnabled, ETrue); |
|
529 } |
|
530 else |
|
531 { |
|
532 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarTrustClient::Brand ID Is Disabled"); |
|
533 // co-branding - Add co branding details in context |
|
534 stsSsnContext->Update(WSStarContextKeys::KBrandIDEnabled, EFalse); |
|
535 } |
|
536 |
|
537 } |
|
538 |
|
539 } |
|
540 } |
|
541 |
|
542 TBool cacheToken = ETrue; |
|
543 const TBool* brandID = stsSsnContext->GetIntL(WSStarContextKeys::KBrandIDEnabled); |
|
544 if(brandID && !(*brandID)) |
|
545 { |
|
546 cacheToken = EFalse; |
|
547 retVal = KErrSenBrandNotSupported; |
|
548 } |
|
549 |
|
550 if(cacheToken) |
|
551 { |
|
552 //#endif//RD_SEN_CO_BRAND_SUPPORT |
|
553 #endif//RD_SEN_VTCP_SUPPORT |
|
554 //----------------- |
|
555 //4 building response |
|
556 //----------------- |
|
557 CWSStarRSTResponse* rstResponse = CWSStarRSTResponse::NewLC(FALSE, *iAppliesTo, iVersion); |
|
558 rstResponse->SetPolicyVersion(&GetPolicyNs()); |
|
559 rstResponse->UpdateAddressingHoldersL(*stsSsnContext); |
|
560 rstResponse->SetReader(*Framework().Manager().XMLReader()); |
|
561 //shouldnt be error, parsing is done earlier by core so we can be sure, that it is valid SOAP XML |
|
562 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - building RSTResponse"); |
|
563 rstResponse->BuildFrom(*responseXML); |
|
564 |
|
565 if (! iWSStarServiceSession->ExistConsumerL()) |
|
566 { |
|
567 retVal = KErrNotFound; |
|
568 } |
|
569 else |
|
570 { |
|
571 iWSStarServiceSession->SetTrustAnchorL(iIdentityProvider->ProviderID()); |
|
572 if (rstResponse->IsResponse()) |
|
573 { |
|
574 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - set ctx basing on RSTR"); |
|
575 //const TBool* brandID = stsSsnContext->GetIntL(WSStarContextKeys::KBrandIDEnabled); |
|
576 TBool isWAPExists = CWSStarPolicy::CheckPolicyValueL(WSStarContextKeys::KWAPGW, iSTSSession); |
|
577 #ifdef RD_SEN_VTCP_SUPPORT |
|
578 //#ifdef RD_SEN_CO_BRAND_SUPPORT |
|
579 if(isWAPExists && (brandID && *brandID)) |
|
580 #else |
|
581 if(isWAPExists) |
|
582 //#endif//RD_SEN_CO_BRAND_SUPPORT |
|
583 #endif//RD_SEN_VTCP_SUPPORT |
|
584 { |
|
585 retVal = iWSStarServiceSession->SessionContext()->SetTokenKeysL( |
|
586 *rstResponse, iEntropyClient,EFalse); |
|
587 } |
|
588 else |
|
589 { |
|
590 retVal = iWSStarServiceSession->SessionContext()->SetTokenKeysL( |
|
591 *rstResponse, iEntropyClient,ETrue); |
|
592 } |
|
593 iWSStarServiceSession->ActiveTicketObserverL(); |
|
594 //SetTokenKeys call indirectly SetStatus in order to signal session's consumers that connection is ready for sending |
|
595 if (retVal) |
|
596 { |
|
597 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - response from STS is wrong RSTR, maybe some nested Fault"); |
|
598 //CREDLOG_L(KSenCredsLogLevelNormal,".......failed, problem with RSTR analizing"); |
|
599 aErrorMessage = responseXML; |
|
600 if (retVal == KErrNotFound) |
|
601 { |
|
602 retVal = KErrSenSoapFault; |
|
603 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel," ------- returning SOAP Fault for MS and clearing the credential if any"); |
|
604 iWSStarServiceSession->DetachCredentialsL(); |
|
605 } |
|
606 } |
|
607 /*else |
|
608 { |
|
609 #ifdef _SENDEBUG |
|
610 _LIT8(KCredsLogLine, "...Token has been issued (period = %S - %S)"); |
|
611 CREDLOG_FORMAT((KSenCredsLogChannel, KSenCredsLogLevelNormal, KCredsLogLine, &(rstResponse->CredentialCreated()), &(rstResponse->CredentialExpires()))); |
|
612 #endif |
|
613 }*/ |
|
614 } |
|
615 else |
|
616 { |
|
617 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::ValidateL - response from STS is not a proper RSTR"); |
|
618 aErrorMessage = responseXML; |
|
619 retVal = KErrNotFound; |
|
620 } |
|
621 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarTrustClient::ValidateL - building session Ctx: %d"), retVal)); |
|
622 } |
|
623 |
|
624 CleanupStack::PopAndDestroy(rstResponse); |
|
625 #ifdef RD_SEN_VTCP_SUPPORT |
|
626 //#ifdef RD_SEN_CO_BRAND_SUPPORT |
|
627 } |
|
628 //#endif//RD_SEN_CO_BRAND_SUPPORT |
|
629 #endif//RD_SEN_VTCP_SUPPORT |
|
630 if (!aErrorMessage) |
|
631 { |
|
632 CleanupStack::PopAndDestroy(responseXML); |
|
633 } |
|
634 else |
|
635 { |
|
636 CleanupStack::Pop(responseXML); |
|
637 } |
|
638 if (! iTpCounter) |
|
639 { |
|
640 delete ipTransport; |
|
641 ipTransport = NULL; |
|
642 } |
|
643 return retVal; |
|
644 } |
|
645 |
|
646 |
|
647 |
|
648 //--------------------------------------------------------------------------- |
|
649 // SetStatus |
|
650 //--------------------------------------------------------------------------- |
|
651 // |
|
652 |
|
653 void CWSStarTrustClient::SetStatus(TInt /*aStatus */) |
|
654 { |
|
655 // No implementation in Java |
|
656 } |
|
657 |
|
658 //--------------------------------------------------------------------------- |
|
659 // SetAccount |
|
660 //--------------------------------------------------------------------------- |
|
661 // |
|
662 void CWSStarTrustClient::SetAccount( |
|
663 CSenIdentityProvider* aIdentityProvicer) |
|
664 { |
|
665 iIdentityProvider = aIdentityProvicer; |
|
666 } |
|
667 /*CSenIdentityProvider* CWSStarTrustClient::Account() |
|
668 { |
|
669 return iIdentityProvider; |
|
670 }*/ |
|
671 /*TInt CWSStarTrustClient::SetProviderIdL(const TDesC8& aProviderID) |
|
672 { |
|
673 HBufC8* pNew = NULL; |
|
674 if(aProviderID.Length()>0) |
|
675 { |
|
676 pNew = aProviderID.AllocL(); |
|
677 } |
|
678 delete ipProviderId; |
|
679 ipProviderId = pNew; |
|
680 return KErrNone; |
|
681 } |
|
682 TPtrC8 CWSStarTrustClient::ProviderId() |
|
683 { |
|
684 if(ipProviderId) |
|
685 return *ipProviderId; |
|
686 else |
|
687 return KNullDesC8(); |
|
688 }*/ |
|
689 |
|
690 //--------------------------------------------------------------------------- |
|
691 // ServiceSession |
|
692 //--------------------------------------------------------------------------- |
|
693 // |
|
694 CSenServiceSession* CWSStarTrustClient::ServiceSession() |
|
695 { |
|
696 return iWSStarServiceSession; |
|
697 } |
|
698 |
|
699 //--------------------------------------------------------------------------- |
|
700 // Obtain Transport using a factory from Core Manager |
|
701 //--------------------------------------------------------------------------- |
|
702 // |
|
703 MSenTransport& CWSStarTrustClient::TransportL() |
|
704 { |
|
705 if(!ipTransport) |
|
706 { |
|
707 // Core is capable of working as transport factory, too. |
|
708 // The returned transport instancies may or may not be |
|
709 // ECOM plugins: |
|
710 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::Instantiating new transport"); |
|
711 ipTransport = Framework().Manager().CreateL(*iSTSSession, iSTSSession); |
|
712 } |
|
713 return *ipTransport; |
|
714 } |
|
715 //--------------------------------------------------------------------------- |
|
716 // SetSTSSessionL |
|
717 //--------------------------------------------------------------------------- |
|
718 // |
|
719 void CWSStarTrustClient::SetSTSSessionL( |
|
720 CWSStarServiceSession* aSession) |
|
721 { |
|
722 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::SetServiceSessionL"); |
|
723 _LIT8(KTouch, "touch"); |
|
724 // free memory |
|
725 //delete iSTSSession; |
|
726 const TDesC8* attrValue = aSession->AsElement().AttrValue(KTouch); |
|
727 if(attrValue != NULL) |
|
728 { |
|
729 AsElement().AddAttrL(KTouch, *attrValue); |
|
730 } |
|
731 iSTSSession = aSession; |
|
732 if(iSTSSession) |
|
733 { |
|
734 iSTSSession->AddConsumerL(*this); |
|
735 } |
|
736 } |
|
737 |
|
738 CWSStarServiceSession* CWSStarTrustClient::GetSTSSessionL() |
|
739 { |
|
740 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::SetServiceSessionL"); |
|
741 if(iSTSSession) |
|
742 { |
|
743 return iSTSSession; |
|
744 } |
|
745 else |
|
746 { |
|
747 return NULL; |
|
748 } |
|
749 } |
|
750 //--------------------------------------------------------------------------- |
|
751 // Create body for STS request |
|
752 //--------------------------------------------------------------------------- |
|
753 // |
|
754 CSenElement* CWSStarTrustClient::CreateBodyL() |
|
755 { |
|
756 HBufC8* value = const_cast<HBufC8*>(CWSStarPolicy::GetPolicyValueL(KIssuedToken, KRPSCluster, *iHndCtx, iSTSSession)); |
|
757 CleanupStack::PushL(value); |
|
758 |
|
759 //----------------- |
|
760 //1 RST part (1st otken, proper one) |
|
761 //----------------- |
|
762 CSenElement* specificRST = NULL; |
|
763 if (value && iPassportMode) |
|
764 { |
|
765 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::CreateBodyL - found cluster"); |
|
766 delete iAppliesTo; |
|
767 iAppliesTo = NULL; |
|
768 iAppliesTo = value; |
|
769 specificRST = CreateRSTL(iRenewingMode, value->Des()); |
|
770 CleanupStack::Pop(value); |
|
771 value = NULL; |
|
772 } |
|
773 else |
|
774 { |
|
775 delete iAppliesTo; |
|
776 iAppliesTo = NULL; |
|
777 iAppliesTo = iWSStarServiceSession->Endpoint().AllocL(); |
|
778 specificRST = CreateRSTL(iRenewingMode, *iAppliesTo); |
|
779 CleanupStack::PopAndDestroy(value); |
|
780 //Renewing - check from policy |
|
781 //@Allow not specified, the default value is true. |
|
782 //@OK not specified, the default value is false. |
|
783 specificRST->AddElementL(*iVersion, KRenewingTag); |
|
784 } |
|
785 CleanupStack::PushL(specificRST); |
|
786 |
|
787 //----------------- |
|
788 //2 entropy |
|
789 //----------------- |
|
790 |
|
791 if (CWSStarPolicy::CheckPolicyValueL(KClientEntropy, iSTSSession)) |
|
792 { |
|
793 TRAPD(error, RandomEntropyClientL()); |
|
794 if (!error) |
|
795 { |
|
796 CSenElement& entrElement = specificRST->AddElementL(*iVersion, KEntropyTag); |
|
797 entrElement.AddElementL(*iVersion, KBinarySecretTag).SetContentL(*iEntropyClient); |
|
798 } |
|
799 } |
|
800 |
|
801 //----------------- |
|
802 //3 excluding dynamic RST by RST template |
|
803 //----------------- |
|
804 delete iTokenType; |
|
805 iTokenType = NULL; |
|
806 iTokenType = CWSStarPolicy::GetPolicyValueL(WSPolicy::KTokenType, iSTSSession); |
|
807 if (!iTokenType && iPassportMode) |
|
808 { |
|
809 iTokenType = WSPassport32::KDefaultTokenType().AllocL(); |
|
810 } |
|
811 |
|
812 |
|
813 RPointerArray<CSenElement> elements; |
|
814 if (iTokenType) |
|
815 { |
|
816 /*#ifdef _RD_SEN_ENABLE_CREDLOG |
|
817 _LIT8(KCredsLogLine, "Sending RST to STS to get new token (type %S)...."); |
|
818 CREDLOG_FORMAT((KSenCredsLogChannel, KSenCredsLogLevelNormal, KCredsLogLine, tokenType)); |
|
819 #endif */ |
|
820 value = CWSStarPolicy::GetPolicyValueL(*iTokenType, KIssuedToken, KRequestSecurityTokenTemplate, *iHndCtx, iSTSSession, elements); |
|
821 } |
|
822 else |
|
823 { |
|
824 value = CWSStarPolicy::GetPolicyValueL(KIssuedToken, KRequestSecurityTokenTemplate, *iHndCtx, iSTSSession, elements); |
|
825 } |
|
826 if (!value) |
|
827 { |
|
828 if (iTokenType) |
|
829 { |
|
830 specificRST->AddElementL(*iVersion, |
|
831 KTokenTypeTag).SetContentL(*iTokenType); |
|
832 } |
|
833 } |
|
834 else |
|
835 { |
|
836 TLSLOG_ALL(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,(*value));//in debug we dont have to push to cleanup stack |
|
837 delete value; |
|
838 value = NULL; |
|
839 CleanupStack::PopAndDestroy(specificRST); |
|
840 CSenDomFragment* domFrg = CSenDomFragment::NewL(*iVersion, |
|
841 KRSTTag, |
|
842 KRSTQTag); |
|
843 CleanupStack::PushL(domFrg); |
|
844 specificRST = domFrg->ExtractElement(); |
|
845 CleanupStack::PopAndDestroy(domFrg); |
|
846 CleanupStack::PushL(specificRST); |
|
847 |
|
848 for (TInt i = 0; i<elements.Count(); i++ ) |
|
849 { |
|
850 CSenDomFragment* rstTemplate = CSenDomFragment::NewL(*elements[i]); |
|
851 CSenElement* rstTemplateEl = rstTemplate->ExtractElement(); |
|
852 delete rstTemplate; |
|
853 rstTemplate = NULL; |
|
854 CleanupStack::PushL(rstTemplateEl); |
|
855 specificRST->AddElementL(*rstTemplateEl); |
|
856 CleanupStack::Pop(rstTemplateEl); |
|
857 } |
|
858 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::CreateBodyL - added template"); |
|
859 } |
|
860 |
|
861 |
|
862 //----------------- |
|
863 //4 add passport RST (redundant info, but passport requires that) |
|
864 // and enable multirequest |
|
865 //----------------- |
|
866 if (!iPassportMode) |
|
867 { |
|
868 CleanupStack::Pop(specificRST); |
|
869 return specificRST; |
|
870 } |
|
871 else |
|
872 { |
|
873 CSenElement* passportRST = CreateRSTL(EFalse, WSPassport32::KPassportAppliesTo()); |
|
874 CleanupStack::PushL(passportRST); |
|
875 CSenDomFragment* domFrg = CSenDomFragment::NewL(WSStarContextKeys::KMultiReqTagMark); |
|
876 CSenElement* reqMultiple = domFrg->ExtractElement(); |
|
877 delete domFrg; |
|
878 CleanupStack::PushL(reqMultiple); |
|
879 reqMultiple->AddElementL(*specificRST); |
|
880 reqMultiple->AddElementL(*passportRST); |
|
881 CleanupStack::Pop(3, specificRST); |
|
882 return reqMultiple; |
|
883 } |
|
884 } |
|
885 //--------------------------------------------------------------------------- |
|
886 // Create RST skeleton. |
|
887 //--------------------------------------------------------------------------- |
|
888 // |
|
889 CSenElement* CWSStarTrustClient::CreateRSTL(TBool aRenewing, TPtrC8 aAppliesTo) |
|
890 { |
|
891 //whole logic for RST factory |
|
892 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("CWSStarTrustClient::CreateRST - appliesTo: %S"), &aAppliesTo)); |
|
893 |
|
894 CSenDomFragment* domFrg = CSenDomFragment::NewL(*iVersion, |
|
895 KRSTTag, |
|
896 KRSTQTag); |
|
897 CSenElement* elementRst = domFrg->ExtractElement(); |
|
898 CleanupStack::PushL(elementRst); |
|
899 delete domFrg; |
|
900 domFrg = NULL; |
|
901 elementRst->AddElementL(*iVersion, KRequestTypeTag).SetContentL(GetRequestType()); |
|
902 |
|
903 //__________ISSUE |
|
904 if (!aRenewing) |
|
905 { |
|
906 CSenElement& applies = elementRst->AddElementL(GetPolicyNs(), |
|
907 KAppliesToTag, |
|
908 KAppliesToQTag); |
|
909 SenXmlUtils::AddAttributeL(applies, WSStarContextKeys::KAddressAttrMark, aAppliesTo); |
|
910 |
|
911 } |
|
912 //__________RENEW |
|
913 //in 7. Renewal Binding |
|
914 //Other extensions MAY be specified in the request (and the response), but the key |
|
915 //semantics (size, type, algorithms, scope, etc.) MUST NOT be altered during renewal. |
|
916 else |
|
917 { |
|
918 CSenElement& el = elementRst->AddElementL(*iVersion, KRenewTargetTag); |
|
919 const TDesC8* oldToken = iWSStarServiceSession->SessionContext()->GetDesC8L(WSStarContextKeys::KSecurityTokenBackup); |
|
920 if (oldToken) |
|
921 { |
|
922 el.SetContentL(*oldToken); |
|
923 } |
|
924 } |
|
925 CleanupStack::Pop(elementRst); |
|
926 return elementRst; |
|
927 } |
|
928 // End of file |
|
929 |
|
930 //--------------------------------------------------------------------------- |
|
931 // Getter for endpoint |
|
932 //--------------------------------------------------------------------------- |
|
933 // |
|
934 TPtrC8 CWSStarTrustClient::Endpoint() |
|
935 { |
|
936 return iSTSSession->Endpoint(); |
|
937 } |
|
938 //--------------------------------------------------------------------------- |
|
939 // Getter for contract |
|
940 //--------------------------------------------------------------------------- |
|
941 // |
|
942 TPtrC8 CWSStarTrustClient::Contract() |
|
943 { |
|
944 return iSTSSession->Contract(); |
|
945 } |
|
946 //--------------------------------------------------------------------------- |
|
947 // Getter for providerId |
|
948 //--------------------------------------------------------------------------- |
|
949 // |
|
950 TPtrC8 CWSStarTrustClient::ProviderID() |
|
951 { |
|
952 return iSTSSession->ProviderID(); |
|
953 } |
|
954 |
|
955 //--------------------------------------------------------------------------- |
|
956 // Getter for framework |
|
957 //--------------------------------------------------------------------------- |
|
958 // |
|
959 TPtrC8 CWSStarTrustClient::FrameworkId() |
|
960 { |
|
961 return iSTSSession->FrameworkId(); |
|
962 } |
|
963 //--------------------------------------------------------------------------- |
|
964 // serialie to xml |
|
965 //--------------------------------------------------------------------------- |
|
966 // |
|
967 void CWSStarTrustClient::WriteAsXMLToL(RWriteStream& aWriteStream) |
|
968 { |
|
969 iSTSSession->WriteAsXMLToL(aWriteStream); |
|
970 } |
|
971 TInt CWSStarTrustClient::UpdatePolicyL(CWSStarPolicyHandler* aPolicyHandler, MSenServiceDescription* aSD) |
|
972 { |
|
973 return iSTSSession->UpdatePolicyL(aPolicyHandler, aSD); |
|
974 } |
|
975 |
|
976 MSenServicePolicy* CWSStarTrustClient::ServicePolicy() |
|
977 { |
|
978 return iSTSSession->ServicePolicy(); |
|
979 } |
|
980 TInt CWSStarTrustClient::IapId(TUint32& aCurrentIapId) |
|
981 { |
|
982 return iSTSSession->IapId(aCurrentIapId); |
|
983 } |
|
984 //--------------------------------------------------------------------------- |
|
985 // randomize entropy for client |
|
986 //--------------------------------------------------------------------------- |
|
987 // |
|
988 void CWSStarTrustClient::RandomEntropyClientL() |
|
989 { |
|
990 HBufC8* hashedRandom = SenCryptoUtils::RandomAndHashMd5LC(); |
|
991 iEntropyClient = SenCryptoUtils::EncodeBase64L(*hashedRandom); |
|
992 CleanupStack::PopAndDestroy(hashedRandom); |
|
993 if (!iEntropyClient) |
|
994 { |
|
995 User::Leave(KErrNotFound); |
|
996 } |
|
997 } |
|
998 //--------------------------------------------------------------------------- |
|
999 // setter for ws-trust version |
|
1000 //--------------------------------------------------------------------------- |
|
1001 // |
|
1002 |
|
1003 void CWSStarTrustClient::SetVersion(const TDesC8* aVersion) |
|
1004 { |
|
1005 iVersion = aVersion; |
|
1006 } |
|
1007 |
|
1008 //--------------------------------------------------------------------------- |
|
1009 // getter for action (depends on version) |
|
1010 //--------------------------------------------------------------------------- |
|
1011 // |
|
1012 const TDesC8& CWSStarTrustClient::GetAction() |
|
1013 { |
|
1014 if (!iRenewingMode) |
|
1015 { |
|
1016 if (*iVersion == KTrustNamespace200502) |
|
1017 { |
|
1018 return KActionIssueRST200502; |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 return KActionIssueRST200404; |
|
1023 } |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 if (*iVersion == KTrustNamespace200502) |
|
1028 { |
|
1029 return KActionRenewRST200502; |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 return KActionRenewRST200404; |
|
1034 } |
|
1035 } |
|
1036 } |
|
1037 //--------------------------------------------------------------------------- |
|
1038 // getter for action response (depends on version) |
|
1039 //--------------------------------------------------------------------------- |
|
1040 // |
|
1041 const TDesC8& CWSStarTrustClient::GetActionResponse() |
|
1042 { |
|
1043 if (!iRenewingMode) |
|
1044 { |
|
1045 if (*iVersion == KTrustNamespace200502) |
|
1046 { |
|
1047 return KActionIssueRSTR200502; |
|
1048 } |
|
1049 else |
|
1050 { |
|
1051 return KActionIssueRSTR200404; |
|
1052 } |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 if (*iVersion == KTrustNamespace200502) |
|
1057 { |
|
1058 return KActionRenewRSTR200502; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 return KActionRenewRSTR200404; |
|
1063 } |
|
1064 } |
|
1065 } |
|
1066 //--------------------------------------------------------------------------- |
|
1067 // getter for request type (depends on version) |
|
1068 //--------------------------------------------------------------------------- |
|
1069 // |
|
1070 |
|
1071 const TDesC8& CWSStarTrustClient::GetRequestType() |
|
1072 { |
|
1073 if (!iRenewingMode) |
|
1074 { |
|
1075 if (*iVersion == KTrustNamespace200502) |
|
1076 { |
|
1077 return KRequestTypeIssueRST200502; |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 return KRequestTypeIssueRST200404; |
|
1082 } |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 if (*iVersion == KTrustNamespace200502) |
|
1087 { |
|
1088 return KRequestTypeRenewRST200502; |
|
1089 } |
|
1090 else |
|
1091 { |
|
1092 return KRequestTypeRenewRST200404; |
|
1093 } |
|
1094 } |
|
1095 } |
|
1096 //--------------------------------------------------------------------------- |
|
1097 // getter for policy namespace(depends on version) |
|
1098 //--------------------------------------------------------------------------- |
|
1099 // |
|
1100 |
|
1101 const TDesC8& CWSStarTrustClient::GetPolicyNs() |
|
1102 { |
|
1103 if (*iVersion == KTrustNamespace200502) |
|
1104 { |
|
1105 return KPolicyNamespace200409; |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 return KPolicyNamespace200212 ; |
|
1110 } |
|
1111 } |
|
1112 |
|
1113 TBool CWSStarTrustClient::HasSuperClass( TDescriptionClassType aType ) |
|
1114 { |
|
1115 if( aType == MSenServiceDescription::ESenInternalServiceConsumer ) // direct superclass! |
|
1116 { |
|
1117 // If asked type is the know *direct* father/mother, return true: |
|
1118 return ETrue; |
|
1119 } |
|
1120 else |
|
1121 { |
|
1122 // Otherwise, ask from superclass (chain, recursively) |
|
1123 return CSenInternalServiceConsumer::HasSuperClass( aType ); |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 void CWSStarTrustClient::SetHandlerCtx(MSenHandlerContext* aHndCtx) |
|
1128 { |
|
1129 iHndCtx = aHndCtx; |
|
1130 } |
|
1131 TBool CWSStarTrustClient::HasEqualPrimaryKeysL(MSenServiceDescription& aCandidate) |
|
1132 { |
|
1133 TBool retVal(EFalse); |
|
1134 if ( CSenWSDescription::HasEqualPrimaryKeysL(aCandidate) ) |
|
1135 { |
|
1136 // Endpoint, Contract and FrameworkID match, all of them. |
|
1137 // Now, in WS-*, also check ProviderID |
|
1138 if (aCandidate.DescriptionClassType() == DescriptionClassType()) |
|
1139 { |
|
1140 CWSStarTrustClient& trustCandidate = (CWSStarTrustClient&)aCandidate; |
|
1141 if (trustCandidate.ProviderID() == ProviderID()) |
|
1142 { |
|
1143 retVal = ETrue; |
|
1144 } |
|
1145 } |
|
1146 } |
|
1147 return retVal; |
|
1148 } |
|
1149 /* |
|
1150 TBool CWSStarTrustClient::HasEqualPrimaryKeysL(MSenServiceDescription& aCandidate) |
|
1151 { |
|
1152 TBool retVal(EFalse); |
|
1153 //if ( aCandidate.Endpoint() == Endpoint() && aCandidate.Contract() == Contract() && aCandidate.FrameworkId() == FrameworkId() ) |
|
1154 if ( CSenWSDescription::HasEqualPrimaryKeysL(aCandidate) ) |
|
1155 { |
|
1156 // Endpoint, Contract and FrameworkID match, all of them. |
|
1157 // Now, in WS-*, also check ProviderID |
|
1158 TPtrC8 providerID = ContentOf( WSStarSession::KProviderIdElementLocalName ); |
|
1159 CSenWSDescription& xmlSD = (CSenWSDescription&)aCandidate; |
|
1160 CSenElement* idElement = xmlSD.AsElement().Element( WSStarSession::KProviderIdElementLocalName ); |
|
1161 if ( idElement && idElement->Content() == providerID ) |
|
1162 { |
|
1163 // candidate has ProviderID element, which is equal with this sessions's provider ID |
|
1164 retVal = ETrue; |
|
1165 } |
|
1166 } |
|
1167 return retVal; |
|
1168 } |
|
1169 */ |
|
1170 |
|
1171 void CWSStarTrustClient::AdaptStsEndpointL(TBool aToOrginal) //codescannerwarnings |
|
1172 { |
|
1173 if (aToOrginal) |
|
1174 { |
|
1175 iSTSSession->SetEndPointL(*iSTSOrginalEndpoint); |
|
1176 return; |
|
1177 } |
|
1178 |
|
1179 delete iSTSOrginalEndpoint; |
|
1180 iSTSOrginalEndpoint = NULL; |
|
1181 iSTSOrginalEndpoint = iSTSSession->Endpoint().AllocL(); |
|
1182 HBufC8* address = NULL; |
|
1183 if (iTokenType) |
|
1184 { |
|
1185 address = CWSStarPolicy::GetPolicyValueL(*iTokenType, KIssuedToken, KAddress, *iHndCtx, iSTSSession); |
|
1186 } |
|
1187 else |
|
1188 { |
|
1189 address = CWSStarPolicy::GetPolicyValueL(KIssuedToken, KAddress, *iHndCtx, iSTSSession); |
|
1190 } |
|
1191 |
|
1192 if (address) |
|
1193 { |
|
1194 iSTSSession->SetEndPointL(*address); |
|
1195 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::AdaptStsEndpoint() - endpoint replaced by value from policy"); |
|
1196 } |
|
1197 delete address; |
|
1198 address = NULL; |
|
1199 } |
|
1200 TBool CWSStarTrustClient::Matches(MSenServiceDescription& aOtherServiceDescription) |
|
1201 { |
|
1202 return iSTSSession->Matches(aOtherServiceDescription); |
|
1203 } |
|
1204 void CWSStarTrustClient::SetDataTrafficDetails( TSenDataTrafficDetails& aDetails) |
|
1205 { |
|
1206 iTrustDetails = aDetails; |
|
1207 } |
|
1208 // End of file |
|
1209 |