webservices/wsoviplugin/src/wsovioauthclient.cpp
changeset 23 a1df79fa35b4
parent 1 272b002df977
equal deleted inserted replaced
16:abb636afedf7 23:a1df79fa35b4
    38 #include "senwspattern.h"
    38 #include "senwspattern.h"
    39 #include "wsovicons.h"
    39 #include "wsovicons.h"
    40 #include "wsovitokencreationresponse.h"
    40 #include "wsovitokencreationresponse.h"
    41 #include "sencryptoutils.h"
    41 #include "sencryptoutils.h"
    42 #include "wsoviutils.h"
    42 #include "wsoviutils.h"
       
    43 #include <SenDateUtils.h>
    43 
    44 
    44 namespace 
    45 namespace 
    45     {
    46     {
    46     _LIT8(KRemoteConsumer,       "RemoteConsumer");
    47     _LIT8(KRemoteConsumer,       "RemoteConsumer");
    47     }
    48     }
    98 // Destructor
    99 // Destructor
    99 //---------------------------------------------------------------------------
   100 //---------------------------------------------------------------------------
   100 //
   101 //
   101 CWSOviOAuthClient::~CWSOviOAuthClient()
   102 CWSOviOAuthClient::~CWSOviOAuthClient()
   102     {
   103     {
   103     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviOAuthClient::~CWSOviTrustClient");
   104     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviOAuthClient::~CWSOviOAuthClient");
   104     delete iAuthSession;
   105     delete iAuthSession;
   105     delete iBody;
   106     delete iBody;
   106     }
   107     }
   107 
   108 
   108 
   109 
   528 	        retVal = KErrNotFound;
   529 	        retVal = KErrNotFound;
   529 	        }
   530 	        }
   530 	    else
   531 	    else
   531 	        {
   532 	        {
   532 	        iWSOviServiceSession->SetTrustAnchorL(iIdentityProvider->ProviderID());
   533 	        iWSOviServiceSession->SetTrustAnchorL(iIdentityProvider->ProviderID());
   533 	            TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviOAuthClient::ValidateL - set ctx basing on response");
   534 	        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviOAuthClient::ValidateL - set ctx basing on response");
       
   535 	        
       
   536 		    TPtrC8 validUntil = responseFragment->ValidUntil();
       
   537 		    if (validUntil.Length())
       
   538 		        {
       
   539 		        TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,validUntil);
       
   540 		        User::LeaveIfError(iWSOviServiceSession->SessionContext()->Update(WSOviContextKeys::KTokenValidUntilTime,validUntil));
       
   541 		        }
       
   542 			else
       
   543 				{
       
   544 				TTime tmpValidUntil = Time::MaxTTime();
       
   545 				TBuf8<SenDateUtils::KXmlDateTimeMaxLength> pValidUntil;
       
   546 				SenDateUtils::ToXmlDateTimeUtf8L(pValidUntil, tmpValidUntil);
       
   547 		        User::LeaveIfError(iWSOviServiceSession->SessionContext()->Update(WSOviContextKeys::KTokenValidUntilTime,pValidUntil));				
       
   548 				}	
       
   549 	        
   534 	        retVal = iWSOviServiceSession->SessionContext()->SetTokenKeysL(token);
   550 	        retVal = iWSOviServiceSession->SessionContext()->SetTokenKeysL(token);
   535 	        if (retVal)
   551 	        if (retVal)
   536 	            {
   552 	            {
   537 	            aErrorMessage = response;
   553 	            aErrorMessage = response;
   538 	            }
   554 	            }
   717     return retVal; 
   733     return retVal; 
   718     }
   734     }
   719 
   735 
   720 void CWSOviOAuthClient::CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated)
   736 void CWSOviOAuthClient::CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated)
   721     {
   737     {
       
   738     if(aPassword == KNullDesC8())
       
   739     	{
       
   740     	TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviOAuthClient::CreateBodyL() - aPassword == KNullDesC8")));
       
   741     	}
   722     delete iBody;
   742     delete iBody;
   723     iBody = NULL;
   743     iBody = NULL;
   724     HBufC8* nonce = SenCryptoUtils::GetRandomNonceL();
   744     HBufC8* nonce = SenCryptoUtils::GetRandomNonceL();
   725     CleanupStack::PushL(nonce);
   745     CleanupStack::PushL(nonce);
   726     HBufC8* passDec = SenXmlUtils::DecodeHttpCharactersLC( aPassword );
   746     HBufC8* passDec = SenXmlUtils::DecodeHttpCharactersLC( aPassword );