|
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 // INCLUDE |
|
21 #include "wsstarservicesession.h" |
|
22 #include "sendebug.h" |
|
23 #include "senlogger.h" |
|
24 #include "SenSoapFault.h" |
|
25 #include "senservicemanagerdefines.h" |
|
26 #include "SenServiceConnection.h" // err code definitions |
|
27 #include "senserviceinvocationframework.h" |
|
28 #include "SenHttpTransportProperties.h" |
|
29 #include "senvtcptransportproperties.h" |
|
30 #include "SenDateUtils.h" |
|
31 #include "wsstarpolicy.h" |
|
32 #include "sendebug.h" |
|
33 #include "sencryptoutils.h" |
|
34 #include "senwspattern.h" |
|
35 #include "SenXmlUtils.h" |
|
36 #include <xmlengnodelist.h> |
|
37 |
|
38 #include <SenIdentityProvider.h> |
|
39 #include "wsstarcredentialobserver.h" |
|
40 using namespace WSPolicy; |
|
41 |
|
42 /* Constant margin. Value is copied from framework internal class. |
|
43 * We check if MT is expired (now < validUntil - skew time - margin) |
|
44 * Margin is 15 minutes. |
|
45 */ |
|
46 const TInt64 KClockSlipMinutes = 15; |
|
47 |
|
48 |
|
49 CWSStarServiceSession* CWSStarServiceSession::NewL(MSIF& aFramework) |
|
50 { |
|
51 CWSStarServiceSession* self = CWSStarServiceSession::NewLC(aFramework); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 CWSStarServiceSession* CWSStarServiceSession::NewLC(MSIF& aFramework) |
|
57 { |
|
58 CWSStarServiceSession* self = new (ELeave) CWSStarServiceSession( |
|
59 MSenServiceDescription::EWSStarServiceSession, aFramework); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 return self; |
|
63 } |
|
64 |
|
65 CWSStarServiceSession::CWSStarServiceSession(TDescriptionClassType aType, |
|
66 MSIF& aSIF) |
|
67 : CSenWebServiceSession(aType, aSIF), |
|
68 iMessageThread(EFalse), |
|
69 iSubmitState(WSStarSession::KSubmitStateOK) |
|
70 { |
|
71 } |
|
72 |
|
73 CWSStarServiceSession::~CWSStarServiceSession() |
|
74 { |
|
75 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::~CWSStarServiceSession"); |
|
76 delete iSessionContext; |
|
77 delete iProviderID; |
|
78 delete iTrustAnchor; |
|
79 delete iOutContext; |
|
80 delete iInContext; |
|
81 delete ipReceivedMessageIdInTrans; |
|
82 delete iTransProp; |
|
83 |
|
84 TInt count(iConsumerList.Count()); |
|
85 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("CWSStarServiceSession::~CWSStarServiceSession leaved ConsumerL now= %d"), count)); |
|
86 for(TInt i=0; i<count; i++) |
|
87 { |
|
88 // we can assume that every remote consumer |
|
89 // has been wrapped inside WSStarSessionConsumer |
|
90 // -wrapperclass. Cast and destroy: |
|
91 CWSStarSessionConsumer* pConsumer |
|
92 = (CWSStarSessionConsumer*) iConsumerList[i]; |
|
93 |
|
94 // this destroys the wrapper, but the remote |
|
95 // consumer objects ownership remains in either |
|
96 // XMLDao or ClientSession (etc) |
|
97 delete pConsumer; |
|
98 } |
|
99 delete iTicketObs; |
|
100 } |
|
101 |
|
102 void CWSStarServiceSession::ConstructL() |
|
103 { |
|
104 CSenWebServiceSession::ConstructL(); |
|
105 iTicketObs = CWSStarCredentialObserver::NewL(this, iFramework.Manager().Log()); |
|
106 } |
|
107 |
|
108 TInt CWSStarServiceSession::AddConsumerL(MSenRemoteServiceConsumer& aConsumer) |
|
109 { |
|
110 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::AddConsumerL"); |
|
111 |
|
112 const TInt consumerCount(iConsumerList.Count()); |
|
113 for(TInt i=0; i<consumerCount; i++) |
|
114 { |
|
115 if(iConsumerList[i]->Id() == aConsumer.Id()) |
|
116 { |
|
117 return KErrAlreadyExists; // already added, nothing to do |
|
118 } |
|
119 } |
|
120 |
|
121 CWSStarSessionConsumer* pSessionConsumer = |
|
122 CWSStarSessionConsumer::NewL(aConsumer, *Log()); |
|
123 |
|
124 TInt error = iConsumerList.Append(pSessionConsumer); |
|
125 CWSStarPlugin* fmw = (CWSStarPlugin*)&iFramework; |
|
126 fmw->PolicyConsumerAddedL(this,*pSessionConsumer); |
|
127 return KErrNone; |
|
128 } |
|
129 |
|
130 /** |
|
131 * DetachCredentialsL |
|
132 * |
|
133 * This function invalidates the session by deleting the credential |
|
134 * This also call setStatusL to recompute the status |
|
135 */ |
|
136 void CWSStarServiceSession::DetachCredentialsL() |
|
137 { |
|
138 ClearCredentialL() ; |
|
139 SetStatusL() ; |
|
140 } |
|
141 TBool CWSStarServiceSession::ExistConsumerL() |
|
142 { |
|
143 const TInt consumerCount(iConsumerList.Count()); |
|
144 if( consumerCount == 0 ) |
|
145 { |
|
146 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel," - Consumer count = 0"); |
|
147 return EFalse; |
|
148 } |
|
149 else |
|
150 { |
|
151 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("- Consumer count = %d"), consumerCount)); |
|
152 return ETrue; |
|
153 } |
|
154 } |
|
155 |
|
156 TInt CWSStarServiceSession::RemoveConsumerL(MSenRemoteServiceConsumer& aConsumer) |
|
157 { |
|
158 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::RemoveConsumerL:"); |
|
159 |
|
160 const TInt consumerCount(iConsumerList.Count()); |
|
161 for(TInt i=0; i<consumerCount; i++) |
|
162 { |
|
163 if(iConsumerList[i]->Id() == aConsumer.Id()) |
|
164 { |
|
165 CWSStarSessionConsumer* pConsumer |
|
166 = (CWSStarSessionConsumer*) iConsumerList[i]; |
|
167 delete pConsumer; |
|
168 iConsumerList.Remove(i); |
|
169 CSLOG_FORMAT((aConsumer.ConnectionId() , KMinLogLevel , _L8("CWSStarServiceSession::Removed ConsumerL now= %d"), consumerCount-1)); |
|
170 |
|
171 if( (consumerCount-1) == 0 ) |
|
172 { |
|
173 iTicketObs->Cancel(); |
|
174 } |
|
175 break; |
|
176 } |
|
177 } |
|
178 // If this session has no consumers, we can hold our grip to the credential |
|
179 // (note: this does NOT mean that credential is removed, not at all(!), but |
|
180 // that new search for the credential has to be performed). |
|
181 if( consumerCount == 0 ) |
|
182 { |
|
183 CSLOG_L(aConsumer.ConnectionId() ,KNormalLogLevel ,"- Consumer count == 0"); |
|
184 |
|
185 CSLOG_L(aConsumer.ConnectionId() ,KNormalLogLevel ,"-> Closing the handle to the credential owned by the Credential Manager."); |
|
186 |
|
187 SetSecurityL(KNullDesC8); // this removes the reference to credential, but |
|
188 // it can be regained on next lookup |
|
189 // This needs to implemet. so that userinfo (password) |
|
190 // that grants the permission to use the credential |
|
191 // will be checked on that (credential sharing) lookup. |
|
192 } |
|
193 |
|
194 return CSenServiceSession::RemoveConsumerL(aConsumer); |
|
195 } |
|
196 |
|
197 TInt CWSStarServiceSession::MessageForSendingL( const TDesC8& aBody, |
|
198 const TDesC8& aSenderID, |
|
199 CSenSoapMessage*& aMessage) |
|
200 { |
|
201 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::MessageForSendingL"); |
|
202 TInt error(KErrNone); |
|
203 if (AmIHostletSession()) |
|
204 { |
|
205 return CSenWebServiceSession::MessageForSendingL(aBody, aSenderID, aMessage); |
|
206 } |
|
207 else |
|
208 { |
|
209 CleanupStack::PushL(aMessage); |
|
210 CWSStarSessionConsumer* pConsumer = NULL; |
|
211 //senderID is internal id of consumer |
|
212 error = SessionConsumerL(aSenderID, pConsumer); |
|
213 if (error) |
|
214 { |
|
215 CleanupStack::Pop(aMessage); |
|
216 return error; |
|
217 } |
|
218 |
|
219 CWSStarSessionContext* ssCtx = (CWSStarSessionContext*)SessionContext(); |
|
220 |
|
221 //----adding addressing info |
|
222 //messageId - set by handler |
|
223 User::LeaveIfError(iOutContext->Add(WSStarContextKeys::KTo, Contract())); |
|
224 if(ipReceivedMessageIdInTrans) |
|
225 { |
|
226 User::LeaveIfError(iOutContext->Add(WSStarContextKeys::KRelatesTo, |
|
227 *ipReceivedMessageIdInTrans)); |
|
228 } |
|
229 else |
|
230 { |
|
231 User::LeaveIfError(iOutContext->Add(WSStarContextKeys::KRelatesTo, NULL)); |
|
232 } |
|
233 |
|
234 iOutContext->SetOwnedEnvelope(); |
|
235 iOutContext->UpdateFromSessionContextL(*ssCtx); |
|
236 CleanupStack::Pop(aMessage); |
|
237 error = ((CWSStarPlugin&)iFramework).ProcessOutboundMessageL( |
|
238 iOutContext, &aBody, aMessage); |
|
239 |
|
240 iSessionContext->UpdateFromMessageOutContextL(*iOutContext); |
|
241 const TDesC8* resolvedBody = iSessionContext->GetDesC8L(WSStarContextKeys::KBody); |
|
242 |
|
243 if (resolvedBody && (!error)) |
|
244 { |
|
245 error = pConsumer->MessageForSendingL(*resolvedBody , iOutContext); |
|
246 } |
|
247 |
|
248 aMessage = iOutContext->GetCurrentSoapMessage(); |
|
249 iOutContext->SetOwnedEnvelope(EFalse); |
|
250 delete iOutContext; |
|
251 iOutContext = NULL; |
|
252 } |
|
253 return error; |
|
254 } |
|
255 |
|
256 TInt CWSStarServiceSession::NewMessageL(CSenSoapMessage*& aMessage) |
|
257 { |
|
258 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::NewMessageL( CSenSoapMessage*& )"); |
|
259 //method used during ibound processing |
|
260 const TInt* soapVer = iSessionContext->GetIntL(WSStarContextKeys::KSoapVersion); |
|
261 |
|
262 if (soapVer) |
|
263 { |
|
264 aMessage = CSenSoapMessage::NewL((TSOAPVersion)*soapVer); |
|
265 } |
|
266 else |
|
267 { |
|
268 aMessage = CSenSoapMessage::NewL(ESOAP12); |
|
269 } |
|
270 CSenXmlReader* reader = XmlReader(); |
|
271 if (iInContext) |
|
272 { |
|
273 delete iInContext; |
|
274 iInContext = NULL; |
|
275 } |
|
276 iInContext = CWSStarMessageContext::NewL(SenContext::EIncoming, reader); |
|
277 CWSStarSessionContext* ssCtx = (CWSStarSessionContext*)SessionContext(); |
|
278 iInContext->UpdateFromSessionContextL(*ssCtx); |
|
279 |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 TInt CWSStarServiceSession::ParseMessageL(CSenSoapMessage& aSOAPMessage) |
|
284 { |
|
285 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::ParseMessageL(CSenSoapMessage& )"); |
|
286 |
|
287 //-----SCHarF ------- 7.5.3.3 Inbound messageflow |
|
288 |
|
289 CSenXmlReader* reader = XmlReader(); |
|
290 CSenSoapMessage* soapMessage = &aSOAPMessage; |
|
291 ((CWSStarPlugin&)iFramework).ProcessInboundDispatchL(this, soapMessage); |
|
292 ((CWSStarPlugin&)iFramework).ProcessInboundMessageL(iInContext, soapMessage); |
|
293 |
|
294 iServerTime.UniversalTime(); |
|
295 |
|
296 //keep transaction chain |
|
297 if (iMessageThread) |
|
298 { |
|
299 const TDesC8* msgId = iInContext->GetDesC8L(WSStarContextKeys::KMessageID()); |
|
300 if (msgId) |
|
301 { |
|
302 delete ipReceivedMessageIdInTrans; |
|
303 ipReceivedMessageIdInTrans = NULL; |
|
304 ipReceivedMessageIdInTrans = msgId->AllocL(); |
|
305 } |
|
306 else |
|
307 { |
|
308 //transaction mode is enabled, but no messageId in response so what to do. |
|
309 //anyway we will continue without signalizing error |
|
310 } |
|
311 } |
|
312 |
|
313 iSessionContext->UpdateFromMessageInContextL(*iInContext); |
|
314 |
|
315 return CSenWebServiceSession::ParseMessageL(aSOAPMessage); |
|
316 |
|
317 } |
|
318 |
|
319 TInt CWSStarServiceSession::SendSoapMessageToConsumerL( CSenSoapMessage* apMessage, |
|
320 const TInt aTxnId, |
|
321 MSenRemoteServiceConsumer& aConsumer, |
|
322 MSenProperties* aResponseTransportProperties ) |
|
323 |
|
324 { |
|
325 //-----SCHarF ------- glue with dispather for handlers 7.5.3.2 inbound |
|
326 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SendSoapMessageToConsumerL"); |
|
327 |
|
328 |
|
329 if ( apMessage ) |
|
330 { |
|
331 CleanupStack::PushL( apMessage ); |
|
332 //dispatch to proper consumer |
|
333 CWSStarSessionConsumer* pConsumer = NULL; |
|
334 SessionConsumerL( iInContext, pConsumer ); |
|
335 if (!pConsumer) |
|
336 { |
|
337 CleanupStack::PopAndDestroy( apMessage ); // de-alloc immediately! Change this, if WS-stack one day gives back faults to Service Connections |
|
338 // No related consumer, signalize fault error |
|
339 aConsumer.HandleErrorL( NULL, KErrSenBrokenSoapEnvelope, aTxnId, aResponseTransportProperties ); |
|
340 } |
|
341 else |
|
342 { |
|
343 // handle message destroys this |
|
344 TBool completeServerMessages; |
|
345 HasFacetL(KCompleteMessagesFacet, completeServerMessages); |
|
346 CleanupStack::Pop( apMessage ); // REQUIREMENT for next method => it MUST take ownership IMMEDIATELY |
|
347 pConsumer->HandleSoapMessageL( apMessage, aTxnId, aResponseTransportProperties, completeServerMessages ); |
|
348 } |
|
349 iRetryCounter = 0; //reset counter for retryAfter faults. If proper message incomes, we can reset counter |
|
350 iRenewCounter = 0; // |
|
351 iRedirectCounter =0 ; |
|
352 delete iInContext; |
|
353 iInContext = NULL; |
|
354 return KErrNone; |
|
355 } |
|
356 else |
|
357 { |
|
358 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SendSoapMessageToConsumerL - apMessage == NULL => invoking remote consumer's HandleErrorL with KErrSenBrokenSoapEnvelope"); |
|
359 |
|
360 /*TInt retVal = */ aConsumer.HandleErrorL( NULL, KErrSenBrokenSoapEnvelope, aTxnId, aResponseTransportProperties ); |
|
361 return KErrSenInternal; |
|
362 } |
|
363 } |
|
364 |
|
365 |
|
366 |
|
367 MSenRemoteServiceConsumer* CWSStarServiceSession::RemoteConsumerL( const TDesC8& aSenderID ) |
|
368 { |
|
369 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::RemoteConsumerL"); |
|
370 TInt consumersCount(iConsumerList.Count()); |
|
371 |
|
372 for(TInt i=0; i<consumersCount; i++) |
|
373 { |
|
374 if(iConsumerList[i]->Id() == aSenderID) |
|
375 { |
|
376 return iConsumerList[i]; |
|
377 } |
|
378 } |
|
379 return NULL; // not found |
|
380 } |
|
381 |
|
382 //--------------------------------------------------------------------------- |
|
383 // To obtain consumer during processing INBOUND. |
|
384 //--------------------------------------------------------------------------- |
|
385 // |
|
386 |
|
387 TInt CWSStarServiceSession::SessionConsumerL( CWSStarMessageContext*& aMsgCtx, |
|
388 CWSStarSessionConsumer*& aSessionConsumer ) |
|
389 { |
|
390 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::SessionConsumerL"); |
|
391 TInt consumersCount(iConsumerList.Count()); |
|
392 TInt error(KErrNotFound); |
|
393 const TDesC8* relatesTo = aMsgCtx->GetDesC8L(WSStarContextKeys::KRelatesTo); |
|
394 const TDesC8* endpoint = aMsgCtx->GetDesC8L(WSStarContextKeys::KTo); |
|
395 for(TInt i=0; i<consumersCount; i++) |
|
396 { |
|
397 CWSStarSessionConsumer* pConsumer = (CWSStarSessionConsumer*)iConsumerList[i]; |
|
398 if ((relatesTo) && (pConsumer->Expects(*relatesTo, endpoint))) |
|
399 { |
|
400 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::SessionConsumerL - Found consumer"); |
|
401 aSessionConsumer = pConsumer; |
|
402 error = KErrNone; |
|
403 break; |
|
404 } |
|
405 } |
|
406 if (error && consumersCount) |
|
407 { |
|
408 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarServiceSession::SessionConsumerL - consumer was not found - using the 1st one (as default)"); |
|
409 aSessionConsumer = (CWSStarSessionConsumer*)iConsumerList[0]; |
|
410 error = KErrNone; |
|
411 } |
|
412 return error; |
|
413 } |
|
414 |
|
415 //--------------------------------------------------------------------------- |
|
416 // To obtain consumer during processing OUTBOUND. |
|
417 //--------------------------------------------------------------------------- |
|
418 // |
|
419 |
|
420 TInt CWSStarServiceSession::SessionConsumerL( const TDesC8& aSenderID, |
|
421 CWSStarSessionConsumer*& aSessionConsumer ) |
|
422 { |
|
423 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::SessionConsumerL"); |
|
424 aSessionConsumer = (CWSStarSessionConsumer*) RemoteConsumerL(aSenderID); |
|
425 if(aSessionConsumer) |
|
426 { |
|
427 return KErrNone; |
|
428 } |
|
429 else |
|
430 { |
|
431 return KErrNotFound; |
|
432 } |
|
433 } |
|
434 |
|
435 // SYNC IMPLEMENTATION(!) - only available internally. |
|
436 // It means, that all SYNC operation for 3rd developer from public API are in fact ASYNC. |
|
437 // @see SenServiceConnectionImpl.cpp |
|
438 // aSOAPMessage.IsFault() should always be TRUE. |
|
439 // |
|
440 TInt CWSStarServiceSession::HandleSoapFaultL( CSenSoapMessage* apSOAPMessage, |
|
441 HBufC8*& aResponse ) |
|
442 { |
|
443 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::HandleErrorL(CSenSoapMessage&, HBufC8*&)"); |
|
444 |
|
445 TInt retVal(KErrNone); |
|
446 |
|
447 if ( apSOAPMessage ) |
|
448 { |
|
449 CleanupStack::PushL( apSOAPMessage ); // ownerhip is here |
|
450 TInt answer = CanHandleErrorL(); |
|
451 |
|
452 if (answer == KErrSenResendRequired) |
|
453 { |
|
454 CleanupStack::PopAndDestroy( apSOAPMessage ); // not needed atm |
|
455 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CanHandleErrorL == TRUE"); |
|
456 |
|
457 CWSStarSessionConsumer* pConsumer = NULL; |
|
458 |
|
459 // this takes care of messageIDs |
|
460 retVal = SessionConsumerL(iInContext, pConsumer); |
|
461 if(!pConsumer) |
|
462 { |
|
463 CleanupStack::PopAndDestroy( apSOAPMessage ); |
|
464 return KErrNotFound; |
|
465 } |
|
466 const TDesC8* relatesTo = iInContext->GetDesC8L(WSStarContextKeys::KRelatesTo); |
|
467 if (!relatesTo) |
|
468 { |
|
469 //if response from backend doesn't include any relatesTo we can try assume |
|
470 // that response is for last outgoing message. This trick is used by passport phase |
|
471 const TInt* isPassportEnabled = iInContext->GetIntL(WSStarContextKeys::KPassportEnabled); |
|
472 if (isPassportEnabled && *isPassportEnabled == TRUE) |
|
473 { |
|
474 relatesTo = iSessionContext->GetDesC8L(WSStarContextKeys::KMessageID); |
|
475 } |
|
476 } |
|
477 if (relatesTo) |
|
478 { |
|
479 TDesC8* pBody = pConsumer->BodyL(*relatesTo); |
|
480 if (pBody) |
|
481 { |
|
482 HBufC8* pTemp = HBufC8::NewLC(pBody->Length()); |
|
483 TPtr8 temp = pTemp->Des(); |
|
484 temp.Append(*pBody); |
|
485 |
|
486 HBufC8* startBody = HBufC8::NewLC(KSenSoapEnvelopeBodyQName().Length()+ |
|
487 KSenLessThan().Length()+ |
|
488 KSenGreaterThan().Length()); |
|
489 |
|
490 TPtr8 startBodyPtr = startBody->Des(); |
|
491 startBodyPtr.Append(KSenLessThan()); |
|
492 startBodyPtr.Append(KSenSoapEnvelopeBodyQName()); |
|
493 startBodyPtr.Append(KSenGreaterThan()); |
|
494 HBufC8* endBody = HBufC8::NewLC(KSenSoapEnvelopeBodyQName().Length()+ |
|
495 KSenLessThanSlash().Length()+ |
|
496 KSenGreaterThan().Length()); |
|
497 |
|
498 TPtr8 endBodyPtr = endBody->Des(); |
|
499 endBodyPtr.Append(KSenLessThanSlash()); |
|
500 endBodyPtr.Append(KSenSoapEnvelopeBodyQName()); |
|
501 endBodyPtr.Append(KSenGreaterThan()); |
|
502 |
|
503 if( SenXmlUtils::StartsWith(*pBody, *startBody) ) |
|
504 { |
|
505 temp.Delete( 0,startBody->Length() ); |
|
506 } |
|
507 |
|
508 if( SenXmlUtils::EndsWith(*pTemp, *endBody) ) |
|
509 { |
|
510 temp.Delete( pTemp->Length()-endBody->Length(),endBody->Length() ); |
|
511 } |
|
512 |
|
513 CleanupStack::PopAndDestroy(endBody); |
|
514 CleanupStack::PopAndDestroy(startBody); |
|
515 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"Re-submitting the request"); |
|
516 //clear Id |
|
517 retVal = SubmitL(*pTemp, |
|
518 pConsumer->TransportProperties(*relatesTo), |
|
519 *pConsumer, aResponse); |
|
520 //retVal = SubmitL(*pTemp, KNullDesC8, *pConsumer, aResponse); |
|
521 CleanupStack::PopAndDestroy(pTemp); |
|
522 return retVal; |
|
523 } |
|
524 } |
|
525 } |
|
526 // In any other case, it is mean that we can not handle error, we can not |
|
527 // replace with new response. |
|
528 |
|
529 // This is a fault which WS* cannot handle |
|
530 |
|
531 // or ESenReAuthAndResendNeeded which is not supported in SYNC internal mode. |
|
532 // In other words, wst:RenewNeeded is not supported when it coems from STS. |
|
533 // It is only supported when it comes from WebService, bit such scenario |
|
534 // use only ASYNC HandleError |
|
535 |
|
536 CSenSoapFault* pDetached = apSOAPMessage->DetachFaultL(); |
|
537 CleanupStack::PopAndDestroy( apSOAPMessage ); // de-alloc msg after detach! |
|
538 TBool completeServerMessages(EFalse); |
|
539 HasFacetL(KCompleteMessagesFacet, completeServerMessages); |
|
540 |
|
541 if( pDetached ) |
|
542 { |
|
543 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"Detached a SOAP fault"); |
|
544 CleanupStack::PushL(pDetached); |
|
545 // Response contains only soapfault in case no completeServerMessages facet |
|
546 // otherwise it should be left empty |
|
547 // aResponse is updated only when detached soap fault is required. |
|
548 if(completeServerMessages == EFalse) |
|
549 { |
|
550 aResponse = pDetached->AsXmlL(); |
|
551 } |
|
552 CleanupStack::PopAndDestroy(pDetached); |
|
553 return KErrSenSoapFault; // this is 2nd OK return code! |
|
554 } |
|
555 else |
|
556 { |
|
557 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- No SOAP fault was received. Returning KErrNotFound"); |
|
558 return KErrNotFound; |
|
559 } |
|
560 } |
|
561 else // apSOAPMessage == NULL |
|
562 { |
|
563 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- Fatal(!): CWSStarServiceSession::HandleErrorL - apSOAPMessage == NULL!. Returning KErrNotFound."); |
|
564 return KErrNotFound; |
|
565 } |
|
566 } |
|
567 |
|
568 void CWSStarServiceSession::ReattachCredentialsL() |
|
569 { |
|
570 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8(" -Entering ReattachCredentialsL iStatus : %d"), iStatus)); |
|
571 |
|
572 TInt retValue = TryToSearchValidCredentialL(); |
|
573 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8(" -ReattachCredentialsL retValue : %d"), retValue)); |
|
574 if(retValue != KErrNone) |
|
575 { |
|
576 iValidUntil.Set(_L("19000101:")); // way back in history: January 1st 1900 |
|
577 iStatus = ComputeStatusL(); |
|
578 } |
|
579 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8(" -Leaving ReattachCredentialsL iStatus : %d"), iStatus)); |
|
580 } |
|
581 // ASYNC |
|
582 TInt CWSStarServiceSession::HandleSoapFaultL( CSenSoapMessage* apSOAPMessage, |
|
583 const TInt aErrorCode, // should be KErrSenSoapFault.. |
|
584 const TInt aTxnId, |
|
585 MSenRemoteServiceConsumer& aConsumer, |
|
586 MSenProperties* aResponseTransportProperties ) |
|
587 |
|
588 { |
|
589 TInt err(KErrNone); |
|
590 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::HandleErrorL(CSenSoapMessage&)"); |
|
591 |
|
592 |
|
593 if( apSOAPMessage ) |
|
594 { |
|
595 CleanupStack::PushL(apSOAPMessage); |
|
596 TInt answer = CanHandleErrorL(); |
|
597 |
|
598 if (answer) |
|
599 { |
|
600 aConsumer.HandleErrorL(NULL, answer, aTxnId, aResponseTransportProperties); |
|
601 } |
|
602 else |
|
603 { |
|
604 TBool hasFacet = EFalse; |
|
605 TInt err1 = HasFacetL(KCompleteMessagesFacet, hasFacet); |
|
606 HBufC8* pAsXml = NULL; |
|
607 if (hasFacet && (err1 == KErrNone)) |
|
608 { |
|
609 CSLOG_L(aConsumer.ConnectionId() ,KNormalLogLevel ,"Full a SOAP fault"); |
|
610 |
|
611 pAsXml = apSOAPMessage->AsXmlL(); |
|
612 } |
|
613 else |
|
614 { |
|
615 CSenSoapFault* pDetached = apSOAPMessage->DetachFaultL(); |
|
616 if(pDetached) |
|
617 { |
|
618 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"Detached a SOAP fault"); |
|
619 |
|
620 CleanupStack::PushL(pDetached); |
|
621 // pass KErrSenSoapFault // which is 2nd "OK" return code! |
|
622 pAsXml = pDetached->AsXmlL(); |
|
623 CleanupStack::PopAndDestroy(pDetached); |
|
624 } |
|
625 } |
|
626 if(pAsXml) |
|
627 { |
|
628 aConsumer.HandleErrorL(pAsXml, KErrSenSoapFault, aTxnId, aResponseTransportProperties); |
|
629 err = KErrNone; |
|
630 } |
|
631 else |
|
632 { |
|
633 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"No SOAP fault was received."); |
|
634 |
|
635 aConsumer.HandleErrorL(NULL, aErrorCode, aTxnId, aResponseTransportProperties); |
|
636 err = KErrSenInternal; // pass on the orig error code(?) |
|
637 } |
|
638 } |
|
639 CleanupStack::PopAndDestroy(apSOAPMessage); |
|
640 } |
|
641 else |
|
642 { |
|
643 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"Fatal(!): CWSStarServiceSession::HandleSoapFaultL - apSoapMessage arg is NULL."); |
|
644 |
|
645 /*TInt retVal =*/ aConsumer.HandleErrorL(NULL, aErrorCode, aTxnId, aResponseTransportProperties); |
|
646 err = KErrSenInternal; |
|
647 } |
|
648 return err; |
|
649 } |
|
650 |
|
651 TInt CWSStarServiceSession::CanHandleErrorL() |
|
652 { |
|
653 TInt answer(KErrNone); |
|
654 |
|
655 //if failedAuthentication (SCT is now switched to MT, therefore we have to resend |
|
656 const TInt* retryAfter = iSessionContext->GetIntL(WSStarContextKeys::KRetryAfter()); |
|
657 //othar case is simple retry after from service |
|
658 if (!retryAfter) |
|
659 retryAfter = iInContext->GetIntL(WSStarContextKeys::KRetryAfter()); |
|
660 const TDesC8* redirect = iInContext->GetDesC8L(WSStarContextKeys::KRedirect()); |
|
661 |
|
662 const TBool* renewNeeded = NULL; |
|
663 if (iSessionContext) |
|
664 { |
|
665 renewNeeded = iSessionContext->GetIntL(WSStarContextKeys::KReAuthNeeded()); |
|
666 } |
|
667 //temporary code, becouse its server proces, we have to leave immediatlly |
|
668 |
|
669 //retry in milisecunds |
|
670 if (retryAfter && |
|
671 *retryAfter <= WSStarSession::KMaxTimeForRetry*1000 && |
|
672 *retryAfter >= KErrNone && |
|
673 iRetryCounter < WSStarSession::KCounterMax) |
|
674 { |
|
675 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("CWSStarServiceSession::CanHandleErrorL - RETRY request with delay = %d"), *retryAfter)); |
|
676 RTimer timer; // The synchronous timer |
|
677 TRequestStatus timerStatus; // associated with timer |
|
678 timer.CreateLocal(); // Always created for this thread. |
|
679 timer.After(timerStatus,*retryAfter*1000);//in microseconds |
|
680 User::WaitForRequest(timerStatus); |
|
681 timer.Close(); |
|
682 |
|
683 iRetryCounter++; |
|
684 answer = KErrSenResendRequired; |
|
685 } |
|
686 else if((renewNeeded && *renewNeeded && |
|
687 iRenewCounter < WSStarSession::KCounterMax) |
|
688 ) |
|
689 { |
|
690 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("CWSStarServiceSession::CanHandleErrorL - RENEW request (new ticket is needed) iRenewCounter = [%d]"), iRenewCounter)) ; |
|
691 iRenewCounter++; |
|
692 answer = KErrSenReinitRequired; |
|
693 } |
|
694 else if (redirect && |
|
695 iRedirectCounter< WSStarSession::KCounterMax) |
|
696 { |
|
697 iRedirectCounter++; |
|
698 this->SetEndPointL(*redirect); |
|
699 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("CWSStarServiceSession::CanHandleErrorL - REDIRECT request iRenewCounter = [%d]"), iRedirectCounter) ); |
|
700 answer = KErrSenResendRequired; |
|
701 } |
|
702 else |
|
703 { |
|
704 iRetryCounter = 0; |
|
705 iRenewCounter = 0; |
|
706 iRedirectCounter =0; |
|
707 answer = KErrNone; |
|
708 } |
|
709 return answer; |
|
710 } |
|
711 |
|
712 TBool CWSStarServiceSession::Matches(MSenServiceDescription& aPattern) |
|
713 { |
|
714 TBool matches = CSenWebServiceSession::Matches(aPattern); |
|
715 if (!matches) return EFalse; |
|
716 |
|
717 /*HBufC8* patternClusterValue = NULL; |
|
718 TPtrC8 clusterFacetName(WSStarSession::KClusterLocalName); |
|
719 aPattern.FacetValue(clusterFacetName, patternClusterValue); |
|
720 CleanupStack::PushL(patternClusterValue); |
|
721 HBufC8* thisClusterValue = NULL; |
|
722 this->FacetValue(clusterFacetName, thisClusterValue); |
|
723 CleanupStack::PushL(thisClusterValue); |
|
724 if (!(thisClusterValue && |
|
725 patternClusterValue && |
|
726 *thisClusterValue == *patternClusterValue)) |
|
727 { |
|
728 matches = EFalse; |
|
729 } |
|
730 |
|
731 CleanupStack::PopAndDestroy(thisClusterValue); |
|
732 CleanupStack::PopAndDestroy(patternClusterValue);*/ |
|
733 |
|
734 MSenElement& xmlPatternAsElement = ((CSenWSDescription&)aPattern).AsElement(); |
|
735 |
|
736 // MSenElement* pElement = xmlPatternAsElement.Element(WSStarSession::KProviderIdElementLocalName); |
|
737 MSenElement* pElement = xmlPatternAsElement.Element( KSenIdpProviderIdLocalname ); |
|
738 //MSenElement* pElement = |
|
739 // xmlPatternAsElement.Element(WSStarSession::KProviderIdElementLocalName); |
|
740 if(pElement) |
|
741 { |
|
742 TPtrC8 patternProviderID = pElement->Content(); |
|
743 TPtrC8 thisProviderID = ProviderID(); |
|
744 if(patternProviderID.Length()>0) |
|
745 { |
|
746 if(!(thisProviderID.Length()>0 && patternProviderID == thisProviderID)) |
|
747 { |
|
748 return EFalse; |
|
749 } |
|
750 } |
|
751 } |
|
752 |
|
753 if (aPattern.DescriptionClassType() == MSenServiceDescription::EWSDescription) |
|
754 { |
|
755 TPtrC8 patternTransportCue = ((CSenWSDescription&)aPattern).TransportCue(); |
|
756 if (patternTransportCue.Length() > 0) |
|
757 { |
|
758 if(!iTransportCue || (patternTransportCue != *iTransportCue)) |
|
759 { |
|
760 return EFalse; |
|
761 } |
|
762 } |
|
763 } |
|
764 // for now the only interesting facet is the messageThread facet |
|
765 // if this session uses messageThreads it should not match any |
|
766 // description, as it essentially makes the session unique |
|
767 // (unless nobody is using this session). |
|
768 if (iMessageThread && HasConsumer()) |
|
769 { |
|
770 // a new session is needed in any case |
|
771 matches = EFalse; |
|
772 } |
|
773 else |
|
774 { |
|
775 TBool hasFacet; |
|
776 TRAPD(leaveCode, aPattern.HasFacetL(KMessageThread, hasFacet)); |
|
777 if (leaveCode != KErrNone) return EFalse; |
|
778 if (hasFacet) |
|
779 { |
|
780 if (matches && !HasConsumer()) matches = ETrue; |
|
781 else matches = EFalse; |
|
782 } |
|
783 } |
|
784 return matches; |
|
785 } |
|
786 |
|
787 TInt CWSStarServiceSession::ScoreMatchL(MSenServiceDescription& aPattern) |
|
788 { |
|
789 TInt score = CSenWebServiceSession::ScoreMatchL(aPattern); |
|
790 |
|
791 MSenElement& xmlPatternAsElement = ((CSenWSDescription&)aPattern).AsElement(); |
|
792 // MSenElement* pElement = xmlPatternAsElement.Element(WSStarSession::KProviderIdElementLocalName); |
|
793 MSenElement* pElement = xmlPatternAsElement.Element(KSenIdpProviderIdLocalname); |
|
794 // MSenElement* pElement = |
|
795 // xmlPatternAsElement.Element(WSStarSession::KProviderIdElementLocalName); |
|
796 |
|
797 if(pElement) |
|
798 { |
|
799 TPtrC8 patternProviderID = pElement->Content(); |
|
800 TPtrC8 thisProviderID = ProviderID(); |
|
801 if(patternProviderID.Length()>0) |
|
802 { |
|
803 if ( thisProviderID.Length()>0 && patternProviderID == thisProviderID ) |
|
804 { |
|
805 score++; |
|
806 } |
|
807 } |
|
808 } |
|
809 |
|
810 if (aPattern.DescriptionClassType() == MSenServiceDescription::EWSDescription) |
|
811 { |
|
812 TPtrC8 patternTransportCue = ((CSenWSDescription&)aPattern).TransportCue(); |
|
813 if (patternTransportCue.Length() > 0) |
|
814 { |
|
815 if ( iTransportCue && (patternTransportCue == *iTransportCue) ) |
|
816 { |
|
817 score++; |
|
818 } |
|
819 } |
|
820 } |
|
821 |
|
822 return score; |
|
823 } |
|
824 |
|
825 void CWSStarServiceSession::StartTransaction() |
|
826 { |
|
827 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::StartTransaction()"); |
|
828 iMessageThread = ETrue; |
|
829 } |
|
830 |
|
831 void CWSStarServiceSession::TransactionCompleted() |
|
832 { |
|
833 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::TransactionCompleted()"); |
|
834 delete ipReceivedMessageIdInTrans; |
|
835 ipReceivedMessageIdInTrans = NULL; |
|
836 iMessageThread = EFalse; |
|
837 } |
|
838 |
|
839 TInt CWSStarServiceSession::SetTransportPropertiesL(const TDesC8& aProperties, |
|
840 MSenRemoteServiceConsumer& aConsumer) |
|
841 { |
|
842 if(iTransProp) |
|
843 { |
|
844 delete iTransProp; |
|
845 iTransProp = NULL; |
|
846 } |
|
847 iTransProp = HBufC8::NewL(aProperties.Length()); |
|
848 TPtr8 ptr = iTransProp->Des(); |
|
849 ptr.Append(aProperties); |
|
850 CWSStarSessionConsumer* pConsumer = NULL; |
|
851 //senderID is internal id of consumer |
|
852 TInt error = SessionConsumerL(aConsumer.Id(), pConsumer); |
|
853 if (!error && pConsumer) |
|
854 { |
|
855 MSenTransport& tp = pConsumer->TransportL(); |
|
856 HBufC8* transProp = ApplyTransportPropertiesL(aProperties); |
|
857 CleanupStack::PushL(transProp); |
|
858 tp.SetPropertiesL(*transProp, MSenLayeredProperties::ESenTransportLayer, &aConsumer); |
|
859 CleanupStack::PopAndDestroy(transProp); |
|
860 } |
|
861 return KErrNone; |
|
862 } |
|
863 |
|
864 HBufC8* CWSStarServiceSession::ApplyTransportPropertiesL(const TDesC8& aTransportProperties) |
|
865 { |
|
866 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::ApplyTransportPropertiesL():"); |
|
867 TLSLOG_ALL(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,(aTransportProperties)); |
|
868 HBufC8* result = NULL; |
|
869 CSenXmlReader* reader = XmlReader(); |
|
870 TInt error(KErrNone); |
|
871 TPtrC8 value; |
|
872 CSenVtcpTransportProperties* vtcpTransProp = NULL; |
|
873 if (aTransportProperties.Length() <= KSenXmlPropertiesLocalname().Length()*2 |
|
874 + KSenLessThanSlash().Length() |
|
875 + KSenLessThan().Length() |
|
876 + KSenGreaterThan().Length()*2) |
|
877 { |
|
878 if (iTransProp && iTransProp->Length()) |
|
879 { |
|
880 vtcpTransProp = CSenVtcpTransportProperties::NewLC(*iTransProp, *reader); |
|
881 } |
|
882 else |
|
883 { |
|
884 vtcpTransProp = CSenVtcpTransportProperties::NewLC(); |
|
885 } |
|
886 } |
|
887 else |
|
888 { |
|
889 vtcpTransProp = CSenVtcpTransportProperties::NewLC(aTransportProperties, *reader); |
|
890 if (iTransProp) |
|
891 { |
|
892 //1 merge session and message layer transport properties |
|
893 CSenVtcpTransportProperties* conVtcpTransProp = CSenVtcpTransportProperties::NewLC(*iTransProp, *reader); |
|
894 |
|
895 //download folder |
|
896 if (vtcpTransProp->DownloadFolderL(value) == KErrNotFound) |
|
897 { |
|
898 if (conVtcpTransProp->DownloadFolderL(value) != KErrNotFound) |
|
899 { |
|
900 vtcpTransProp->SetDownloadFolderL(value); |
|
901 } |
|
902 } |
|
903 //device id |
|
904 if (vtcpTransProp->DeviceIDL(value) == KErrNotFound) |
|
905 { |
|
906 if (conVtcpTransProp->DeviceIDL(value) != KErrNotFound) |
|
907 { |
|
908 vtcpTransProp->SetDeviceIDL(value); |
|
909 } |
|
910 } |
|
911 |
|
912 if (vtcpTransProp->ProxyHostL(value) == KErrNotFound) |
|
913 { |
|
914 if (conVtcpTransProp->ProxyHostL(value) != KErrNotFound) |
|
915 { |
|
916 vtcpTransProp->SetProxyHostL(value); |
|
917 } |
|
918 } |
|
919 |
|
920 if (vtcpTransProp->MwsNamespaceL(value) == KErrNotFound) |
|
921 { |
|
922 if (conVtcpTransProp->MwsNamespaceL(value) != KErrNotFound) |
|
923 { |
|
924 vtcpTransProp->SetMwsNamespaceL(value); |
|
925 } |
|
926 } |
|
927 |
|
928 TBool boolValue; |
|
929 if (vtcpTransProp->ConnectionBoundL(boolValue) == KErrNotFound) |
|
930 { |
|
931 if (conVtcpTransProp->ConnectionBoundL(boolValue) != KErrNotFound) |
|
932 { |
|
933 vtcpTransProp->SetConnectionBoundL(boolValue); |
|
934 } |
|
935 } |
|
936 if (vtcpTransProp->OnewayMessageOnOffL(boolValue) == KErrNotFound) |
|
937 { |
|
938 if (conVtcpTransProp->OnewayMessageOnOffL(boolValue) != KErrNotFound) |
|
939 { |
|
940 vtcpTransProp->SetOnewayMessageOnOffL(boolValue); |
|
941 } |
|
942 } |
|
943 if (vtcpTransProp->BoolPropertyL(KSenIAPDoNotPrompt, boolValue) == KErrNotFound) |
|
944 { |
|
945 if (conVtcpTransProp->BoolPropertyL(KSenIAPDoNotPrompt, boolValue) != KErrNotFound) |
|
946 { |
|
947 vtcpTransProp->SetBoolPropertyL(KSenIAPDoNotPrompt, boolValue); |
|
948 } |
|
949 } |
|
950 TInt intvalue; |
|
951 if (vtcpTransProp->ConnectionTimeOutL(intvalue) == KErrNotFound) |
|
952 { |
|
953 if (conVtcpTransProp->ConnectionTimeOutL(intvalue) != KErrNotFound) |
|
954 { |
|
955 vtcpTransProp->SetConnectionTimeOutL(intvalue); |
|
956 } |
|
957 } |
|
958 if (vtcpTransProp->DeviceLCIDL(value) == KErrNotFound) |
|
959 { |
|
960 if (conVtcpTransProp->DeviceLCIDL(value) != KErrNotFound) |
|
961 { |
|
962 vtcpTransProp->SetDeviceLCIDL(value); |
|
963 } |
|
964 } |
|
965 if (vtcpTransProp->DeviceLCIDL(value) == KErrNotFound) |
|
966 { |
|
967 if (conVtcpTransProp->DeviceLCIDL(value) != KErrNotFound) |
|
968 { |
|
969 vtcpTransProp->SetDeviceLCIDL(value); |
|
970 } |
|
971 } |
|
972 if (vtcpTransProp->UserAgentL(value) == KErrNotFound) |
|
973 { |
|
974 if (conVtcpTransProp->UserAgentL(value) != KErrNotFound) |
|
975 { |
|
976 vtcpTransProp->SetUserAgentL(value); |
|
977 } |
|
978 } |
|
979 TUint32 uint32value; |
|
980 if (vtcpTransProp->IapIdL(uint32value) == KErrNotFound) |
|
981 { |
|
982 if (conVtcpTransProp->IapIdL(uint32value) != KErrNotFound) |
|
983 { |
|
984 vtcpTransProp->SetIapIdL(uint32value); |
|
985 } |
|
986 } |
|
987 if (vtcpTransProp->HeartbeatL(intvalue) == KErrNotFound) |
|
988 { |
|
989 if (conVtcpTransProp->HeartbeatL(intvalue) != KErrNotFound) |
|
990 { |
|
991 vtcpTransProp->SetHeartbeatL(intvalue); |
|
992 } |
|
993 } |
|
994 if (vtcpTransProp->MaxTimeToLiveL(intvalue) == KErrNotFound) |
|
995 { |
|
996 if (conVtcpTransProp->MaxTimeToLiveL(intvalue) != KErrNotFound) |
|
997 { |
|
998 vtcpTransProp->SetMaxTimeToLiveL(intvalue); |
|
999 } |
|
1000 } |
|
1001 if (vtcpTransProp->MinTimeToLiveL(intvalue) == KErrNotFound) |
|
1002 { |
|
1003 if (conVtcpTransProp->MinTimeToLiveL(intvalue) != KErrNotFound) |
|
1004 { |
|
1005 vtcpTransProp->SetMinTimeToLiveL(intvalue); |
|
1006 } |
|
1007 } |
|
1008 CleanupStack::PopAndDestroy(conVtcpTransProp); |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 error = vtcpTransProp->DeviceIDL(value); |
|
1016 if (error || !value.Length()) |
|
1017 { |
|
1018 value.Set(KNullDesC8()); |
|
1019 error = ((CWSStarPlugin&)iFramework).DeviceId(value); |
|
1020 if (!error) |
|
1021 { |
|
1022 vtcpTransProp->SetDeviceIDL(value); |
|
1023 } |
|
1024 } |
|
1025 if (iOutContext) |
|
1026 { |
|
1027 if (value.Length())//value of device Id |
|
1028 { |
|
1029 TPtrC8 endpoint = Contract(); |
|
1030 TInt pos = endpoint.LocateReverse(TChar('/')); |
|
1031 if (pos!=KErrNotFound) |
|
1032 { |
|
1033 TPtrC8 serviceName = endpoint.Mid(pos); |
|
1034 HBufC8* deviceId = HBufC8::NewLC(value.Length()+serviceName.Length()); |
|
1035 TPtr8 deviceIdDes = deviceId->Des(); |
|
1036 deviceIdDes.Append(value); |
|
1037 deviceIdDes.Append(serviceName); |
|
1038 iOutContext->Update(WSStarContextKeys::KReplyToDeviceAddress, *deviceId); |
|
1039 CleanupStack::PopAndDestroy(deviceId); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 iOutContext->Update(WSStarContextKeys::KReplyToDeviceAddress, value); |
|
1044 } |
|
1045 } |
|
1046 error = vtcpTransProp->ProxyHostL(value); |
|
1047 if (!error) |
|
1048 { |
|
1049 iOutContext->Update(WSStarContextKeys::KReplyTo, value); |
|
1050 } |
|
1051 #ifdef RD_SEN_VTCP_SUPPORT |
|
1052 //Proxy url CR |
|
1053 error = vtcpTransProp->PropertyL(KSenConnectionProxyUrl,value); |
|
1054 if (!error) |
|
1055 { |
|
1056 iOutContext->Update(WSStarContextKeys::KReplyTo, value); |
|
1057 } |
|
1058 #endif//RD_SEN_VTCP_SUPPORT |
|
1059 |
|
1060 error = vtcpTransProp->MwsNamespaceL(value); |
|
1061 if (!error) |
|
1062 { |
|
1063 iOutContext->Update(WSStarContextKeys::KMwsNamespace, value); |
|
1064 } |
|
1065 error = vtcpTransProp->SoapActionL(value); |
|
1066 if (!error) |
|
1067 { |
|
1068 _LIT8(KQuote, "\""); |
|
1069 |
|
1070 HBufC8* pTemp = HBufC8::NewLC(value.Length()); |
|
1071 |
|
1072 TPtr8 temp = pTemp->Des(); |
|
1073 |
|
1074 temp.Append(value); |
|
1075 |
|
1076 if(SenXmlUtils::StartsWith(value, KQuote)) |
|
1077 { |
|
1078 temp.Delete(0,KQuote().Length()); |
|
1079 } |
|
1080 |
|
1081 if(SenXmlUtils::EndsWith(*pTemp, KQuote)) |
|
1082 { |
|
1083 temp.Delete(pTemp->Length()-1,KQuote().Length()); |
|
1084 } |
|
1085 |
|
1086 iOutContext->Update(WSStarContextKeys::KAction, *pTemp); |
|
1087 CleanupStack::PopAndDestroy(pTemp); |
|
1088 } |
|
1089 //some GUI clients need messageId in GUI level :( and has control logic realted to messageId |
|
1090 error = vtcpTransProp->PropertyL( KSenClientGeneratedMessageId, value ); |
|
1091 if (!error && iOutContext) |
|
1092 { |
|
1093 iOutContext->Update(WSStarContextKeys::KMessageID, value); |
|
1094 } |
|
1095 } |
|
1096 HBufC8* updatedTP = vtcpTransProp->AsUtf8LC(); |
|
1097 CSenHttpTransportProperties* httpTransProp = NULL; |
|
1098 if (!updatedTP->Length()) |
|
1099 { |
|
1100 httpTransProp = CSenHttpTransportProperties::NewLC(); |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 httpTransProp = CSenHttpTransportProperties::NewLC(*updatedTP, *reader); |
|
1105 } |
|
1106 const TInt* soapVer = iSessionContext->GetIntL(WSStarContextKeys::KSoapVersion); |
|
1107 error = httpTransProp->SoapActionL(value); |
|
1108 if (!error && soapVer) |
|
1109 { |
|
1110 httpTransProp->ApplyBindingL((TSOAPVersion)*soapVer); |
|
1111 } |
|
1112 |
|
1113 result = httpTransProp->AsUtf8L(); |
|
1114 CleanupStack::PopAndDestroy(httpTransProp); |
|
1115 CleanupStack::PopAndDestroy(updatedTP); |
|
1116 CleanupStack::PopAndDestroy(vtcpTransProp); |
|
1117 return result; |
|
1118 } |
|
1119 |
|
1120 TInt CWSStarServiceSession::SendL( const TDesC8& aMessage, |
|
1121 const TDesC8& aTransportProperties, |
|
1122 MSenRemoteServiceConsumer& aConsumer, |
|
1123 TInt& aTxnId, |
|
1124 HBufC8*& aRevalidationError ) |
|
1125 { |
|
1126 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SendL(TDesC8&, ...)"); |
|
1127 TInt retVal(KErrNone); |
|
1128 if ( AmIHostletSession() ) |
|
1129 { |
|
1130 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"- This is a session for a hostlet."); |
|
1131 |
|
1132 retVal = CSenWebServiceSession::SendL( aMessage, aTransportProperties, aConsumer, aTxnId, aRevalidationError ); |
|
1133 CSLOG_FORMAT((aConsumer.ConnectionId(), KNormalLogLevel , _L8("- Return value from CSenWebServiceSession::SendL: %d"), retVal )); |
|
1134 |
|
1135 CSLOG_FORMAT((aConsumer.ConnectionId(), KNormalLogLevel , _L8("- Transaction ID from transport: %d"), aTxnId )); |
|
1136 |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"- This is a session for a consumer."); |
|
1141 |
|
1142 PrepareOutCtxL(aTransportProperties); |
|
1143 FindAndShareSCTL(); |
|
1144 |
|
1145 VerifyPermissionL(); |
|
1146 //we still have to check if validUntil is not expired. |
|
1147 retVal = RevalidateMobileTicketIfExpiredL( aRevalidationError ); // RefreshMTL |
|
1148 iSessionContext->Update(WSStarContextKeys::KOnlySharing, ETrue); |
|
1149 //retVal = RefreshMTL( aRevalidationError ); |
|
1150 |
|
1151 #ifdef _SENDEBUG |
|
1152 if( aRevalidationError ) |
|
1153 { |
|
1154 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"- SOAP Fault / error from re-validation:"); |
|
1155 |
|
1156 CSLOG_ALL(aConsumer.ConnectionId() ,KMinLogLevel ,( *aRevalidationError )); |
|
1157 |
|
1158 } |
|
1159 #endif // _SENDEBUG |
|
1160 if( retVal == KErrNone ) |
|
1161 { |
|
1162 delete aRevalidationError; // should ALWAYS be null in here (as retval from RevalidateMobileTicketIfExpiredL was KErrNone!) //(as retval from RefreshMT was KErrNone!) |
|
1163 aRevalidationError = NULL; |
|
1164 HBufC8* transProp = ApplyTransportPropertiesL(aTransportProperties); |
|
1165 CleanupStack::PushL(transProp); |
|
1166 retVal = CSenWebServiceSession::SendL( aMessage, *transProp, aConsumer, aTxnId, aRevalidationError ); |
|
1167 CleanupStack::PopAndDestroy(transProp); |
|
1168 } |
|
1169 //else { // if RevalidateMobileTicketIfExpiredL method provided such // } // return error code and aRevalidationError, if RefreshMT method provided such // } |
|
1170 } |
|
1171 return retVal; |
|
1172 } |
|
1173 |
|
1174 |
|
1175 TInt CWSStarServiceSession::SubmitL( const TDesC8& aMessage, |
|
1176 const TDesC8& aTransportProperties, |
|
1177 MSenRemoteServiceConsumer& aConsumer, |
|
1178 HBufC8*& aResponse ) |
|
1179 { |
|
1180 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SubmitL(TDesC8&, ...)"); |
|
1181 |
|
1182 TInt retVal(KErrNone); |
|
1183 if (!AmIHostletSession()) |
|
1184 { |
|
1185 PrepareOutCtxL(aTransportProperties); |
|
1186 HBufC8* transProp = ApplyTransportPropertiesL(aTransportProperties); |
|
1187 CleanupStack::PushL(transProp); |
|
1188 retVal = CSenWebServiceSession::SubmitL(aMessage, *transProp, aConsumer, aResponse); |
|
1189 CleanupStack::PopAndDestroy(transProp); |
|
1190 if (retVal == KErrNone) |
|
1191 { |
|
1192 iSubmitState = WSStarSession::KSubmitStateOK; |
|
1193 } |
|
1194 |
|
1195 //becouse of lack phase (dispatch to proprr consumer). |
|
1196 //It is SUBMIT nature, only used internally between Client and STS |
|
1197 //we have to make validation here |
|
1198 CWSStarSessionConsumer* consumer = NULL; |
|
1199 if (iInContext) |
|
1200 { |
|
1201 SessionConsumerL(iInContext, consumer); |
|
1202 if (!(consumer && consumer->Id() == aConsumer.Id())) |
|
1203 { |
|
1204 retVal = KErrSenBrokenSoapEnvelope; |
|
1205 } |
|
1206 } |
|
1207 } |
|
1208 return retVal; |
|
1209 } |
|
1210 |
|
1211 TInt CWSStarServiceSession::SubmitSoapL( const TDesC8& aSoapMessage, |
|
1212 const TDesC8& aTransportProperties, |
|
1213 MSenRemoteServiceConsumer& aConsumer, |
|
1214 HBufC8*& aResponse ) |
|
1215 { |
|
1216 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SubmitSoapL(TDesC8& ...)"); |
|
1217 |
|
1218 TInt retVal(KErrNone); |
|
1219 if (!AmIHostletSession()) |
|
1220 { |
|
1221 PrepareOutCtxL(aTransportProperties); |
|
1222 CSenSoapMessage* message = NULL; |
|
1223 HBufC8* body = NULL; |
|
1224 CreateAndParseSoapMessageL(aSoapMessage, message, body); |
|
1225 CleanupStack::PushL(body); |
|
1226 // message ownership transfered to MessageForSendingL |
|
1227 HBufC8* transProp = ApplyTransportPropertiesL(aTransportProperties); |
|
1228 CleanupStack::PushL(transProp); |
|
1229 |
|
1230 retVal = MessageForSendingL(*body,aConsumer.Id(),message); |
|
1231 CleanupStack::PushL(message); |
|
1232 HBufC8* pMsg = message->AsXmlL(); |
|
1233 CleanupStack::PushL(pMsg); |
|
1234 if (retVal == KErrNone) |
|
1235 { |
|
1236 retVal = CSenWebServiceSession::SubmitSoapL(*pMsg, *transProp, aConsumer, aResponse); |
|
1237 } |
|
1238 CleanupStack::PopAndDestroy(pMsg); |
|
1239 CleanupStack::PopAndDestroy(message); |
|
1240 CleanupStack::PopAndDestroy(transProp); |
|
1241 CleanupStack::PopAndDestroy(body); |
|
1242 if (retVal == KErrNone) |
|
1243 { |
|
1244 iSubmitState = WSStarSession::KSubmitStateOK; |
|
1245 } |
|
1246 |
|
1247 //becouse of lack phase (dispatch to proprr consumer). |
|
1248 //It is SUBMIT nature, only used internally between Client and STS |
|
1249 //we have to make validation here |
|
1250 CWSStarSessionConsumer* consumer = NULL; |
|
1251 if (iInContext) |
|
1252 { |
|
1253 SessionConsumerL(iInContext, consumer); |
|
1254 } |
|
1255 if (!(consumer && consumer->Id() == aConsumer.Id())) |
|
1256 { |
|
1257 retVal = KErrSenBrokenSoapEnvelope; |
|
1258 } |
|
1259 } |
|
1260 return retVal; |
|
1261 |
|
1262 } |
|
1263 |
|
1264 TInt CWSStarServiceSession::SendSoapL( const TDesC8& aSoapMessage, |
|
1265 const TDesC8& aTransportProperties, |
|
1266 MSenRemoteServiceConsumer& aConsumer, |
|
1267 TInt& aTxnId, |
|
1268 HBufC8*& aRevalidationError ) |
|
1269 { |
|
1270 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"CWSStarServiceSession::SubmitSoapL(TDesC8& ...)"); |
|
1271 |
|
1272 TInt retVal(KErrNone); |
|
1273 if ( !AmIHostletSession() ) // no support for SendSoapL in hostlet sessions |
|
1274 { |
|
1275 PrepareOutCtxL(aTransportProperties); |
|
1276 FindAndShareSCTL(); |
|
1277 VerifyPermissionL(); |
|
1278 // We still have to check if validUntil is not expired. |
|
1279 retVal = RevalidateMobileTicketIfExpiredL( aRevalidationError ); // RefreshMTL |
|
1280 iSessionContext->Update(WSStarContextKeys::KOnlySharing, ETrue); |
|
1281 //retVal = RefreshMTL( aRevalidationError ); |
|
1282 |
|
1283 #ifdef _SENDEBUG |
|
1284 if( aRevalidationError ) |
|
1285 { |
|
1286 CSLOG_L(aConsumer.ConnectionId() ,KMinLogLevel ,"- SOAP Fault / error from re-validation:"); |
|
1287 |
|
1288 CSLOG_ALL(aConsumer.ConnectionId() ,KMinLogLevel ,( *aRevalidationError )); |
|
1289 |
|
1290 } |
|
1291 #endif // _SENDEBUG |
|
1292 |
|
1293 if (retVal == KErrNone) |
|
1294 { |
|
1295 CSenSoapMessage* message = NULL; |
|
1296 HBufC8* body = NULL; |
|
1297 CreateAndParseSoapMessageL(aSoapMessage, message, body); |
|
1298 CleanupStack::PushL(body); |
|
1299 // message ownership transfered to MessageForSendingL |
|
1300 HBufC8* transProp = ApplyTransportPropertiesL(aTransportProperties); |
|
1301 CleanupStack::PushL(transProp); |
|
1302 retVal = MessageForSendingL(*body,aConsumer.Id(),message); |
|
1303 CleanupStack::PushL(message); |
|
1304 HBufC8* pMsg = message->AsXmlL(); |
|
1305 CleanupStack::PushL(pMsg); |
|
1306 ParseToSoapMessage2L( *pMsg,aConsumer,aTxnId ); |
|
1307 |
|
1308 //wslog FILELOGALL(_L("WsLog"), _L("last_req.xml"), pMsg->Des()); |
|
1309 |
|
1310 if (retVal == KErrNone) |
|
1311 { |
|
1312 delete aRevalidationError; // should ALWAYS be null in here (as retval from RevalidateMobileTicketIfExpiredL was KErrNone!)// RefreshMT was KErrNone!) |
|
1313 aRevalidationError = NULL; |
|
1314 retVal = CSenWebServiceSession::SendSoapL( *pMsg, *transProp, aConsumer, aTxnId, aRevalidationError ); |
|
1315 } |
|
1316 CleanupStack::PopAndDestroy(pMsg); |
|
1317 CleanupStack::PopAndDestroy(message); |
|
1318 CleanupStack::PopAndDestroy(transProp); |
|
1319 CleanupStack::PopAndDestroy(body); |
|
1320 } |
|
1321 //else { // re-validation failed, return an error and aRevalidationError descriptor } |
|
1322 } |
|
1323 return retVal; |
|
1324 } |
|
1325 |
|
1326 void CWSStarServiceSession::CreateAndParseSoapMessageL(const TDesC8& aSoapMessage, CSenSoapMessage*& aMessage, HBufC8*& aBody) |
|
1327 { |
|
1328 CSenXmlReader* reader = XmlReader(); |
|
1329 |
|
1330 aMessage = CSenSoapMessage::NewL(); |
|
1331 aMessage->SetReader(*reader); |
|
1332 aMessage->BuildFrom(aSoapMessage); |
|
1333 const TDesC8& uri = aMessage->NsUri(); |
|
1334 TInt version; |
|
1335 if (uri == KSenSoapEnvelopeXmlns) |
|
1336 { |
|
1337 version = ESOAP11; |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 version = ESOAP12; |
|
1342 } |
|
1343 |
|
1344 if (iOutContext) |
|
1345 { |
|
1346 iSessionContext->Update(WSStarContextKeys::KSoapVersion,version); |
|
1347 } |
|
1348 |
|
1349 CSenElement& bodyEl = aMessage->BodyL(); |
|
1350 HBufC8* bodyXml = bodyEl.AsXmlL(); |
|
1351 CleanupStack::PushL(bodyXml); |
|
1352 TInt length = bodyXml->Length(); |
|
1353 CleanupStack::PopAndDestroy(bodyXml); |
|
1354 aBody = HBufC8::NewLC(length); |
|
1355 RPointerArray<CSenElement>& elements = bodyEl.ElementsL(); |
|
1356 TPtr8 body = aBody->Des(); |
|
1357 for (TInt i=0;i<elements.Count();i++) |
|
1358 { |
|
1359 CSenElement* element = elements[i]; |
|
1360 HBufC8* elXml = element->AsXmlL(); |
|
1361 CleanupStack::PushL(elXml); |
|
1362 body.Append(*elXml); |
|
1363 CleanupStack::PopAndDestroy(elXml); |
|
1364 } |
|
1365 CleanupStack::Pop(aBody); |
|
1366 } |
|
1367 |
|
1368 TBool CWSStarServiceSession::IsExpiredL() |
|
1369 { |
|
1370 CSenServiceSession::SetStatusL(); |
|
1371 return (CSenServiceSession::StatusL() == KSenConnectionStatusExpired); |
|
1372 } |
|
1373 |
|
1374 |
|
1375 void CWSStarServiceSession::SetSessionContext(CWSStarSessionContext* aContext) |
|
1376 { |
|
1377 delete iSessionContext; |
|
1378 iSessionContext = aContext; |
|
1379 } |
|
1380 CWSStarSessionContext* CWSStarServiceSession::SessionContext() |
|
1381 { |
|
1382 return iSessionContext; |
|
1383 } |
|
1384 |
|
1385 void CWSStarServiceSession::ClearCredentialL() |
|
1386 { |
|
1387 // Before removing the credential, checkt that |
|
1388 // iCredentialPtr.Credential() != NULL |
|
1389 if ( HasSecurity() ) // this performs the NULL check for credential |
|
1390 { |
|
1391 // Remove Invalid Credential from Credentials DB |
|
1392 TInt credentialId = iCredentialPtr.Credential()->IdentifierL().IdL(); //codescannerwarnings |
|
1393 ((MSenServiceManager&)iFramework.Manager()).RemoveCredentialL(credentialId); //codescannerwarnings |
|
1394 } |
|
1395 |
|
1396 // Remove Credential usage from Session |
|
1397 SetSecurityL(KNullDesC8); |
|
1398 iValidUntil.Set(_L("18000101:")); |
|
1399 } |
|
1400 |
|
1401 TInt CWSStarServiceSession::InitializeFromL( MSenServiceDescription& aDescription, |
|
1402 CWSStarPolicyHandler* aPolicyHandler ) |
|
1403 { |
|
1404 CSenWebServiceSession::SetSecurityL(KNullDesC8); |
|
1405 iValidUntil.Set(_L("19000101:"));//from SetSecurityL()moved to here, because ID-WSF doesn't need |
|
1406 aDescription.HasFacetL(KMessageThread,iMessageThread); |
|
1407 |
|
1408 TDescriptionClassType classType = aDescription.DescriptionClassType(); |
|
1409 if( classType == MSenServiceDescription::EWSDescription |
|
1410 || |
|
1411 classType == MSenServiceDescription::EWSPattern |
|
1412 || |
|
1413 classType == MSenServiceDescription::EIdentityProvider |
|
1414 ) |
|
1415 { |
|
1416 MSenElement& xmlSdAsElement = ( |
|
1417 (CSenWSDescription*)&aDescription)->AsElement(); |
|
1418 |
|
1419 |
|
1420 MSenElement* pElement = xmlSdAsElement.Element(KSenIdpProviderIdLocalname); |
|
1421 //MSenElement* pElement = |
|
1422 // xmlSdAsElement.Element(WSStarSession::KProviderIdElementLocalName); |
|
1423 delete iProviderID; |
|
1424 iProviderID = NULL; |
|
1425 if(pElement) |
|
1426 { |
|
1427 iProviderID = pElement->Content().AllocL(); |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 CSenIdentityProvider* provider = ((CWSStarPlugin&)iFramework). |
|
1432 Manager().IdentityProviderL(aDescription); |
|
1433 if (provider) |
|
1434 { |
|
1435 iProviderID = provider->ProviderID().AllocL(); |
|
1436 } |
|
1437 } |
|
1438 pElement = xmlSdAsElement.Element(WSStarSession::KTrustAnchorElementLocalName); |
|
1439 if(pElement) |
|
1440 { |
|
1441 delete iTrustAnchor; |
|
1442 iTrustAnchor = NULL; |
|
1443 iTrustAnchor = pElement->Content().AllocL(); |
|
1444 } |
|
1445 |
|
1446 CSenXmlReader* reader = XmlReader(); |
|
1447 if (!iSessionContext) |
|
1448 { |
|
1449 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::InitializeFromL"); |
|
1450 iSessionContext = CWSStarSessionContext::NewL(reader, &aDescription, aPolicyHandler); |
|
1451 |
|
1452 pElement = xmlSdAsElement.Element(WSStarSession::KSTRLocalName); |
|
1453 if(pElement) |
|
1454 { |
|
1455 CSenElement* pNestedElement = pElement->Child(0);//assumption STR always has wsse:SecurityTokenReference |
|
1456 if (pNestedElement) |
|
1457 { |
|
1458 HBufC8* content = pNestedElement->AsXmlL(); |
|
1459 CleanupStack::PushL(content); |
|
1460 if (content) |
|
1461 { |
|
1462 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KSTR, *content)); |
|
1463 } |
|
1464 CleanupStack::PopAndDestroy(content); |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 //calling higher class load such things like iClientServerInterval |
|
1469 CSenWebServiceSession::InitializeFromL(aDescription); |
|
1470 |
|
1471 if ( StatusL() != KSenConnectionStatusReady ) |
|
1472 { |
|
1473 // Try to search Credential directly from CredentialManager |
|
1474 // if Connection/Credential is not ready |
|
1475 if ( TryToSearchValidCredentialL() == KErrNone ) //codescannerwarnings |
|
1476 { |
|
1477 SetStatusL(); |
|
1478 } |
|
1479 } |
|
1480 |
|
1481 if ( !iCredentialPtr.Credential() ) |
|
1482 { |
|
1483 pElement = xmlSdAsElement.Element(WSStarSession::KPOPBase64LocalName); |
|
1484 if(pElement) |
|
1485 { |
|
1486 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KPOPBase64, pElement->Content())); |
|
1487 } |
|
1488 pElement = xmlSdAsElement.Element(WSStarSession::KTokenType); |
|
1489 if(pElement) |
|
1490 { |
|
1491 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KTokenType, pElement->Content())); |
|
1492 } |
|
1493 pElement = xmlSdAsElement.Element(WSStarSession::KBinaryTypeLocalName); |
|
1494 if(pElement) |
|
1495 { |
|
1496 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KBinaryType, pElement->Content())); |
|
1497 } |
|
1498 pElement = xmlSdAsElement.Element(WSStarSession::KCreatedLocalName); |
|
1499 if(pElement) |
|
1500 { |
|
1501 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KTimestampCreated, pElement->Content())); |
|
1502 } |
|
1503 pElement = xmlSdAsElement.Element(WSStarSession::KPhoneTimeWhenMTResolvedLocalName); |
|
1504 if(pElement) |
|
1505 { |
|
1506 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KPhoneTimeWhenMTResolved, pElement->Content())); |
|
1507 } |
|
1508 } |
|
1509 |
|
1510 AddSecurityTokenToContextL(); |
|
1511 ActiveTicketObserverL(); |
|
1512 } |
|
1513 } |
|
1514 else |
|
1515 { |
|
1516 CSenWebServiceSession::InitializeFromL(aDescription); |
|
1517 } |
|
1518 |
|
1519 return KErrNone; |
|
1520 } |
|
1521 |
|
1522 void CWSStarServiceSession::AddSecurityTokenToContextL() |
|
1523 { |
|
1524 if ( HasSecurity() ) |
|
1525 { |
|
1526 CSenCredentialProperties& properties = iCredentialPtr.Credential()->PropertiesL(); //codescannerwarnings |
|
1527 TInt retVal; |
|
1528 TPtrC8 value; |
|
1529 if ( iSessionContext ) |
|
1530 { |
|
1531 retVal = properties.PropertyL(WSStarSession::KPOPBase64LocalName, value); |
|
1532 if ( retVal == KErrNone ) |
|
1533 { |
|
1534 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KPOPBase64, value)); |
|
1535 } |
|
1536 retVal = properties.PropertyL(WSStarSession::KTokenType, value); |
|
1537 if ( retVal == KErrNone ) |
|
1538 { |
|
1539 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KTokenType, value)); |
|
1540 } |
|
1541 retVal = properties.PropertyL(WSStarSession::KBinaryTypeLocalName, value); |
|
1542 if ( retVal == KErrNone ) |
|
1543 { |
|
1544 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KBinaryType, value)); |
|
1545 } |
|
1546 retVal = properties.PropertyL(WSStarSession::KCreatedLocalName, value); |
|
1547 if ( retVal == KErrNone ) |
|
1548 { |
|
1549 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KTimestampCreated, value)); |
|
1550 } |
|
1551 retVal = properties.PropertyL(WSStarSession::KPhoneTimeWhenMTResolvedLocalName, value); |
|
1552 if ( retVal == KErrNone ) |
|
1553 { |
|
1554 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KPhoneTimeWhenMTResolved, value)); |
|
1555 } |
|
1556 |
|
1557 HBufC8* pSecurity = SecurityL(); |
|
1558 if (pSecurity) |
|
1559 { |
|
1560 CleanupStack::PushL(pSecurity); |
|
1561 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::InitializeFromL - adding token to ctx"); |
|
1562 |
|
1563 retVal = properties.PropertyL(WSStarSession::KTokenType, value); |
|
1564 if ( retVal != KErrNone) |
|
1565 { |
|
1566 value.Set(KNullDesC8); |
|
1567 } |
|
1568 HBufC8* binarySecurityToken = |
|
1569 SenCryptoUtils::CreateEncodedBinarySecretL(*pSecurity, value); |
|
1570 CleanupStack::PopAndDestroy(pSecurity); |
|
1571 CleanupStack::PushL(binarySecurityToken); |
|
1572 User::LeaveIfError(iSessionContext->Add( |
|
1573 WSStarContextKeys::KSecurityToken, |
|
1574 *binarySecurityToken)); |
|
1575 User::LeaveIfError(iSessionContext->Add( |
|
1576 WSStarContextKeys::KSecurityTokenBackup, |
|
1577 *binarySecurityToken)); |
|
1578 CleanupStack::PopAndDestroy(binarySecurityToken); |
|
1579 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts; |
|
1580 SenDateUtils::ToXmlDateTimeUtf82L(ts, iValidUntil); |
|
1581 User::LeaveIfError(iSessionContext->Add(WSStarContextKeys::KTimestampExpires, ts)); |
|
1582 } |
|
1583 } |
|
1584 } |
|
1585 } |
|
1586 |
|
1587 void CWSStarServiceSession::WriteExtensionsAsXMLToL(RWriteStream& aWriteStream) |
|
1588 { |
|
1589 CSenWebServiceSession::WriteExtensionsAsXMLToL(aWriteStream); |
|
1590 |
|
1591 if(iProviderID) |
|
1592 { |
|
1593 aWriteStream.WriteL(WSStarSession::KProviderIDTag); |
|
1594 aWriteStream.WriteL(*iProviderID); |
|
1595 aWriteStream.WriteL(WSStarSession::KProviderIDEndTag); |
|
1596 } |
|
1597 |
|
1598 if(iTrustAnchor) |
|
1599 { |
|
1600 aWriteStream.WriteL(WSStarSession::KTrustAnchorTag); |
|
1601 aWriteStream.WriteL(*iTrustAnchor); |
|
1602 aWriteStream.WriteL(WSStarSession::KTrustAnchorEndTag); |
|
1603 } |
|
1604 |
|
1605 if(iClientServerInterval.Int64() != 0) |
|
1606 { |
|
1607 aWriteStream.WriteL(WSStarSession::KServiceInterval); |
|
1608 TBuf8<64> buf; |
|
1609 buf.AppendNum(iClientServerInterval.Int64()); |
|
1610 aWriteStream.WriteL(buf); |
|
1611 aWriteStream.WriteL(WSStarSession::KServiceIntervalEnd); |
|
1612 } |
|
1613 |
|
1614 |
|
1615 if (iSessionContext) |
|
1616 { |
|
1617 if ( iCredentialPtr.Credential() ) |
|
1618 {/* |
|
1619 CSenCredentialProperties& properties = iCredentialPtr.Credential()->Properties(); |
|
1620 const TDesC8* pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KPOPBase64); |
|
1621 if ( pValue ) |
|
1622 { |
|
1623 properties.SetPropertyL(WSStarSession::KPOPBase64LocalName(), *pValue); |
|
1624 } |
|
1625 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTokenType); |
|
1626 if ( pValue ) |
|
1627 { |
|
1628 properties.SetPropertyL(WSStarSession::KTokenType(), *pValue); |
|
1629 } |
|
1630 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KBinaryType); |
|
1631 if ( pValue ) |
|
1632 { |
|
1633 properties.SetPropertyL(WSStarSession::KBinaryTypeLocalName(), *pValue); |
|
1634 } |
|
1635 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KSTR); |
|
1636 if ( pValue ) |
|
1637 { |
|
1638 properties.SetPropertyL(WSStarSession::KSTRLocalName(), *pValue); |
|
1639 } |
|
1640 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampCreated); |
|
1641 if ( pValue ) |
|
1642 { |
|
1643 properties.SetPropertyL(WSStarSession::KCreatedLocalName(), *pValue); |
|
1644 } |
|
1645 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
1646 if ( pValue ) |
|
1647 { |
|
1648 properties.SetPropertyL(WSStarSession::KPhoneTimeWhenMTResolvedLocalName(), *pValue); |
|
1649 }*/ |
|
1650 } |
|
1651 else |
|
1652 { |
|
1653 const TDesC8* value = iSessionContext->GetDesC8L(WSStarContextKeys::KPOPBase64); |
|
1654 if(value) |
|
1655 { |
|
1656 aWriteStream.WriteL(WSStarSession::KPOPBase64Tag); |
|
1657 aWriteStream.WriteL(*value); |
|
1658 aWriteStream.WriteL(WSStarSession::KPOPBase64EndTag); |
|
1659 } |
|
1660 value = iSessionContext->GetDesC8L(WSStarContextKeys::KTokenType); |
|
1661 if(value) |
|
1662 { |
|
1663 aWriteStream.WriteL(WSStarSession::KTokenTypeTag); |
|
1664 aWriteStream.WriteL(*value); |
|
1665 aWriteStream.WriteL(WSStarSession::KTokenTypeEndTag); |
|
1666 } |
|
1667 value = iSessionContext->GetDesC8L(WSStarContextKeys::KBinaryType); |
|
1668 if(value) |
|
1669 { |
|
1670 aWriteStream.WriteL(WSStarSession::KBinaryTypeTag); |
|
1671 aWriteStream.WriteL(*value); |
|
1672 aWriteStream.WriteL(WSStarSession::KBinaryTypeEndTag); |
|
1673 } |
|
1674 value = iSessionContext->GetDesC8L(WSStarContextKeys::KSTR); |
|
1675 if(value) |
|
1676 { |
|
1677 aWriteStream.WriteL(WSStarSession::KSTRTag); |
|
1678 aWriteStream.WriteL(*value); |
|
1679 aWriteStream.WriteL(WSStarSession::KSTREndTag); |
|
1680 } |
|
1681 value = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampCreated); |
|
1682 if(value) |
|
1683 { |
|
1684 aWriteStream.WriteL(WSStarSession::KCreatedTag); |
|
1685 aWriteStream.WriteL(*value); |
|
1686 aWriteStream.WriteL(WSStarSession::KCreatedEndTag); |
|
1687 } |
|
1688 value = iSessionContext->GetDesC8L(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
1689 if(value) |
|
1690 { |
|
1691 aWriteStream.WriteL(WSStarSession::KPhoneTimeWhenMTResolvedTag); |
|
1692 aWriteStream.WriteL(*value); |
|
1693 aWriteStream.WriteL(WSStarSession::KPhoneTimeWhenMTResolvedEndTag); |
|
1694 } |
|
1695 } |
|
1696 } |
|
1697 } |
|
1698 |
|
1699 TPtrC8 CWSStarServiceSession::ProviderID() |
|
1700 { |
|
1701 if(iProviderID) |
|
1702 return *iProviderID; |
|
1703 else |
|
1704 return KNullDesC8(); |
|
1705 |
|
1706 } |
|
1707 |
|
1708 void CWSStarServiceSession::SetTrustAnchorL(const TDesC8& aURI) |
|
1709 { |
|
1710 delete iTrustAnchor; |
|
1711 iTrustAnchor = NULL; |
|
1712 iTrustAnchor = aURI.AllocL(); |
|
1713 } |
|
1714 TPtrC8 CWSStarServiceSession::TrustAnchor() |
|
1715 { |
|
1716 if(iTrustAnchor) |
|
1717 return *iTrustAnchor; |
|
1718 else |
|
1719 return KNullDesC8(); |
|
1720 } |
|
1721 |
|
1722 TInt CWSStarServiceSession::ComputeStatusL() |
|
1723 { |
|
1724 |
|
1725 TInt retVal = CSenServiceSession::ComputeStatusL(); |
|
1726 TTime createTime; |
|
1727 //we copy logic from CSenWebServiceSession and add :1) IProviderID condition |
|
1728 if ((retVal == KSenConnectionStatusReady) && iProviderID) |
|
1729 { |
|
1730 TTime now; |
|
1731 //we dont base of Mobile Time |
|
1732 //now.UniversalTime(); |
|
1733 // now for us is passportTime + X (x = interval time = now - MTObtainedTime) |
|
1734 |
|
1735 // Following check is needed, so that *primary* search for credential properties |
|
1736 // is performed from the credential (first), context search is secondary |
|
1737 // (in practice, compute status call is always performed when we have |
|
1738 // credential so this code is always executed). Requirement for this code: |
|
1739 // => This code is needed, when MT of this session has been expired, but a valid Module Test exists in DB |
|
1740 // In WebServiceSession layer, there is a search (find) logic, looking for valid Module Tests, after which |
|
1741 // the super class will call ComputeStatusL() [since WSS cannot know SIF spesific rules for validity]. |
|
1742 if ( HasSecurity() ) |
|
1743 { |
|
1744 CSenCredentialProperties& properties = iCredentialPtr.Credential()->PropertiesL(); //codescannerwarnings |
|
1745 |
|
1746 TPtrC8 createdValue; |
|
1747 TInt retVal = properties.PropertyL(WSStarSession::KCreatedLocalName, createdValue); |
|
1748 if ( retVal == KErrNone ) |
|
1749 { |
|
1750 TTime clientTime; |
|
1751 TTime mtTime; |
|
1752 TPtrC8 mtTimetd; |
|
1753 retVal = properties.PropertyL(WSStarSession::KPhoneTimeWhenMTResolvedLocalName, mtTimetd); |
|
1754 if ( retVal == KErrNone ) |
|
1755 { |
|
1756 mtTime = SenDateUtils::FromXmlDateTimeL(mtTimetd); |
|
1757 clientTime.UniversalTime(); |
|
1758 if (clientTime != Time::NullTTime()) |
|
1759 { |
|
1760 TTimeIntervalMicroSeconds diff = clientTime.MicroSecondsFrom(mtTime); |
|
1761 createTime = SenDateUtils::FromXmlDateTimeL(createdValue); |
|
1762 now = createTime; |
|
1763 if (diff > 0) |
|
1764 { |
|
1765 now += diff; |
|
1766 } |
|
1767 } |
|
1768 } |
|
1769 } |
|
1770 else |
|
1771 { |
|
1772 now.UniversalTime(); |
|
1773 } |
|
1774 } |
|
1775 else if ( iSessionContext ) |
|
1776 { |
|
1777 const TDesC8* createdValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampCreated); |
|
1778 |
|
1779 if (createdValue) |
|
1780 { |
|
1781 TTime clientTime; |
|
1782 TTime mtTime; |
|
1783 const TDesC8* mtTimetd = iSessionContext->GetDesC8L(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
1784 if (mtTimetd) |
|
1785 { |
|
1786 mtTime = SenDateUtils::FromXmlDateTimeL(*mtTimetd); |
|
1787 clientTime.UniversalTime(); |
|
1788 if (clientTime != Time::NullTTime()) |
|
1789 { |
|
1790 TTimeIntervalMicroSeconds diff = clientTime.MicroSecondsFrom(mtTime); |
|
1791 createTime = SenDateUtils::FromXmlDateTimeL(*createdValue); |
|
1792 now = createTime; |
|
1793 if (diff > 0) |
|
1794 { |
|
1795 now += diff; |
|
1796 } |
|
1797 } |
|
1798 } |
|
1799 } |
|
1800 else |
|
1801 { |
|
1802 now.UniversalTime(); |
|
1803 } |
|
1804 } |
|
1805 else |
|
1806 { |
|
1807 //for passport session, (internal session) |
|
1808 //We wil base on Device time |
|
1809 now.UniversalTime(); |
|
1810 } |
|
1811 |
|
1812 #ifdef _SENDEBUG |
|
1813 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> timeStr; |
|
1814 TRAPD(leaveCode, SenDateUtils::ToXmlDateTimeUtf82L(timeStr, now);) |
|
1815 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarServiceSession::computeStatus - now =: %S"), &timeStr)); |
|
1816 |
|
1817 TRAP(leaveCode, SenDateUtils::ToXmlDateTimeUtf82L(timeStr, createTime);) |
|
1818 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarServiceSession::computeStatus - created =: %S"), &timeStr)); |
|
1819 |
|
1820 TRAP(leaveCode, SenDateUtils::ToXmlDateTimeUtf82L(timeStr, iValidUntil);) |
|
1821 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarServiceSession::computeStatus - iValidUntil =: %S"), &timeStr)); |
|
1822 #endif |
|
1823 //HC !!!!!!!!!!!! very tricky things. Microsoft ticket always expires after 10hours event timestamps says sth different |
|
1824 /// therefore we simulate 14 hours (so one day ticket 24H -14 gives 10 magic hours) |
|
1825 /*const TInt KMSUndocumentedMinutes = 60*14; //nice for testing is 60*23+56 |
|
1826 TTimeIntervalMinutes ticketWindow; |
|
1827 iValidUntil.MinutesFrom(createTime, ticketWindow); |
|
1828 if (ticketWindow > TTimeIntervalMinutes(KMSUndocumentedMinutes)) |
|
1829 { |
|
1830 LOG_WRITE((_L("CWSStarServiceSession::computeStatus ticket window is ok"))); |
|
1831 now = now + TTimeIntervalMinutes(KMSUndocumentedMinutes); |
|
1832 } |
|
1833 else |
|
1834 { |
|
1835 |
|
1836 LOG_WRITE((_L("CWSStarServiceSession::computeStatus ticket window is too short to cut sth"))); |
|
1837 } |
|
1838 |
|
1839 |
|
1840 #ifdef _SENDEBUG |
|
1841 TRAP(leaveCode, SenDateUtils::ToXmlDateTimeUtf8L(timeStr, now);) |
|
1842 if (!leaveCode) |
|
1843 { |
|
1844 LOG_WRITEFORMAT((_L8("CWSStarServiceSession::computeStatus + fake MS 10Hours- now =: %S"), &timeStr)); |
|
1845 } |
|
1846 #endif |
|
1847 */ |
|
1848 //include also margin (3 minutes) |
|
1849 if (iValidUntil != Time::NullTTime() && |
|
1850 now > (iValidUntil - TTimeIntervalMinutes(KClockSlipMinutes))) |
|
1851 //|| |
|
1852 //(iValidUntil == Time::NullTTime() && |
|
1853 //!HasSecurity())) |
|
1854 { |
|
1855 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarServiceSession::Credential is expired."))); |
|
1856 retVal = KSenConnectionStatusExpired; |
|
1857 } |
|
1858 else |
|
1859 { |
|
1860 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarServiceSession::Credential is ok."))); |
|
1861 } |
|
1862 } |
|
1863 return retVal; |
|
1864 } |
|
1865 |
|
1866 void CWSStarServiceSession::PrepareOutCtxL(const TDesC8& aTransportProperties) |
|
1867 { |
|
1868 iClientTime.UniversalTime(); |
|
1869 |
|
1870 CSenXmlReader* reader = XmlReader(); |
|
1871 if (iOutContext) |
|
1872 { |
|
1873 delete iOutContext; |
|
1874 iOutContext = NULL; |
|
1875 } |
|
1876 iOutContext = CWSStarMessageContext::NewL(SenContext::EOutgoing, reader); |
|
1877 if (aTransportProperties != KNullDesC8) |
|
1878 { |
|
1879 iOutContext->Add(WSStarContextKeys::KWSStarTranspProp, |
|
1880 aTransportProperties); |
|
1881 } |
|
1882 } |
|
1883 |
|
1884 // This method IS USED only by ASYNC methods (serving session SendL invokations |
|
1885 // from 3rd party developer via SC) but NOT by sync methods (like internal consumers) |
|
1886 TInt CWSStarServiceSession::RevalidateMobileTicketIfExpiredL( HBufC8*& aErrorMessage ) // RefreshMTL |
|
1887 //TInt CWSStarServiceSession::RefreshMTL( HBufC8*& aErrorMessage ) |
|
1888 { |
|
1889 TInt result(KErrNone); |
|
1890 if (IsExpiredL()) |
|
1891 { |
|
1892 //we need revalidate |
|
1893 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarServiceSession::RevalidateMobileTicketIfExpiredL - revalidation is required."))); |
|
1894 //LOG_WRITE((_L("CWSStarServiceSession::RefreshMT - we have to refresh"))); |
|
1895 result = ((CWSStarPlugin&)iFramework).ProcessOutboundValidationL( *this, this, aErrorMessage ); |
|
1896 if ( result == KErrNone ) |
|
1897 { |
|
1898 // validation succeeded => serialize this session (and its credentials immediately) |
|
1899 iFramework.Manager().SaveL( *this ); // this will currently *also* serialize associated credential (new/updated MT) |
|
1900 } |
|
1901 return result; |
|
1902 } |
|
1903 //LOG_WRITE((_L("CWSStarServiceSession::RefreshMT - ticket still valid"))); |
|
1904 TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,(_L("CWSStarServiceSession::RevalidateMobileTicketIfExpiredL - ticket is still valid."))); |
|
1905 return KErrNone; |
|
1906 } |
|
1907 |
|
1908 TBool CWSStarServiceSession::HasSuperClass( TDescriptionClassType aType ) |
|
1909 { |
|
1910 if( aType == MSenServiceDescription::EWebServiceSession ) // direct superclass! |
|
1911 { |
|
1912 // If asked type is the know *direct* father/mother, return true: |
|
1913 return ETrue; |
|
1914 } |
|
1915 else |
|
1916 { |
|
1917 // Otherwise, ask from superclass (chain, recursively) |
|
1918 return CSenWebServiceSession::HasSuperClass( aType ); |
|
1919 } |
|
1920 } |
|
1921 |
|
1922 TInt CWSStarServiceSession::ShareTokenWithL( CWSStarServiceSession* aWSStarSessionDst, |
|
1923 TBool& aMTwasReplaceBySCT, |
|
1924 TBool aSeekSCT ) |
|
1925 { |
|
1926 TInt error(KErrNone); |
|
1927 if (aSeekSCT) |
|
1928 { |
|
1929 const TInt* isR = NULL; |
|
1930 isR = iSessionContext->GetIntL(WSStarContextKeys::KMTIsReplacedBySCT); |
|
1931 if (!isR || (isR && *isR == FALSE)) return KErrNotFound; |
|
1932 } |
|
1933 if ( !HasSecurity() )//if not MT than SCT for sure doesnt exist |
|
1934 { |
|
1935 return KErrNotFound; |
|
1936 } |
|
1937 //share MT (only not expired), otherway it is sensless |
|
1938 //dont call SetStatus/IsExpired becouse it will infornm consumer/Core about chnge. |
|
1939 //Session will not be able to revalidate by itself in next sending |
|
1940 if (ComputeStatusL() != KSenConnectionStatusExpired) |
|
1941 { |
|
1942 /*#ifdef _SENDEBUG |
|
1943 _LIT8(KCredsLogLine, "Token sharing FROM (%S) TO (%S)"); |
|
1944 CREDLOG_FORMAT((KSenCredsLogChannel, KSenCredsLogLevelNormal, KCredsLogLine, &Endpoint(), &(aWSStarSessionDst->Endpoint()))); |
|
1945 #endif */ |
|
1946 //share possible SCT are already in ctx |
|
1947 error = iSessionContext->ShareTokenWithL( |
|
1948 aWSStarSessionDst->SessionContext(), aMTwasReplaceBySCT); |
|
1949 |
|
1950 //HBufC8* pSecurity = SecurityL(); |
|
1951 //CleanupStack::PushL(pSecurity); |
|
1952 //aWSStarSessionDst->AddCredentialL(*pSecurity, iValidUntil);//this also recalculate state |
|
1953 aWSStarSessionDst->AddCredentialL(iCredentialPtr, iValidUntil);//this also recalculate state |
|
1954 //CleanupStack::PopAndDestroy(pSecurity); |
|
1955 return error; |
|
1956 } |
|
1957 else |
|
1958 { |
|
1959 return KErrNotFound; |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 void CWSStarServiceSession::AddCredentialL( const TDesC8& aSecurity, TTime aValidUntil ) |
|
1964 { |
|
1965 iValidUntil = aValidUntil; |
|
1966 SetSecurityL(aSecurity); |
|
1967 SetStatusL(); |
|
1968 } |
|
1969 |
|
1970 void CWSStarServiceSession::AddCredentialL(RSenCredentialPtr aCredentialPtr, TTime aValidUntil) |
|
1971 { |
|
1972 iValidUntil = aValidUntil; |
|
1973 SetCredentialPtrL(aCredentialPtr); // Share same Credential between multiple Sessions //codescannerwarnings |
|
1974 SetStatusL(); |
|
1975 } |
|
1976 |
|
1977 TBool CWSStarServiceSession::AmIHostletSession() |
|
1978 { |
|
1979 if(iTransportCue && (KSenTransportCueHostletConnection() == *iTransportCue)) |
|
1980 { |
|
1981 return ETrue; |
|
1982 } |
|
1983 return EFalse; |
|
1984 } |
|
1985 |
|
1986 void CWSStarServiceSession::FindAndShareSCTL() |
|
1987 { |
|
1988 |
|
1989 if (!iProviderID) |
|
1990 { |
|
1991 return; |
|
1992 } |
|
1993 |
|
1994 //1) check if we have already SCT |
|
1995 const TInt* isR = iSessionContext->GetIntL(WSStarContextKeys::KMTIsReplacedBySCT); |
|
1996 if (isR && *isR == TRUE) return;//SCT already exist so we dont have to share |
|
1997 |
|
1998 //2) real sharing |
|
1999 HBufC8* clusterUsed = CWSStarPolicy::GetPolicyValueL(WSPolicy::KIssuedToken, WSPolicy::KRPSCluster, (CWSStarPlugin&)iFramework, this); |
|
2000 TInt retVal(KErrNone); |
|
2001 //its mean - if our provider uses cluster template, |
|
2002 //we can SCT form other msn services which use same provider ID |
|
2003 if (clusterUsed) |
|
2004 { |
|
2005 RPointerArray<CSenWSDescription> msnSDs; |
|
2006 CleanupClosePushL(msnSDs); |
|
2007 CSenWSPattern* pattern = CSenWSPattern::NewLC(); |
|
2008 |
|
2009 //select * from session_of_SD where session is (ws* framework, and has same provideId) |
|
2010 //here we assume that provider use cluster template |
|
2011 |
|
2012 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
2013 pattern->AsElement().AddElementL(KSenIdpProviderIdLocalname).SetContentL(*iProviderID); |
|
2014 //pattern->AsElement().AddElementL(WSStarSession::KProviderIdElementLocalName).SetContentL(*iProviderID); |
|
2015 //seeking |
|
2016 CWSStarServiceSession* msnSession = NULL; |
|
2017 TRAPD(leaveError, retVal = ((CWSStarPlugin&)iFramework).Manager().ServiceDescriptionsL(msnSDs, *pattern)); |
|
2018 // Becouse they are registered without framework Id (DAO keep sessions, but in client case only SD -> see registering STSClient, DSClient..) |
|
2019 // SD matches only by enpoint and contract |
|
2020 if(!retVal && !leaveError) |
|
2021 { |
|
2022 TInt count = msnSDs.Count(); |
|
2023 TBool pMTwasReplaceBySCT = EFalse; |
|
2024 //if MT has been shared already than it happened during validation |
|
2025 // now we just looking for SCT. |
|
2026 //usecase: |
|
2027 // -----SC1::new |
|
2028 // -----SC2:new (MT sharing inside trusat client |
|
2029 // -----SC1::send (SCT is only inside SC1) |
|
2030 // -----SC2::send (now we can share SCT) |
|
2031 |
|
2032 TBool seekOnlySCT = ETrue; |
|
2033 for(TInt i = 0; i < msnSDs.Count(); i++) |
|
2034 { |
|
2035 //all sessions (so in practice we have also access to SCT, not only MT), |
|
2036 // to eliminate client, just for case we check type |
|
2037 TDescriptionClassType dt = msnSDs[i]->DescriptionClassType(); |
|
2038 if (dt == MSenServiceDescription::EWSStarServiceSession) |
|
2039 { |
|
2040 msnSession = (CWSStarServiceSession*)msnSDs[i]; |
|
2041 TRAPD(err, retVal = msnSession->ShareTokenWithL( |
|
2042 this, pMTwasReplaceBySCT, |
|
2043 seekOnlySCT)); |
|
2044 if ((retVal == KErrNone) && (err == KErrNone)) |
|
2045 { |
|
2046 if (pMTwasReplaceBySCT) |
|
2047 { |
|
2048 break; |
|
2049 } |
|
2050 } |
|
2051 } |
|
2052 } |
|
2053 } |
|
2054 CleanupStack::PopAndDestroy(2, &msnSDs); |
|
2055 } |
|
2056 delete clusterUsed; |
|
2057 } |
|
2058 |
|
2059 TInt CWSStarServiceSession::UpdatePolicyL( CWSStarPolicyHandler* aPolicyHandler, MSenServiceDescription* aSD ) |
|
2060 { |
|
2061 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::UpdatePolicyL"); |
|
2062 CWSStarSessionContext* pCtx = SessionContext(); |
|
2063 if( !pCtx ) |
|
2064 { |
|
2065 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KNormalLogLevel,"CWSStarServiceSession::UpdatePolicyL: - Attempting to create new session context"); |
|
2066 // In the future => session context exists BEFORE the session even has been created(!) |
|
2067 CSenXmlReader* reader = XmlReader(); |
|
2068 iSessionContext = CWSStarSessionContext::NewL(reader, aSD, aPolicyHandler); |
|
2069 pCtx = SessionContext(); |
|
2070 |
|
2071 if( !pCtx ) |
|
2072 { |
|
2073 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::UpdatePolicyL: - FATAL: unable to create new session context(!)."); |
|
2074 return KErrSenInternal; // very unlikely oom case (that did not leave!) / construction of ctx oddly failed |
|
2075 } |
|
2076 } |
|
2077 return pCtx->UpdatePolicyL(aPolicyHandler, aSD); |
|
2078 } |
|
2079 |
|
2080 void CWSStarServiceSession::ParseToSoapMessage2L( const TDesC8& aSoapMessage, MSenRemoteServiceConsumer& aConsumer, TInt& aTxnId ) |
|
2081 { |
|
2082 TInt ctxLookupErr(KErrNone); |
|
2083 CSenSoapMessageDom2* soapMessage2 = NULL; |
|
2084 MSenMessageContext* pCtx = aConsumer.MessageContextByTxnIdL( aTxnId, ctxLookupErr ); |
|
2085 if( ctxLookupErr == KErrNone && pCtx ) |
|
2086 { |
|
2087 soapMessage2 = (CSenSoapMessageDom2*)pCtx->MessageL(); //codescannerwarnigs |
|
2088 } |
|
2089 |
|
2090 if (!soapMessage2) |
|
2091 { |
|
2092 return; |
|
2093 } |
|
2094 CSenSoapMessageDom2* newMessage2 = CSenSoapMessageDom2::NewLC(); |
|
2095 CSenParser* parser = CSenParser::NewLC(); |
|
2096 parser->EnableFeature(EReportNamespaceMapping); |
|
2097 parser->ParseL(aSoapMessage, *newMessage2); |
|
2098 CleanupStack::PopAndDestroy(parser); |
|
2099 |
|
2100 _LIT8(KCidPrefix, "cid:*"); |
|
2101 RArray<TXmlEngElement> binaryElements; |
|
2102 RXmlEngNodeList<TXmlEngAttr> attrArray; |
|
2103 CleanupClosePushL(binaryElements); |
|
2104 TXmlEngElement rootElement = newMessage2->AsElementL(); |
|
2105 TInt countEl = ListBinaryElementsL(binaryElements,rootElement); |
|
2106 if (countEl == 0) |
|
2107 { |
|
2108 CleanupStack::PopAndDestroy(&binaryElements); |
|
2109 CleanupStack::Pop(newMessage2); |
|
2110 pCtx->SetMessage(newMessage2,ETrue); |
|
2111 return; |
|
2112 } |
|
2113 CSLOG_FORMAT((aConsumer.ConnectionId(), KMinLogLevel , _L8("- Count of <xop:Include elements> in DOM tree: %d"), countEl)); |
|
2114 |
|
2115 |
|
2116 TXmlEngAttr attr; |
|
2117 TPtrC8 cid; |
|
2118 |
|
2119 RSenDocument document = newMessage2->AsDocumentL(); |
|
2120 RSenDocument doc = soapMessage2->AsDocumentL(); |
|
2121 RArray<TXmlEngDataContainer> dataContainerArray; |
|
2122 CleanupClosePushL(dataContainerArray); |
|
2123 doc.GetDataContainerList(dataContainerArray); |
|
2124 TInt countDC(dataContainerArray.Count()); |
|
2125 |
|
2126 |
|
2127 TXmlEngElement element; |
|
2128 if ( countEl > 0 && countDC > 0 ) |
|
2129 { |
|
2130 for ( TInt i = 0; i < countEl; i++ ) |
|
2131 { |
|
2132 element = binaryElements[i]; |
|
2133 element.GetAttributes(attrArray); |
|
2134 while ( attrArray.HasNext() ) |
|
2135 { |
|
2136 attr = attrArray.Next(); |
|
2137 TPtrC8 value = attr.Value(); |
|
2138 TInt position = value.Match(KCidPrefix); |
|
2139 if ( position < 0 ) |
|
2140 { |
|
2141 position = 0; |
|
2142 } |
|
2143 cid.Set(value.Mid( position + KCidPrefix().Size() - 1)); // minus star character (*) |
|
2144 if ( cid.Length() > 0 ) |
|
2145 { |
|
2146 break; |
|
2147 } |
|
2148 } |
|
2149 attrArray.Close(); |
|
2150 |
|
2151 for ( TInt j = 0; j < countDC; j++ ) |
|
2152 { |
|
2153 TXmlEngDataContainer dataContainer = dataContainerArray[j]; |
|
2154 if ( dataContainer.Cid() == cid ) |
|
2155 { |
|
2156 if ( dataContainer.NodeType() == TXmlEngNode::EChunkContainer) |
|
2157 { |
|
2158 TXmlEngChunkContainer binData = |
|
2159 document.CreateChunkContainerL( |
|
2160 dataContainer.Cid(), |
|
2161 dataContainer.AsChunkContainer().Chunk(), |
|
2162 dataContainer.AsChunkContainer().ChunkOffset(), |
|
2163 dataContainer.AsChunkContainer().Size() ); |
|
2164 element.ReplaceWith(binData); |
|
2165 } |
|
2166 else if ( dataContainer.NodeType() == TXmlEngNode::EFileContainer) |
|
2167 { |
|
2168 TXmlEngFileContainer binData = |
|
2169 document.CreateFileContainerL( |
|
2170 dataContainer.Cid(), |
|
2171 dataContainer.AsFileContainer().File() ); |
|
2172 |
|
2173 element.ReplaceWith(binData); |
|
2174 } |
|
2175 |
|
2176 break; |
|
2177 } |
|
2178 } |
|
2179 } |
|
2180 } |
|
2181 CleanupStack::PopAndDestroy(2, &binaryElements); |
|
2182 CleanupStack::Pop(newMessage2); |
|
2183 pCtx->SetMessage(newMessage2,ETrue); |
|
2184 } |
|
2185 |
|
2186 TInt CWSStarServiceSession::ListBinaryElementsL( RArray<TXmlEngElement>& aElementArray, |
|
2187 TXmlEngElement& aElement ) |
|
2188 { |
|
2189 // TLSLOG_L(KSenCoreServiceManagerLogChannelBase, KMinLogLevel,"CWSStarServiceSession::ListBinaryElementsL"); // logged *way* TOO often! => commented out |
|
2190 _LIT8(KInclude, "Include"); |
|
2191 _LIT8(KXopIncludeUri, "http://www.w3.org/2004/08/xop/include"); |
|
2192 |
|
2193 TInt count(0); |
|
2194 RXmlEngNodeList<TXmlEngElement> list; |
|
2195 CleanupClosePushL(list); |
|
2196 aElement.GetChildElements(list); |
|
2197 TInt c = list.Count(); |
|
2198 |
|
2199 #ifdef _SENDEBUG |
|
2200 TPtrC8 root = aElement.Name(); |
|
2201 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("- Processing element: '%S', num of child elements: %d"), &root, c)); |
|
2202 TPtrC8 content = aElement.Text(); |
|
2203 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,"---- Content START ----"); |
|
2204 TLSLOG_ALL(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,(content)); |
|
2205 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,"---- Content END ----"); |
|
2206 #endif // _SENDEBUG |
|
2207 |
|
2208 |
|
2209 |
|
2210 while ( list.HasNext() ) |
|
2211 { |
|
2212 TXmlEngElement element = list.Next(); |
|
2213 |
|
2214 TPtrC8 tag = element.Name(); |
|
2215 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMaxLogLevel, _L8("- child: '%S'"), &tag)); |
|
2216 if ( tag == KInclude ) |
|
2217 { |
|
2218 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,"- <xop:Include> element found."); |
|
2219 if ( element.NamespaceUri() == KXopIncludeUri ) |
|
2220 { |
|
2221 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel,"- namespace == http://www.w3.org/2004/08/xop/include"); |
|
2222 aElementArray.AppendL(element); |
|
2223 count = count + 1; |
|
2224 } |
|
2225 } |
|
2226 count = count + ListBinaryElementsL(aElementArray, element); |
|
2227 } |
|
2228 |
|
2229 CleanupStack::PopAndDestroy(&list); |
|
2230 return count; |
|
2231 } |
|
2232 |
|
2233 void CWSStarServiceSession::FillCredentialIdentifierL(CSenCredentialIdentifier& aIdentifier) |
|
2234 { |
|
2235 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::FillCredentialIdentifierL:"); |
|
2236 CSenWebServiceSession::FillCredentialIdentifierL(aIdentifier); |
|
2237 //_LIT8(KProviderIdElementLocalName, "ProviderID"); |
|
2238 //aIdentifier.SetPropertyL(KProviderIdElementLocalName, ProviderID()); |
|
2239 |
|
2240 TPtrC8 providerId = ProviderID(); |
|
2241 aIdentifier.SetPropertyL(KSenIdpProviderIdLocalname, providerId); |
|
2242 |
|
2243 // Add information about the account that is priviledged to consume this credential |
|
2244 |
|
2245 // (a) find matching IDP description (which represents the account / userinfo) |
|
2246 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- About to call LookupIdentityProviderL"); |
|
2247 CSenIdentityProvider* pIdentityProvider = LookupIdentityProviderL(); |
|
2248 // CSenIdentityProvider* pIdentityProvider = NULL; |
|
2249 // if ( providerId != KNullDesC8 ) |
|
2250 // { |
|
2251 // LOG_WRITEFORMAT((_L8("- Searching for IdentityProvider using ProviderId : %S"), &providerId)); |
|
2252 // CSenWSDescription* pIdpPattern = CSenWSDescription::NewLC(); |
|
2253 // pIdpPattern->SetEndPointL(providerId); |
|
2254 // pIdentityProvider = iFramework.Manager().IdentityProviderL(*pIdpPattern); |
|
2255 // CleanupStack::PopAndDestroy(pIdpPattern); |
|
2256 // } |
|
2257 |
|
2258 if ( pIdentityProvider ) |
|
2259 { |
|
2260 TPtrC8 username = pIdentityProvider->UserName(); |
|
2261 if( username.Length() > 0 ) |
|
2262 { |
|
2263 aIdentifier.SetPropertyL(KSenIdpAuthzIDLocalname, username); |
|
2264 } |
|
2265 TPtrC8 password = pIdentityProvider->Password(); |
|
2266 if( password.Length() > 0 ) |
|
2267 { |
|
2268 aIdentifier.SetPropertyL(KSenIdpPasswordLocalname, password); |
|
2269 } |
|
2270 } |
|
2271 } |
|
2272 |
|
2273 void CWSStarServiceSession::VerifyPermissionL() |
|
2274 { |
|
2275 if( HasSecurity() ) |
|
2276 { |
|
2277 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::VerifyPermissionL:"); |
|
2278 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- Making call to LookupIdentityProviderL"); |
|
2279 CSenIdentityProvider* pProvider = LookupIdentityProviderL(); |
|
2280 if ( pProvider ) |
|
2281 { |
|
2282 CSenCredentialIdentifier& identifier = iCredentialPtr.Credential()->IdentifierL(); |
|
2283 TPtrC8 username; // that was used to acquire this credential |
|
2284 TInt retVal = identifier.PropertyL(KSenIdpAuthzIDLocalname, username); |
|
2285 |
|
2286 TPtrC8 password; // that was used to acquire this credential |
|
2287 retVal = identifier.PropertyL(KSenIdpPasswordLocalname, password); |
|
2288 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMaxLogLevel, _L8("=> Credential properties: username = '%S', password = '%S'"), &username, &password)); |
|
2289 |
|
2290 TPtrC8 accountUsername = pProvider->UserName(); |
|
2291 TPtrC8 accountPassword = pProvider->Password(); |
|
2292 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMaxLogLevel, _L8("=> Candidate IDP details: username = '%S', password = '%S'"), &accountUsername, &accountPassword)); |
|
2293 |
|
2294 if( ( username.Length() > 0 && username != accountUsername ) || |
|
2295 ( password.Length() > 0 && password != accountPassword ) ) |
|
2296 { |
|
2297 // either username or password DOES NOT MATCH (and the mismatching |
|
2298 // one is not zero-length string) |
|
2299 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"-> Will not grant permission to consume current credential,"); |
|
2300 |
|
2301 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel," clearing credential & it's properties from context."); |
|
2302 SetSecurityL(KNullDesC8); |
|
2303 ClearCredentialPropertiesFromContext(); |
|
2304 } |
|
2305 else |
|
2306 { |
|
2307 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"--> Permission to consume current credential is granted."); |
|
2308 // => Permission to consume this credential is granted(!) |
|
2309 } |
|
2310 } |
|
2311 else |
|
2312 { |
|
2313 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"- There is no IDP (account), clearing credential & it's properties from context."); |
|
2314 // It is not possible to consumer WS-* service(s) without IDP (account) |
|
2315 SetSecurityL(KNullDesC8); |
|
2316 ClearCredentialPropertiesFromContext(); |
|
2317 } |
|
2318 } |
|
2319 else |
|
2320 { |
|
2321 // If session has no credential (neither MT or SCT), neither should it have any |
|
2322 // related data in context(!) |
|
2323 //--> LOG_WRITE_L("- There is no credential, clearing credential properties from context."); |
|
2324 //--> SetSecurityL(KNullDesC8); |
|
2325 ClearCredentialPropertiesFromContext(); |
|
2326 } |
|
2327 } |
|
2328 |
|
2329 CSenIdentityProvider* CWSStarServiceSession::LookupIdentityProviderL() |
|
2330 { |
|
2331 TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel,"CWSStarServiceSession::LookupIdpL()"); |
|
2332 TPtrC8 providerId = ProviderID(); |
|
2333 CSenIdentityProvider* pIdentityProvider = NULL; |
|
2334 if ( providerId != KNullDesC8 ) |
|
2335 { |
|
2336 TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase , KMinLogLevel, _L8("- Searching for IdentityProvider using ProviderId : %S"), &providerId)); |
|
2337 CSenWSDescription* pIdpPattern = CSenWSDescription::NewLC(); |
|
2338 pIdpPattern->SetEndPointL(providerId); |
|
2339 pIdentityProvider = iFramework.Manager().IdentityProviderL(*pIdpPattern); |
|
2340 CleanupStack::PopAndDestroy(pIdpPattern); |
|
2341 } |
|
2342 return pIdentityProvider; |
|
2343 } |
|
2344 |
|
2345 |
|
2346 void CWSStarServiceSession::AddPropertiesFromSessionContextToCredentialL() |
|
2347 { |
|
2348 if (iSessionContext) |
|
2349 { |
|
2350 if ( iCredentialPtr.Credential() ) |
|
2351 { |
|
2352 CSenCredentialProperties& properties = iCredentialPtr.Credential()->PropertiesL(); //codescannerwarnings |
|
2353 const TDesC8* pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KPOPBase64); |
|
2354 if ( pValue ) |
|
2355 { |
|
2356 properties.SetPropertyL(WSStarSession::KPOPBase64LocalName(), *pValue); |
|
2357 } |
|
2358 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTokenType); |
|
2359 if ( pValue ) |
|
2360 { |
|
2361 properties.SetPropertyL(WSStarSession::KTokenType(), *pValue); |
|
2362 } |
|
2363 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KBinaryType); |
|
2364 if ( pValue ) |
|
2365 { |
|
2366 properties.SetPropertyL(WSStarSession::KBinaryTypeLocalName(), *pValue); |
|
2367 } |
|
2368 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KSTR); |
|
2369 if ( pValue ) |
|
2370 { |
|
2371 properties.SetPropertyL(WSStarSession::KSTRLocalName(), *pValue); |
|
2372 } |
|
2373 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampCreated); |
|
2374 if ( pValue ) |
|
2375 { |
|
2376 properties.SetPropertyL(WSStarSession::KCreatedLocalName(), *pValue); |
|
2377 } |
|
2378 pValue = iSessionContext->GetDesC8L(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
2379 if ( pValue ) |
|
2380 { |
|
2381 properties.SetPropertyL(WSStarSession::KPhoneTimeWhenMTResolvedLocalName(), *pValue); |
|
2382 } |
|
2383 |
|
2384 // Now, serialize this session (and all it's updated credentials) into database(s) |
|
2385 iFramework.Manager().SaveL( *this ); // this will currently *also* serialize associated credential (new/updated MT) |
|
2386 } |
|
2387 } |
|
2388 } |
|
2389 |
|
2390 TBool CWSStarServiceSession::HasEqualPrimaryKeysL( MSenServiceDescription& aCandidate ) |
|
2391 { |
|
2392 TBool retVal(EFalse); |
|
2393 if ( CSenWSDescription::HasEqualPrimaryKeysL(aCandidate) ) |
|
2394 { |
|
2395 // Endpoint, Contract and FrameworkID match, all of them. |
|
2396 // Now, in WS-*, also check ProviderID |
|
2397 if (aCandidate.DescriptionClassType() == DescriptionClassType()) |
|
2398 { |
|
2399 CWSStarServiceSession& sessionCandidate = (CWSStarServiceSession&)aCandidate; |
|
2400 if (sessionCandidate.ProviderID() == ProviderID()) |
|
2401 { |
|
2402 retVal = ETrue; |
|
2403 } |
|
2404 } |
|
2405 } |
|
2406 return retVal; |
|
2407 } |
|
2408 |
|
2409 void CWSStarServiceSession::CredentialChanged( TSenCredentialChange aChange, |
|
2410 TAny* apPointer ) |
|
2411 { |
|
2412 if ( aChange == MSenCredentialObserver::EDestroyed && iSessionContext ) |
|
2413 { |
|
2414 ClearCredentialPropertiesFromContext(); |
|
2415 } |
|
2416 CSenWebServiceSession::CredentialChanged( aChange, apPointer ); |
|
2417 } |
|
2418 |
|
2419 |
|
2420 void CWSStarServiceSession::ClearCredentialPropertiesFromContext() |
|
2421 { |
|
2422 if( iSessionContext ) |
|
2423 { |
|
2424 iSessionContext->Remove(WSStarContextKeys::KPOPBase64); |
|
2425 iSessionContext->Remove(WSStarContextKeys::KTokenType); |
|
2426 iSessionContext->Remove(WSStarContextKeys::KBinaryType); |
|
2427 iSessionContext->Remove(WSStarContextKeys::KSTR); |
|
2428 iSessionContext->Remove(WSStarContextKeys::KTimestampCreated); |
|
2429 iSessionContext->Remove(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
2430 iSessionContext->Remove(WSStarContextKeys::KMTIsReplacedBySCT); |
|
2431 iSessionContext->Remove(WSStarContextKeys::KSecurityToken); |
|
2432 } |
|
2433 //CSenWebServiceSession::CredentialChanged(aChange, apPointer); |
|
2434 } |
|
2435 |
|
2436 void CWSStarServiceSession::ActiveTicketObserverL() |
|
2437 { |
|
2438 const TDesC8* createdValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampCreated); |
|
2439 const TDesC8* expiresValue = iSessionContext->GetDesC8L(WSStarContextKeys::KTimestampExpires); |
|
2440 const TDesC8* phoneTimeValue = iSessionContext->GetDesC8L(WSStarContextKeys::KPhoneTimeWhenMTResolved); |
|
2441 |
|
2442 TTimeIntervalMinutes margin(KClockSlipMinutes - 1); |
|
2443 if (createdValue && expiresValue && phoneTimeValue) |
|
2444 { |
|
2445 TTime expTime, creTime, phTime, nowTime; |
|
2446 creTime = SenDateUtils::FromXmlDateTimeL(*createdValue); |
|
2447 expTime = SenDateUtils::FromXmlDateTimeL(*expiresValue); |
|
2448 phTime = SenDateUtils::FromXmlDateTimeL(*phoneTimeValue); |
|
2449 |
|
2450 creTime += margin; |
|
2451 TTimeIntervalMicroSeconds diff = expTime.MicroSecondsFrom(creTime); |
|
2452 |
|
2453 #ifdef _SENDEBUG |
|
2454 TBuf8<64> buf; |
|
2455 buf.Num( diff.Int64() ); |
|
2456 TLSLOG_FORMAT(( KSenCoreServiceManagerLogChannelBase, KNormalLogLevel, _L8("CWSStarServiceSession::ActiveTicketObserverL - range %S microsec"), &buf )); |
|
2457 #endif // _SENDEBUG |
|
2458 |
|
2459 nowTime.UniversalTime(); |
|
2460 if (nowTime != Time::NullTTime()) |
|
2461 { |
|
2462 TTimeIntervalMicroSeconds diff2 = nowTime.MicroSecondsFrom( phTime ); // already missed time |
|
2463 #ifdef _SENDEBUG |
|
2464 buf.Num( diff2.Int64() ); |
|
2465 TLSLOG_FORMAT(( KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarServiceSession::ActiveTicketObserverL - already pased %S microsec"), &buf )); |
|
2466 #endif // _SENDEBUG |
|
2467 diff = TTimeIntervalMicroSeconds( diff.Int64() - diff2.Int64() ); // Counting the real difference |
|
2468 } |
|
2469 |
|
2470 if (diff > 0) |
|
2471 { |
|
2472 iTicketObs->Start( diff );//nowTime + diff); |
|
2473 #ifdef _SENDEBUG |
|
2474 buf.Num(diff.Int64()); |
|
2475 TLSLOG_FORMAT(( KSenCoreServiceManagerLogChannelBase, KNormalLogLevel, _L8("CWSStarServiceSession::ActiveTicketObserverL - iTicketObs->Start(%S) microsec"), &buf )); |
|
2476 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts; |
|
2477 SenDateUtils::ToXmlDateTimeUtf8L(ts, nowTime + diff); |
|
2478 TLSLOG_FORMAT(( KSenCoreServiceManagerLogChannelBase , KNormalLogLevel, _L8("CWSStarServiceSession::ActiveTicketObserverL - START time %S "), &ts )); |
|
2479 #endif |
|
2480 } |
|
2481 #ifdef _SENDEBUG |
|
2482 else |
|
2483 { |
|
2484 TLSLOG_L(KSenCoreServiceManagerLogChannelBase, KMinLogLevel, "CWSStarServiceSession::ActiveTicketObserverL - SKIP - ticket expired already we don't need to wait"); |
|
2485 // ==> Validation phase will soon executed and new timer WILL BE activated |
|
2486 } |
|
2487 #endif |
|
2488 } |
|
2489 |
|
2490 } |
|
2491 // End of file |