|
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 "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 // INCLUDE FILES |
|
22 #include "wsstarcobrandingclient.h" |
|
23 |
|
24 #include <s32mem.h> |
|
25 #include <f32file.h> |
|
26 #include <s32file.h> |
|
27 #include <SenXmlUtils.h> |
|
28 #include "sencryptoutils.h" |
|
29 |
|
30 #include "wsstarservicesession.h" |
|
31 #include "SenXmlUtils.h" |
|
32 #include "msencoreservicemanager.h" |
|
33 #include "sendebug.h" |
|
34 #include "senlogger.h" |
|
35 #include "MSenServiceDescription.h" |
|
36 #include "senlogger.h" |
|
37 #include "SenServiceConnection.h" |
|
38 #include "seninternalserviceconsumer.h" |
|
39 #include "wsstarrstresponse.h" |
|
40 #include <SenCredential.h> |
|
41 #include "wsstarpolicy.h" |
|
42 #include "wsstarplugin.h" |
|
43 #include <SenTransportProperties.h> |
|
44 #include "senwspattern.h" |
|
45 |
|
46 using namespace WSTrust; |
|
47 using namespace WSPolicy; |
|
48 |
|
49 //namespace |
|
50 // { |
|
51 // _LIT8(KRemoteConsumer, "RemoteConsumer"); |
|
52 // } |
|
53 |
|
54 //--------------------------------------------------------------------------- |
|
55 // Creates and returns a new instace of this class. |
|
56 //--------------------------------------------------------------------------- |
|
57 // |
|
58 CWSStarCoBrandingClient* CWSStarCoBrandingClient::NewL( |
|
59 CSIF& aSIF, |
|
60 RFileLogger& aLogger) |
|
61 { |
|
62 CWSStarCoBrandingClient* pNew = NewLC(aSIF, aLogger); |
|
63 CleanupStack::Pop(pNew); |
|
64 return pNew; |
|
65 } |
|
66 |
|
67 //--------------------------------------------------------------------------- |
|
68 // Creates and returns a new instace of this class and leaves the object on the cleanup stack |
|
69 //--------------------------------------------------------------------------- |
|
70 // |
|
71 CWSStarCoBrandingClient* CWSStarCoBrandingClient::NewLC( |
|
72 CSIF& aSIF, |
|
73 RFileLogger& aLogger) |
|
74 { |
|
75 CWSStarCoBrandingClient* pNew = |
|
76 new (ELeave) CWSStarCoBrandingClient( |
|
77 aSIF, |
|
78 MSenServiceDescription::EWSStarSTSClient, |
|
79 aLogger); |
|
80 |
|
81 CleanupStack::PushL(pNew); |
|
82 pNew->BaseConstructL(); |
|
83 return pNew; |
|
84 } |
|
85 |
|
86 //--------------------------------------------------------------------------- |
|
87 // Constructor |
|
88 //--------------------------------------------------------------------------- |
|
89 // |
|
90 CWSStarCoBrandingClient::CWSStarCoBrandingClient( |
|
91 CSIF& aSIF, |
|
92 TDescriptionClassType aType, |
|
93 RFileLogger& aLogger) |
|
94 : CSenInternalServiceConsumer(aType, aSIF), |
|
95 iLog(aLogger) |
|
96 { |
|
97 } |
|
98 |
|
99 void CWSStarCoBrandingClient::BaseConstructL() |
|
100 { |
|
101 CSenInternalServiceConsumer::ConstructL(); |
|
102 iTpCounter = 0; |
|
103 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarCoBrandingClient::ConstructL()"))); |
|
104 } |
|
105 |
|
106 //--------------------------------------------------------------------------- |
|
107 // Destructor |
|
108 //--------------------------------------------------------------------------- |
|
109 // |
|
110 CWSStarCoBrandingClient::~CWSStarCoBrandingClient() |
|
111 { |
|
112 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarCoBrandingClient::~CWSStarCoBrandingClient"); |
|
113 delete ipTransport; |
|
114 delete iCoBrandingOrginalEndpoint; |
|
115 } |
|
116 |
|
117 |
|
118 //--------------------------------------------------------------------------- |
|
119 // SetStatus |
|
120 //--------------------------------------------------------------------------- |
|
121 // |
|
122 |
|
123 void CWSStarCoBrandingClient::SetStatus(TInt /*aStatus */) |
|
124 { |
|
125 // No implementation in Java |
|
126 } |
|
127 |
|
128 //--------------------------------------------------------------------------- |
|
129 // SetSTSSessionL |
|
130 //--------------------------------------------------------------------------- |
|
131 // |
|
132 void CWSStarCoBrandingClient::SetCoBrandingSessionL( |
|
133 CWSStarServiceSession* aSession) |
|
134 { |
|
135 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarCoBrandingClient::SetCoBrandingSessionL"); |
|
136 _LIT8(KTouch, "touch"); |
|
137 const TDesC8* attrValue = aSession->AsElement().AttrValue(KTouch); |
|
138 if(attrValue != NULL) |
|
139 { |
|
140 AsElement().AddAttrL(KTouch, *attrValue); |
|
141 } |
|
142 iCoBrandingSession = aSession; |
|
143 } |
|
144 |
|
145 //--------------------------------------------------------------------------- |
|
146 // Fetch SCT request |
|
147 //--------------------------------------------------------------------------- |
|
148 //Co-Branding CR |
|
149 TInt CWSStarCoBrandingClient::FetchSCTL( |
|
150 CWSStarServiceSession& aSession, |
|
151 HBufC8*& aErrorMessage) |
|
152 { |
|
153 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarCoBrandingClient::FetchSCTL(..)"); |
|
154 TInt retVal(KErrNone); // for returning error codes |
|
155 iWSStarServiceSession = &aSession; // save session |
|
156 iWSStarServiceSession->AddConsumerL(*this); |
|
157 |
|
158 CWSStarSessionContext* coBrandingSsnContext = iCoBrandingSession->SessionContext(); |
|
159 CWSStarSessionContext* valSsnContext = iWSStarServiceSession->SessionContext(); |
|
160 |
|
161 //PART 2 :: |
|
162 |
|
163 HBufC8* pBodyXML = NULL; |
|
164 HBufC8* coBrandResponseXML = NULL; |
|
165 |
|
166 const TBool* brandID = coBrandingSsnContext->GetIntL(WSStarContextKeys::KBrandIDEnabled); |
|
167 if(brandID && *brandID) |
|
168 { |
|
169 |
|
170 //Create a Fetch SCt body and update |
|
171 CWSStarPlugin& frmWSStar = (CWSStarPlugin&)Framework(); |
|
172 CSenElement* pBody = CreateFSTL(); |
|
173 |
|
174 if(pBody) |
|
175 { |
|
176 |
|
177 //Update application info attribute |
|
178 if (CWSStarPolicy::CheckPolicyValueL(WSStarContextKeys::KMwsNamespace, iCoBrandingSession)) |
|
179 { |
|
180 HBufC8* mwsNameSapce = CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KMwsNamespace,iCoBrandingSession); |
|
181 CleanupStack::PushL(mwsNameSapce); |
|
182 valSsnContext->Update(WSStarContextKeys::KMwsNamespace, mwsNameSapce->Des()); |
|
183 CleanupStack::PopAndDestroy(mwsNameSapce); |
|
184 |
|
185 } |
|
186 |
|
187 AddAppInfoHeaderL(); |
|
188 |
|
189 //Update action |
|
190 valSsnContext->Update(WSStarContextKeys::KAction, KActionIssueFST200610); |
|
191 |
|
192 HBufC8* address = NULL; |
|
193 |
|
194 address = CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KWAPGW,iCoBrandingSession); |
|
195 |
|
196 if (address) |
|
197 { |
|
198 valSsnContext->Update(WSStarContextKeys::KTo, *address); |
|
199 |
|
200 delete address; |
|
201 address = NULL; |
|
202 } |
|
203 |
|
204 |
|
205 valSsnContext->Update(WSStarContextKeys::KBodyElement, pBody); |
|
206 pBodyXML = pBody->AsXmlL(); |
|
207 CleanupStack::PushL(pBodyXML); |
|
208 |
|
209 |
|
210 //Set transport properties |
|
211 CSenTransportProperties* transProp = CSenTransportProperties::NewLC(); |
|
212 TPtrC8 value; |
|
213 value.Set(*valSsnContext->GetDesC8L(WSStarContextKeys::KAction)); |
|
214 transProp->SetSoapActionL(value); |
|
215 |
|
216 // Get the IAP setting and accordingly set the transport properties |
|
217 TUint32 id = 0; |
|
218 TInt getIapRetCode = IapId(id); |
|
219 |
|
220 ; |
|
221 // Check whether IAP ID is pre-defined, and copy it only if such property value is found |
|
222 //if ( getIapRetCode == KErrNone && id < 4294967295) // unsigned 4294967295 == -1 signed |
|
223 if ( getIapRetCode == KErrNone && id < (TUint32)KErrNotFound) // unsigned 4294967295 == -1 signed |
|
224 { |
|
225 transProp->SetIapIdL(id); |
|
226 } |
|
227 // ETMI-6WAGDB end |
|
228 |
|
229 //limit http timeout, |
|
230 // if sts hangs and can not send any response, then we block every async client method. |
|
231 // Possibel revalidation during sendL can take too long time therefore we create new limit |
|
232 transProp->SetMaxTimeToLiveL(WSStarSession::KMaxHttpTimeOut); |
|
233 |
|
234 const TDesC8* pMwsNamespace = valSsnContext->GetDesC8L(WSStarContextKeys::KMwsNamespace); |
|
235 |
|
236 if(pMwsNamespace) |
|
237 transProp->SetMwsNamespaceL(*pMwsNamespace); |
|
238 |
|
239 HBufC8* transPropAsXml = transProp->AsUtf8LC(); |
|
240 |
|
241 //overwrite passport endpoint (provided by GUI) by endpoint provided by policy |
|
242 AdaptCoBrandEndpointL(); |
|
243 |
|
244 iTpCounter++; |
|
245 retVal = iWSStarServiceSession->SubmitL(*pBodyXML, *transPropAsXml, *this, coBrandResponseXML); |
|
246 iTpCounter--; |
|
247 CleanupStack::PushL(coBrandResponseXML); |
|
248 AdaptCoBrandEndpointL(ETrue); |
|
249 valSsnContext->Remove(WSStarContextKeys::KTo); |
|
250 valSsnContext->Remove(WSStarContextKeys::KAppInfoPresent); |
|
251 |
|
252 |
|
253 if(coBrandResponseXML) |
|
254 { |
|
255 //Parse the response |
|
256 CSenParser* pParser = CSenParser::NewLC(); |
|
257 CSenSoapEnvelope2* pResponseFragment = CSenSoapEnvelope2::NewL(); |
|
258 CleanupStack::PushL(pResponseFragment); |
|
259 TRAPD(errorL,pParser->ParseL(*coBrandResponseXML, *pResponseFragment)); |
|
260 |
|
261 if ( retVal!= KErrNone || errorL!= KErrNone) |
|
262 { |
|
263 aErrorMessage = coBrandResponseXML; |
|
264 } |
|
265 |
|
266 CleanupStack::PopAndDestroy(2); // pParser, pResponseFragment |
|
267 |
|
268 } |
|
269 |
|
270 if (!aErrorMessage) |
|
271 { |
|
272 CleanupStack::PopAndDestroy(coBrandResponseXML); |
|
273 } |
|
274 else |
|
275 { |
|
276 CleanupStack::Pop(coBrandResponseXML); |
|
277 } |
|
278 |
|
279 CleanupStack::PopAndDestroy(transPropAsXml); |
|
280 CleanupStack::PopAndDestroy(transProp); |
|
281 CleanupStack::PopAndDestroy(pBodyXML); |
|
282 |
|
283 } |
|
284 } |
|
285 |
|
286 if (! iTpCounter) |
|
287 { |
|
288 delete ipTransport; |
|
289 ipTransport = NULL; |
|
290 } |
|
291 |
|
292 |
|
293 iWSStarServiceSession->RemoveConsumerL(*this); |
|
294 |
|
295 return retVal; |
|
296 |
|
297 } |
|
298 //End Of Co-Branding |
|
299 void CWSStarCoBrandingClient::AddAppInfoHeaderL() |
|
300 { |
|
301 CWSStarSessionContext* valSsnContext = iWSStarServiceSession->SessionContext(); |
|
302 |
|
303 //Update application info attribute |
|
304 if (CWSStarPolicy::CheckPolicyValueL(WSStarContextKeys::KAppInfo, iCoBrandingSession)) |
|
305 { |
|
306 valSsnContext->Update(WSStarContextKeys::KAppInfoPresent, ETrue); |
|
307 |
|
308 RPointerArray<CSenElement> aAppElements; |
|
309 CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KAppInfo,WSStarContextKeys::KApplication,iCoBrandingSession,aAppElements); |
|
310 |
|
311 for(TInt i=0;i<aAppElements.Count();i++) |
|
312 { |
|
313 CSenElement* element = aAppElements[i]; |
|
314 if(element->LocalName() == KName) |
|
315 { |
|
316 valSsnContext->Update(WSStarContextKeys::KApplicationName, element->Content()); |
|
317 } |
|
318 if(element->LocalName() == WSStarContextKeys::KVendor) |
|
319 { |
|
320 valSsnContext->Update(WSStarContextKeys::KApplicationVendor, element->Content()); |
|
321 } |
|
322 if(element->LocalName() == WSStarContextKeys::KVersion) |
|
323 { |
|
324 valSsnContext->Update(WSStarContextKeys::KApplicationVersion, element->Content()); |
|
325 } |
|
326 } |
|
327 |
|
328 RPointerArray<CSenElement> aDeOpElements; |
|
329 CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KAppInfo,WSStarContextKeys::KDeviceOptions,iCoBrandingSession,aDeOpElements); |
|
330 for(TInt i=0;i<aDeOpElements.Count();i++) |
|
331 { |
|
332 CSenElement* element = aDeOpElements[i]; |
|
333 if(element->LocalName() == WSStarContextKeys::KLocale) |
|
334 { |
|
335 valSsnContext->Update(WSStarContextKeys::KLocale, element->Content()); |
|
336 } |
|
337 if(element->LocalName() == WSStarContextKeys::KUserAgent) |
|
338 { |
|
339 RPointerArray<CSenElement> childElements1 = element->ElementsL(); |
|
340 for(TInt j=0;j<childElements1.Count();j++) |
|
341 { |
|
342 CSenElement* childElement1 = childElements1[j]; |
|
343 if(childElement1->LocalName() == WSStarContextKeys::KManufacturer) |
|
344 { |
|
345 valSsnContext->Update(WSStarContextKeys::KManufacturer, childElement1->Content()); |
|
346 } |
|
347 if(childElement1->LocalName() == WSStarContextKeys::KModel) |
|
348 { |
|
349 valSsnContext->Update(WSStarContextKeys::KModel, childElement1->Content()); |
|
350 } |
|
351 if(childElement1->LocalName() == WSStarContextKeys::KIMSI) |
|
352 { |
|
353 valSsnContext->Update(WSStarContextKeys::KIMSI, childElement1->Content()); |
|
354 } |
|
355 if(childElement1->LocalName() == WSStarContextKeys::KOS) |
|
356 { |
|
357 |
|
358 RPointerArray<CSenElement> childElements2 = childElement1->ElementsL(); |
|
359 for(TInt k=0;k<childElements2.Count();k++) |
|
360 { |
|
361 CSenElement* childElement2 = childElements2[k]; |
|
362 if(childElement2->LocalName() == WSStarContextKeys::KName) |
|
363 { |
|
364 valSsnContext->Update(WSStarContextKeys::KDeviceName, childElement2->Content()); |
|
365 } |
|
366 if(childElement2->LocalName() == WSStarContextKeys::KVersion) |
|
367 { |
|
368 valSsnContext->Update(WSStarContextKeys::KDeviceVersion, childElement2->Content()); |
|
369 } |
|
370 } |
|
371 } |
|
372 } |
|
373 } |
|
374 } |
|
375 } |
|
376 } |
|
377 CSenServiceSession* CWSStarCoBrandingClient::ServiceSession() |
|
378 { |
|
379 return iWSStarServiceSession; |
|
380 } |
|
381 |
|
382 //--------------------------------------------------------------------------- |
|
383 // Create body for Fetch SCT request |
|
384 //--------------------------------------------------------------------------- |
|
385 //Co-Branding CR |
|
386 CSenElement* CWSStarCoBrandingClient::CreateFSTL() |
|
387 { |
|
388 |
|
389 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::CreateFSTL"); |
|
390 |
|
391 //----------------- |
|
392 //1 Proxy |
|
393 //----------------- |
|
394 |
|
395 if (CWSStarPolicy::CheckPolicyValueL(WSStarContextKeys::KWAPGW, iCoBrandingSession)) |
|
396 { |
|
397 |
|
398 HBufC8* wapGW = CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KWAPGW, iCoBrandingSession); |
|
399 if (wapGW) |
|
400 { |
|
401 CleanupStack::PushL(wapGW); |
|
402 } |
|
403 else |
|
404 { |
|
405 //Hard Coded Value |
|
406 } |
|
407 |
|
408 CSenDomFragment* domFrg = CSenDomFragment::NewL(KFSTTag); |
|
409 CSenElement* elementRst = domFrg->ExtractElement(); |
|
410 |
|
411 CleanupStack::PushL(elementRst); |
|
412 |
|
413 delete domFrg; |
|
414 domFrg = NULL; |
|
415 |
|
416 elementRst->AddNamespaceL(KNullDesC8,*wapGW); |
|
417 |
|
418 |
|
419 CleanupStack::Pop(elementRst); |
|
420 |
|
421 if (wapGW) |
|
422 { |
|
423 CleanupStack::PopAndDestroy(wapGW); |
|
424 } |
|
425 |
|
426 return elementRst; |
|
427 } |
|
428 |
|
429 return NULL; |
|
430 |
|
431 } |
|
432 |
|
433 //End Of Co-Branding |
|
434 MSenTransport& CWSStarCoBrandingClient::TransportL() |
|
435 { |
|
436 if(!ipTransport) |
|
437 { |
|
438 // Core is capable of working as transport factory, too. |
|
439 // The returned transport instancies may or may not be |
|
440 // ECOM plugins: |
|
441 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::Instantiating new transport"); |
|
442 ipTransport = Framework().Manager().CreateL(*iWSStarServiceSession, iWSStarServiceSession); |
|
443 } |
|
444 return *ipTransport; |
|
445 } |
|
446 //--------------------------------------------------------------------------- |
|
447 // Getter for endpoint |
|
448 //--------------------------------------------------------------------------- |
|
449 // |
|
450 TPtrC8 CWSStarCoBrandingClient::Endpoint() |
|
451 { |
|
452 return iWSStarServiceSession->Endpoint(); |
|
453 } |
|
454 //--------------------------------------------------------------------------- |
|
455 // Getter for contract |
|
456 //--------------------------------------------------------------------------- |
|
457 // |
|
458 TPtrC8 CWSStarCoBrandingClient::Contract() |
|
459 { |
|
460 return iWSStarServiceSession->Contract(); |
|
461 } |
|
462 //--------------------------------------------------------------------------- |
|
463 // Getter for providerId |
|
464 //--------------------------------------------------------------------------- |
|
465 // |
|
466 TPtrC8 CWSStarCoBrandingClient::ProviderID() |
|
467 { |
|
468 return iWSStarServiceSession->ProviderID(); |
|
469 } |
|
470 |
|
471 //--------------------------------------------------------------------------- |
|
472 // Getter for framework |
|
473 //--------------------------------------------------------------------------- |
|
474 // |
|
475 TPtrC8 CWSStarCoBrandingClient::FrameworkId() |
|
476 { |
|
477 return iWSStarServiceSession->FrameworkId(); |
|
478 } |
|
479 //--------------------------------------------------------------------------- |
|
480 // serialie to xml |
|
481 //--------------------------------------------------------------------------- |
|
482 // |
|
483 void CWSStarCoBrandingClient::WriteAsXMLToL(RWriteStream& aWriteStream) |
|
484 { |
|
485 iWSStarServiceSession->WriteAsXMLToL(aWriteStream); |
|
486 } |
|
487 MSenServicePolicy* CWSStarCoBrandingClient::ServicePolicy() |
|
488 { |
|
489 return iWSStarServiceSession->ServicePolicy(); |
|
490 } |
|
491 TInt CWSStarCoBrandingClient::IapId(TUint32& aCurrentIapId) |
|
492 { |
|
493 return iWSStarServiceSession->IapId(aCurrentIapId); |
|
494 } |
|
495 |
|
496 //--------------------------------------------------------------------------- |
|
497 // setter for ws-trust version |
|
498 //--------------------------------------------------------------------------- |
|
499 // |
|
500 void CWSStarCoBrandingClient::SetHandlerCtx(MSenHandlerContext* aHndCtx) |
|
501 { |
|
502 iHndCtx = aHndCtx; |
|
503 } |
|
504 |
|
505 //Co-branding CR |
|
506 TInt CWSStarCoBrandingClient::AdaptCoBrandEndpointL(TBool aToOrginal) //codescannerwarnings |
|
507 { |
|
508 |
|
509 TInt returnValue( KErrNone ); |
|
510 if (aToOrginal) |
|
511 { |
|
512 iWSStarServiceSession->SetEndPointL(*iCoBrandingOrginalEndpoint); |
|
513 return returnValue; |
|
514 } |
|
515 delete iCoBrandingOrginalEndpoint; |
|
516 iCoBrandingOrginalEndpoint = NULL; |
|
517 iCoBrandingOrginalEndpoint = iWSStarServiceSession->Endpoint().AllocL(); |
|
518 HBufC8* address = NULL; |
|
519 |
|
520 address = CWSStarPolicy::GetPolicyValueL(WSStarContextKeys::KWAPGW,iCoBrandingSession); |
|
521 |
|
522 if (address) |
|
523 { |
|
524 iWSStarServiceSession->SetEndPointL(*address); |
|
525 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarTrustClient::AdaptCoBrandEndpointL() - endpoint replaced by value from policy"); |
|
526 |
|
527 delete address; |
|
528 address = NULL; |
|
529 } |
|
530 else |
|
531 { |
|
532 returnValue = KErrNotFound; |
|
533 } |
|
534 |
|
535 return returnValue; |
|
536 } |
|
537 |
|
538 TBool CWSStarCoBrandingClient::Matches(MSenServiceDescription& aOtherServiceDescription) |
|
539 { |
|
540 return iWSStarServiceSession->Matches(aOtherServiceDescription); |
|
541 |
|
542 } |
|
543 |
|
544 // End of file |
|
545 |
|
546 |