Revision: 201023 RCL_3 PDK_3.0.1
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 16:54:52 +0300
branchRCL_3
changeset 30 b72ea8487adb
parent 22 56092bff76ba
child 34 f68f07157250
Revision: 201023 Kit: 2010125
webservices/wsoviplugin/inc/wsovioauthclient.h
webservices/wsoviplugin/inc/wsoviutils.h
webservices/wsoviplugin/src/wsovioauthclient.cpp
webservices/wsoviplugin/src/wsoviutils.cpp
--- a/webservices/wsoviplugin/inc/wsovioauthclient.h	Wed Jun 09 10:53:28 2010 +0300
+++ b/webservices/wsoviplugin/inc/wsovioauthclient.h	Mon Jun 21 16:54:52 2010 +0300
@@ -118,7 +118,7 @@
     void SetHandlerCtx(MSenHandlerContext* aHndCtx);
     
     TBool HasSuperClass( TDescriptionClassType aType );
-    void CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated);
+    void CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated, const TDesC8& aValidator=KNullDesC8);
         
 protected://methods
     
--- a/webservices/wsoviplugin/inc/wsoviutils.h	Wed Jun 09 10:53:28 2010 +0300
+++ b/webservices/wsoviplugin/inc/wsoviutils.h	Mon Jun 21 16:54:52 2010 +0300
@@ -46,10 +46,10 @@
                 
         // New functions
 		static HBufC8* NormalizeStringLC(const TDesC8& aMethod, const TDesC8& aUrl, const TDesC8& aHeader );
-		static HBufC8* DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword);
+		static HBufC8* DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword, const TDesC8& aValidator = KNullDesC8);
         static HBufC8* EncodeCharsLC(const TDesC8& aString);
         static HBufC8* FormEncodeCharsLC(const TDesC8& aString);
-
+        static HBufC8* GenerateValidatorL(const TDesC8& aUser, const TDesC8& aPassword);
     private:
 
 		~CWSOviUtils();       
--- a/webservices/wsoviplugin/src/wsovioauthclient.cpp	Wed Jun 09 10:53:28 2010 +0300
+++ b/webservices/wsoviplugin/src/wsovioauthclient.cpp	Mon Jun 21 16:54:52 2010 +0300
@@ -231,15 +231,33 @@
         
         TPtrC8 userName(KNullDesC8);
         TPtrC8 password(KNullDesC8);
+		TPtrC8 validator(KNullDesC8);
         if ( authenticationInfoPromptedFromUser )
             {
+		     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel," --- Setting username/password from authenticationInfoPromptedFromUser");
             userName.Set(authInfo().iUsername);
             password.Set(authInfo().iPassword);
             }
         else
             {
+		     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel," --- Setting username/password from IDP");
             userName.Set(iIdentityProvider->UserName());
             password.Set(iIdentityProvider->Password());
+
+			/* Below code will be required when we need to get validator from IDP but Now Crashes */
+			/*CSenElement* validatorTag(NULL);
+			if (iIdentityProvider->FrameworkId() == KDefaultOviFrameworkID)
+				{
+				CSenElement* el( NULL );
+				iIdentityProvider->AccountExtensions( el );
+				if (el)
+					{
+					_LIT8(KWSAccAttrAccountValidator,      "Validator");
+					validatorTag = el->Element(KWSAccAttrAccountValidator);
+					validator.Set(validatorTag->Content());
+				        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSOviOAuthClient::ValidateL() - NCIM Valiadtor read successfully");
+					}
+				}*/
             }
         HBufC8* created(NULL);
         //CWSOviSessionContext* sessioncontext = iWSOviServiceSession->SessionContext();
@@ -259,7 +277,8 @@
         CreateBodyL(*version,
                     userName,
                     password,
-					*created);
+			*created/*,
+			validator*/);
         CleanupStack::PopAndDestroy(created);
 
         
