webservices/wsoviplugin/src/wsoviservicesession.cpp
changeset 23 a1df79fa35b4
parent 1 272b002df977
equal deleted inserted replaced
16:abb636afedf7 23:a1df79fa35b4
    28 #include "SenHttpTransportProperties.h"
    28 #include "SenHttpTransportProperties.h"
    29 #include "SenDateUtils.h"
    29 #include "SenDateUtils.h"
    30 #include "sendebug.h"
    30 #include "sendebug.h"
    31 #include "senwspattern.h"
    31 #include "senwspattern.h"
    32 #include "SenXmlUtils.h"
    32 #include "SenXmlUtils.h"
    33 #include <xmlengnodelist.h> 
    33 #include <xml/dom/xmlengnodelist.h> 
    34 #include <SenHttpTransportProperties.h>
    34 #include <SenHttpTransportProperties.h>
    35 #include <SenIdentityProvider.h>
    35 #include <SenIdentityProvider.h>
    36 #include "wsovicredentialobserver.h"
    36 #include "wsovicredentialobserver.h"
    37 #include "sencryptoutils.h"
    37 #include "sencryptoutils.h"
    38 
    38 
    61     {
    61     {
    62     }
    62     }
    63 
    63 
    64 CWSOviServiceSession::~CWSOviServiceSession()
    64 CWSOviServiceSession::~CWSOviServiceSession()
    65     {
    65     {
       
    66     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::~CWSOviServiceSession()");
    66     delete iSessionContext;
    67     delete iSessionContext;
    67     delete iProviderID;
    68     delete iProviderID;
    68     delete iTrustAnchor;
    69     delete iTrustAnchor;
    69     delete iOutContext;
    70     delete iOutContext;
    70     delete iInContext;
    71     delete iInContext;
    88     delete iTokenObs;
    89     delete iTokenObs;
    89     }
    90     }
    90 
    91 
    91 void CWSOviServiceSession::ConstructL()
    92 void CWSOviServiceSession::ConstructL()
    92     {
    93     {
       
    94     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::ConstructL()");             
    93     CSenWebServiceSession::ConstructL();
    95     CSenWebServiceSession::ConstructL();
    94     iTokenObs = CWSOviCredentialObserver::NewL(this,iFramework.Manager().Log());
    96     iTokenObs = CWSOviCredentialObserver::NewL(this,iFramework.Manager().Log());
    95     }
    97     }
    96 
    98 
    97 TInt CWSOviServiceSession::AddConsumerL(MSenRemoteServiceConsumer& aConsumer)
    99 TInt CWSOviServiceSession::AddConsumerL(MSenRemoteServiceConsumer& aConsumer)
   261         {
   263         {
   262         TPtrC8 patternProviderID = pElement->Content();
   264         TPtrC8 patternProviderID = pElement->Content();
   263         TPtrC8 thisProviderID = ProviderID();
   265         TPtrC8 thisProviderID = ProviderID();
   264         if(patternProviderID.Length()>0)
   266         if(patternProviderID.Length()>0)
   265             {
   267             {
   266             if(!(thisProviderID.Length()>0 && patternProviderID == thisProviderID))
   268             if( !(thisProviderID.Length()>0 && patternProviderID == thisProviderID) )
   267                 {
   269                 {
       
   270                 TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::Matches() - Provider Id not same returning EFalse");
   268                 return EFalse;
   271                 return EFalse;
   269                 }
   272                 }
   270             }
   273             }
   271         }
   274         }
   272         
   275         
   548         AdaptEndpointL(EFalse);
   551         AdaptEndpointL(EFalse);
   549 
   552 
   550         const TDesC8* message = iOutContext->GetDesC8L(WSOviContextKeys::KMessageBody);
   553         const TDesC8* message = iOutContext->GetDesC8L(WSOviContextKeys::KMessageBody);
   551         if (message)
   554         if (message)
   552             {
   555             {
       
   556 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("CWSOviServiceSession::SubmitL() - Request"));
       
   557 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));
       
   558 	        TLSLOG_ALL(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMaxLogLevel , *message);
       
   559 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));
       
   560                     
   553             retVal = transport.SubmitL(Endpoint(), *message, *utfTP, aResponse, aConsumer);
   561             retVal = transport.SubmitL(Endpoint(), *message, *utfTP, aResponse, aConsumer);
   554             }
   562             }
   555         else
   563         else
   556             {
   564             {
       
   565 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("CWSOviServiceSession::SubmitL() - Request"));
       
   566 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));
       
   567 	        TLSLOG_ALL(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMaxLogLevel , aMessage);
       
   568 	        TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));            	
       
   569             	
   557             retVal = transport.SubmitL(Endpoint(), aMessage, *utfTP, aResponse, aConsumer);
   570             retVal = transport.SubmitL(Endpoint(), aMessage, *utfTP, aResponse, aConsumer);
   558             }   
   571             }
       
   572                
       
   573         TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("CWSOviServiceSession::SubmitL() - Response"));
       
   574         TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));
       
   575         TLSLOG_ALL(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMaxLogLevel , *aResponse);
       
   576         TLSLOG(KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel, _L8("********************************************"));
   559         
   577         
   560         MSenProperties& prop = transport.PropertiesL();
   578         MSenProperties& prop = transport.PropertiesL();
   561         ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, retVal, aResponse, &prop );
   579         ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, retVal, aResponse, &prop );
   562         
   580         
   563         AdaptEndpointL(ETrue);
   581         AdaptEndpointL(ETrue);
   586     return retVal;
   604     return retVal;
   587     }
   605     }
   588 
   606 
   589 void CWSOviServiceSession::AdaptEndpointL(TBool aToOrginal)
   607 void CWSOviServiceSession::AdaptEndpointL(TBool aToOrginal)
   590     {
   608     {
       
   609     TLSLOG_L(KSenCoreServiceManagerLogChannelBase,KMinLogLevel ,"CWSOviServiceSession::AdaptEndpointL");	
   591     TPtrC8 oldEndpoint = Endpoint();
   610     TPtrC8 oldEndpoint = Endpoint();
   592     if (aToOrginal)
   611     if (aToOrginal)
   593         {
   612         {
   594         SetEndPointL(*iOrginalEndpoint);
   613         SetEndPointL(*iOrginalEndpoint);
   595         return;
   614         return;
   631             {
   650             {
   632             newEp = HBufC8::NewLC(suffixEndpoint.Length()
   651             newEp = HBufC8::NewLC(suffixEndpoint.Length()
   633                                   +oldEndpoint.Length());
   652                                   +oldEndpoint.Length());
   634             TPtr8 ptrNewEp = newEp->Des();
   653             TPtr8 ptrNewEp = newEp->Des();
   635             ptrNewEp.Append(oldEndpoint);
   654             ptrNewEp.Append(oldEndpoint);
   636             ptrNewEp.Append(suffixEndpoint);
   655             TInt retVal = oldEndpoint.Find(suffixEndpoint);
       
   656             if(retVal == KErrNotFound)
       
   657             	{
       
   658             	ptrNewEp.Append(suffixEndpoint);
       
   659             	}
   637             SetEndPointL(*newEp);
   660             SetEndPointL(*newEp);
   638             CleanupStack::PopAndDestroy(newEp);
   661             CleanupStack::PopAndDestroy(newEp);
   639             }
   662             }
   640         }
   663         }
       
   664     TLSLOG_L(KSenCoreServiceManagerLogChannelBase,KMinLogLevel ,"CWSOviServiceSession::AdaptEndpointL Completed");
   641     }
   665     }
   642 CSenIdentityProvider* CWSOviServiceSession::IdentityProviderFromCoreL(
   666 CSenIdentityProvider* CWSOviServiceSession::IdentityProviderFromCoreL(
   643                                             const TDesC8& aProviderID)
   667                                             const TDesC8& aProviderID)
   644     {
   668     {
   645     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::IdentityProviderLFromCore");
   669     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::IdentityProviderLFromCore");
   693 TInt CWSOviServiceSession::SendToConsumerL(HBufC8* aMessage,
   717 TInt CWSOviServiceSession::SendToConsumerL(HBufC8* aMessage,
   694                               const TInt aTxnId,
   718                               const TInt aTxnId,
   695                               MSenRemoteServiceConsumer& aConsumer,
   719                               MSenRemoteServiceConsumer& aConsumer,
   696                               MSenProperties* aResponseTransportProperties)
   720                               MSenProperties* aResponseTransportProperties)
   697     {
   721     {
       
   722     TLSLOG_L(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMinLogLevel,"CWSOviServiceSession::SendToConsumerL()");
   698     ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, KErrNone, aMessage, aResponseTransportProperties);
   723     ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, KErrNone, aMessage, aResponseTransportProperties);
   699     TLSLOG_L(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMinLogLevel,"CWSOviServiceSession::ParseMessageL(CSenSoapMessage& )");
       
   700     iRenewCounter = 0;
   724     iRenewCounter = 0;
   701     iRetryCounter = 0;
   725     iRetryCounter = 0;
   702     return aConsumer.HandleMessageL( aMessage, aTxnId, aResponseTransportProperties );
   726     TInt retVal = aConsumer.HandleMessageL( aMessage, aTxnId, aResponseTransportProperties );
       
   727     return retVal;
   703     }
   728     }
   704     
   729     
   705 TInt CWSOviServiceSession::SendErrorToConsumerL( const TInt aErrorCode,
   730 TInt CWSOviServiceSession::SendErrorToConsumerL( const TInt aErrorCode,
   706                                                      HBufC8* apError,
   731                                                      HBufC8* apError,
   707                                                      const TInt aTxnId,
   732                                                      const TInt aTxnId,
   708                                                      MSenRemoteServiceConsumer& aConsumer,
   733                                                      MSenRemoteServiceConsumer& aConsumer,
   709                                                      MSenProperties* aResponseTransportProperties )
   734                                                      MSenProperties* aResponseTransportProperties )
   710     {
   735     {
   711     TLSLOG_L(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMinLogLevel,"CWSOviServiceSession::SendErrorToConsumerL");
   736     TLSLOG_L(KSenClientSessionLogChannelBase+aConsumer.ConnectionId()  , KMinLogLevel,"CWSOviServiceSession::SendErrorToConsumerL");
   712     TLSLOG_FORMAT((KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KNormalLogLevel , _L8("- ErrorCode: %d"), aErrorCode ));
   737     TLSLOG_FORMAT((KSenClientSessionLogChannelBase+aConsumer.ConnectionId(), KMinLogLevel , _L8("- ErrorCode: %d"), aErrorCode ));
   713     ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, aErrorCode, apError, aResponseTransportProperties);
   738     ((CWSOviPlugin&)iFramework).ProcessInboundDispatchL(this, aErrorCode, apError, aResponseTransportProperties);
   714     TInt answer = CanHandleErrorL();
   739     TInt answer = CanHandleErrorL();
   715     if (answer)
   740     if (answer)
   716         {
   741         {
   717         delete apError;
   742         delete apError;
   839                 pElement = xmlSdAsElement.Element(WSOviSession::KTokenCreationTimeLocalName);
   864                 pElement = xmlSdAsElement.Element(WSOviSession::KTokenCreationTimeLocalName);
   840                 if(pElement)
   865                 if(pElement)
   841                     {
   866                     {
   842                     User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenCreationTime, pElement->Content()));    
   867                     User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenCreationTime, pElement->Content()));    
   843                     }
   868                     }
       
   869                 pElement = xmlSdAsElement.Element(WSOviSession::KTokenValidUntilTimeLocalName);
       
   870                 if(pElement)
       
   871                     {
       
   872                     User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenValidUntilTime, pElement->Content()));    
       
   873                     }                    
   844                 pElement = xmlSdAsElement.Element(WSOviSession::KTTLLocalName);
   874                 pElement = xmlSdAsElement.Element(WSOviSession::KTTLLocalName);
   845                 if(pElement)
   875                 if(pElement)
   846                     {
   876                     {
   847                     User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTTL, pElement->Content()));    
   877                     User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTTL, pElement->Content()));    
   848                     }
   878                     }
   875             retVal = properties.PropertyL(WSOviSession::KTokenCreationTimeLocalName, value);
   905             retVal = properties.PropertyL(WSOviSession::KTokenCreationTimeLocalName, value);
   876             if ( retVal == KErrNone )
   906             if ( retVal == KErrNone )
   877                 {
   907                 {
   878                 User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenCreationTime, value));    
   908                 User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenCreationTime, value));    
   879                 }
   909                 }
       
   910             retVal = properties.PropertyL(WSOviSession::KTokenValidUntilTimeLocalName, value);
       
   911             if ( retVal == KErrNone )
       
   912                 {
       
   913                 User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTokenValidUntilTime, value));    
       
   914                 }               
   880             retVal = properties.PropertyL(WSOviSession::KTTLLocalName, value);
   915             retVal = properties.PropertyL(WSOviSession::KTTLLocalName, value);
   881             if ( retVal == KErrNone )
   916             if ( retVal == KErrNone )
   882                 {
   917                 {
   883                 User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTTL, value));    
   918                 User::LeaveIfError(iSessionContext->Add(WSOviContextKeys::KTTL, value));    
   884                 }
   919                 }
   912             CSenCredentialProperties& properties = iCredentialPtr.Credential()->PropertiesL();  //codescannerwarnings
   947             CSenCredentialProperties& properties = iCredentialPtr.Credential()->PropertiesL();  //codescannerwarnings
   913             const TDesC8* pValue = iSessionContext->GetDesC8L(WSOviContextKeys::KTokenCreationTime);
   948             const TDesC8* pValue = iSessionContext->GetDesC8L(WSOviContextKeys::KTokenCreationTime);
   914             if ( pValue )
   949             if ( pValue )
   915                 {
   950                 {
   916                 properties.SetPropertyL(WSOviSession::KTokenCreationTimeLocalName(), *pValue);
   951                 properties.SetPropertyL(WSOviSession::KTokenCreationTimeLocalName(), *pValue);
   917                 }        
   952                 }
       
   953             pValue = iSessionContext->GetDesC8L(WSOviContextKeys::KTokenValidUntilTime);
       
   954             if ( pValue )
       
   955                 {
       
   956                 properties.SetPropertyL(WSOviSession::KTokenValidUntilTimeLocalName(), *pValue);
       
   957                 }            
   918             pValue = iSessionContext->GetDesC8L(WSOviContextKeys::KTTL);
   958             pValue = iSessionContext->GetDesC8L(WSOviContextKeys::KTTL);
   919             if ( pValue )
   959             if ( pValue )
   920                 {
   960                 {
   921                 properties.SetPropertyL(WSOviSession::KTTLLocalName(), *pValue);
   961                 properties.SetPropertyL(WSOviSession::KTTLLocalName(), *pValue);
   922                 }        
   962                 }        
   959                 {
   999                 {
   960                 aWriteStream.WriteL(WSOviSession::KTokenCreationTimeTag);
  1000                 aWriteStream.WriteL(WSOviSession::KTokenCreationTimeTag);
   961                 aWriteStream.WriteL(*value);
  1001                 aWriteStream.WriteL(*value);
   962                 aWriteStream.WriteL(WSOviSession::KTokenCreationTimeEndTag);
  1002                 aWriteStream.WriteL(WSOviSession::KTokenCreationTimeEndTag);
   963                 }
  1003                 }
       
  1004             value = iSessionContext->GetDesC8L(WSOviContextKeys::KTokenValidUntilTime);
       
  1005             if (value)
       
  1006                 {
       
  1007                 aWriteStream.WriteL(WSOviSession::KTokenValidUntilTimeTag);
       
  1008                 aWriteStream.WriteL(*value);
       
  1009                 aWriteStream.WriteL(WSOviSession::KTokenValidUntilTimeEndTag);
       
  1010                 }                
   964             value = iSessionContext->GetDesC8L(WSOviContextKeys::KTTL);
  1011             value = iSessionContext->GetDesC8L(WSOviContextKeys::KTTL);
   965             if (value)
  1012             if (value)
   966                 {
  1013                 {
   967                 aWriteStream.WriteL(WSOviSession::KTTLTag);
  1014                 aWriteStream.WriteL(WSOviSession::KTTLTag);
   968                 aWriteStream.WriteL(*value);
  1015                 aWriteStream.WriteL(*value);
  1155         }
  1202         }
  1156     }
  1203     }
  1157 
  1204 
  1158 TInt CWSOviServiceSession::ShareTokenWithL( CWSOviServiceSession* aWSOviSessionDst)
  1205 TInt CWSOviServiceSession::ShareTokenWithL( CWSOviServiceSession* aWSOviSessionDst)
  1159     {
  1206     {
       
  1207     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::ShareTokenWithL()");
  1160     TInt error(KErrNone);
  1208     TInt error(KErrNone);
  1161     if ( !HasSecurity() )
  1209     if ( !HasSecurity() )
  1162         {
  1210         {
  1163         return KErrNotFound;
  1211         return KErrNotFound;
  1164         }
  1212         }
  1174         aWSOviSessionDst->AddCredentialL(iCredentialPtr, iValidUntil);
  1222         aWSOviSessionDst->AddCredentialL(iCredentialPtr, iValidUntil);
  1175         return error;
  1223         return error;
  1176         }
  1224         }
  1177     else
  1225     else
  1178         {
  1226         {
       
  1227         TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::ShareTokenWithL() returning KErrNotFound");
  1179         return KErrNotFound;
  1228         return KErrNotFound;
  1180         }
  1229         }
  1181     }
  1230     }
  1182     
  1231     
  1183 void CWSOviServiceSession::AddCredentialL( const TDesC8& aSecurity, TTime aValidUntil )
  1232 void CWSOviServiceSession::AddCredentialL( const TDesC8& aSecurity, TTime aValidUntil )
  1184     {
  1233     {
       
  1234     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::AddCredentialL(aSecurity, aValidUntil)");
  1185     iValidUntil = aValidUntil;
  1235     iValidUntil = aValidUntil;
  1186     SetSecurityL(aSecurity);
  1236     SetSecurityL(aSecurity);
  1187     SetStatusL();
  1237     SetStatusL();
       
  1238     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::AddCredentialL(aSecurity, aValidUntil) Completed");
  1188     }
  1239     }
  1189     
  1240     
  1190 void CWSOviServiceSession::AddCredentialL(RSenCredentialPtr aCredentialPtr, TTime aValidUntil)
  1241 void CWSOviServiceSession::AddCredentialL(RSenCredentialPtr aCredentialPtr, TTime aValidUntil)
  1191     {
  1242     {
       
  1243     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::AddCredentialL(aCredentialPtr, aValidUntil)");
  1192     iValidUntil = aValidUntil;
  1244     iValidUntil = aValidUntil;
  1193     SetCredentialPtrL(aCredentialPtr); // Share same Credential between multiple Sessions	//codescannerwarnings
  1245     SetCredentialPtrL(aCredentialPtr); // Share same Credential between multiple Sessions	//codescannerwarnings
  1194     SetStatusL();
  1246     SetStatusL();
       
  1247     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviServiceSession::AddCredentialL(aCredentialPtr, aValidUntil) Completed");
  1195     }
  1248     }
  1196     
  1249     
  1197 TBool CWSOviServiceSession::AmIHostletSession()
  1250 TBool CWSOviServiceSession::AmIHostletSession()
  1198     {
  1251     {
  1199     if(iTransportCue && (KSenTransportCueHostletConnection() == *iTransportCue))
  1252     if(iTransportCue && (KSenTransportCueHostletConnection() == *iTransportCue))
  1356     {
  1409     {
  1357     if( iSessionContext )
  1410     if( iSessionContext )
  1358         {
  1411         {
  1359         iSessionContext->Remove(WSOviContextKeys::KToken);    
  1412         iSessionContext->Remove(WSOviContextKeys::KToken);    
  1360         iSessionContext->Remove(WSOviContextKeys::KTokenCreationTime);
  1413         iSessionContext->Remove(WSOviContextKeys::KTokenCreationTime);
       
  1414         iSessionContext->Remove(WSOviContextKeys::KTokenValidUntilTime);
  1361         iSessionContext->Remove(WSOviContextKeys::KTTL);
  1415         iSessionContext->Remove(WSOviContextKeys::KTTL);
  1362         iSessionContext->Remove(WSOviContextKeys::KTokenSecret);
  1416         iSessionContext->Remove(WSOviContextKeys::KTokenSecret);
  1363         }
  1417         }
  1364     }
  1418     }
  1365 void CWSOviServiceSession::SetMaxValidUntil()
  1419 void CWSOviServiceSession::SetMaxValidUntil()