@@ -372,10 +391,12 @@
             time -= TTimeIntervalMicroSeconds(diff.Int64());
             HBufC8* created = SenCryptoUtils::GetTimestampL(time);
             CleanupStack::PushL(created);
+							
             CreateBodyL(*version,
                         userName,
                         password,
-                        *created);
+                        *created/*,
+			validator*/);
             CleanupStack::PopAndDestroy(created);
             retVal = iAuthSession->SubmitL(*iBody, *transPropAsXml, *this, response);
             aSession.SetTransportL(ipTransport);//ownership moved
@@ -733,7 +754,7 @@
     return retVal; 
     }
 
-void CWSOviOAuthClient::CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated)
+void CWSOviOAuthClient::CreateBodyL(const TDesC8& aXmlNs, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aCreated, const TDesC8& aValidator)
     {
     if(aPassword == KNullDesC8())
     	{
@@ -744,7 +765,8 @@
     HBufC8* nonce = SenCryptoUtils::GetRandomNonceL();
     CleanupStack::PushL(nonce);
     HBufC8* passDec = SenXmlUtils::DecodeHttpCharactersLC( aPassword );
-    HBufC8* digest = CWSOviUtils::DigestAuthStringL(*nonce, aCreated, aUsername, *passDec);
+	HBufC8* digest = CWSOviUtils::DigestAuthStringL(*nonce, aCreated, aUsername, *passDec, aValidator);
+
     CleanupStack::PopAndDestroy(passDec);
     CleanupStack::PushL(digest);
                     
--- a/webservices/wsoviplugin/src/wsoviutils.cpp	Wed Jun 09 10:53:28 2010 +0300
+++ b/webservices/wsoviplugin/src/wsoviutils.cpp	Mon Jun 21 16:54:52 2010 +0300
@@ -84,7 +84,7 @@
 	return pNormalizedString;
 	}
 
-HBufC8* CWSOviUtils::DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword)
+HBufC8* CWSOviUtils::GenerateValidatorL(const TDesC8& aUser, const TDesC8& aPassword)
 	{
 	_LIT8(KFormatUser, "/accounts/%S/");
 	HBufC8* validatorString = HBufC8::NewLC(KFormatUser().Length()+aUser.Length());
@@ -93,17 +93,40 @@
 	CSHA1* sha1 = CSHA1::NewL();
 	sha1->Update(*validatorString);
 	TPtrC8 validator = sha1->Final(aPassword);
-	CleanupStack::PopAndDestroy(validatorString);
+	CleanupStack::PopAndDestroy(validatorString);		
 	CleanupStack::PushL(sha1);
 	HBufC8* base64validator = SenCryptoUtils::EncodeBase64L(validator);
-	sha1->Reset();
-	sha1->Update(aNonce);
-	sha1->Update(aTimestamp);
-	TPtrC8 digest = sha1->Final(*base64validator);
-	delete base64validator;
-	HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest);
 	CleanupStack::PopAndDestroy(sha1);
-	return digestBase64;
+	return base64validator;
+	}
+
+HBufC8* CWSOviUtils::DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword, const TDesC8& aValidator )
+	{
+	if ( aValidator == KNullDesC8 )
+		{
+		CSHA1* sha1 = CSHA1::NewL();
+		CleanupStack::PushL(sha1);
+		HBufC8* base64validator = GenerateValidatorL(aUser, aPassword);
+		//sha1->Reset();
+		sha1->Update(aNonce);
+		sha1->Update(aTimestamp);
+		TPtrC8 digest = sha1->Final(*base64validator);
+		delete base64validator;
+		HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest);
+		CleanupStack::PopAndDestroy(sha1);
+		return digestBase64;
+		}
+	else
+		{
+		CSHA1* sha1 = CSHA1::NewL();
+		CleanupStack::PushL(sha1);
+		sha1->Update(aNonce);
+		sha1->Update(aTimestamp);		
+		TPtrC8 digest = sha1->Final(aValidator);
+		HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest);
+		CleanupStack::PopAndDestroy(sha1);
+		return digestBase64;
+		}
 	}