syncmlfw/common/syncagent/src/NSmlAgentBase.cpp
changeset 35 0deca9b72b62
parent 32 5d0ec111abfc
child 60 eb6690d0d439
equal deleted inserted replaced
32:5d0ec111abfc 35:0deca9b72b62
   131 	clearTextPtr = *userName;
   131 	clearTextPtr = *userName;
   132 	clearTextPtr += KColon;
   132 	clearTextPtr += KColon;
   133 	clearTextPtr += *password;
   133 	clearTextPtr += *password;
   134 	HBufC8* B64String = HBufC8::NewLC( clearText->Length() * 2 );
   134 	HBufC8* B64String = HBufC8::NewLC( clearText->Length() * 2 );
   135 	TPtr8 B64StringPtr( B64String->Des() );
   135 	TPtr8 B64StringPtr( B64String->Des() );
   136 	User::LeaveIfError( B64Coder.Encode( *clearText, B64StringPtr ) );
   136 	User::LeaveIfError( B64Coder.PortableEncode( *clearText, B64StringPtr ) );
   137 	CleanupStack::Pop(); // B64String
   137 	CleanupStack::Pop(); // B64String
   138 	CleanupStack::PopAndDestroy( 3 ); //clearText, password, userName
   138 	CleanupStack::PopAndDestroy( 3 ); //clearText, password, userName
   139 	return B64String;
   139 	return B64String;
   140 	}
   140 	}
   141 	
   141 	
   188 	userNamePasswordPtr += *password;
   188 	userNamePasswordPtr += *password;
   189 	TPtrC8 userNamePasswordHash;
   189 	TPtrC8 userNamePasswordHash;
   190 	userNamePasswordHash.Set( md5->Hash( *userNamePassword ) );
   190 	userNamePasswordHash.Set( md5->Hash( *userNamePassword ) );
   191 	HBufC8* B64UserNamePasswordString = HBufC8::NewLC( userNamePasswordHash.Length() * 2 );
   191 	HBufC8* B64UserNamePasswordString = HBufC8::NewLC( userNamePasswordHash.Length() * 2 );
   192 	TPtr8 B64UserNamePasswordStringPtr( B64UserNamePasswordString->Des() );
   192 	TPtr8 B64UserNamePasswordStringPtr( B64UserNamePasswordString->Des() );
   193 	User::LeaveIfError( B64Coder.Encode( userNamePasswordHash, B64UserNamePasswordStringPtr ) );
   193 	User::LeaveIfError( B64Coder.PortableEncode( userNamePasswordHash, B64UserNamePasswordStringPtr ) );
   194 	HBufC8* userNamePasswordNonce = HBufC8::NewLC( B64UserNamePasswordStringPtr.Length() + KColon.iTypeLength + nonce->Length() );
   194 	HBufC8* userNamePasswordNonce = HBufC8::NewLC( B64UserNamePasswordStringPtr.Length() + KColon.iTypeLength + nonce->Length() );
   195 	TPtr8 userNamePasswordNoncePtr = userNamePasswordNonce->Des();
   195 	TPtr8 userNamePasswordNoncePtr = userNamePasswordNonce->Des();
   196 	userNamePasswordNoncePtr = B64UserNamePasswordStringPtr;
   196 	userNamePasswordNoncePtr = B64UserNamePasswordStringPtr;
   197 	userNamePasswordNoncePtr += KColon;
   197 	userNamePasswordNoncePtr += KColon;
   198 	userNamePasswordNoncePtr += *nonce;
   198 	userNamePasswordNoncePtr += *nonce;
   200 	TPtrC8 finalHash;
   200 	TPtrC8 finalHash;
   201 	md5->Reset();
   201 	md5->Reset();
   202 	finalHash.Set( md5->Hash( *userNamePasswordNonce ) );
   202 	finalHash.Set( md5->Hash( *userNamePasswordNonce ) );
   203 	HBufC8* B64String = HBufC8::NewLC( finalHash.Length() * 2 );
   203 	HBufC8* B64String = HBufC8::NewLC( finalHash.Length() * 2 );
   204 	TPtr8 B64StringPtr( B64String->Des() );
   204 	TPtr8 B64StringPtr( B64String->Des() );
   205 	User::LeaveIfError( B64Coder.Encode( finalHash, B64StringPtr ) );
   205 	User::LeaveIfError( B64Coder.PortableEncode( finalHash, B64StringPtr ) );
   206 	CleanupStack::Pop();   // B64String
   206 	CleanupStack::Pop();   // B64String
   207 	CleanupStack::PopAndDestroy( 8 ); //userNamePasswordNonce, B64userNamePasswordNonce, userNamePassword, nonce, nonceInUnicode, password, userName, md5
   207 	CleanupStack::PopAndDestroy( 8 ); //userNamePasswordNonce, B64userNamePasswordNonce, userNamePassword, nonce, nonceInUnicode, password, userName, md5
   208 	return  B64String;
   208 	return  B64String;
   209 	}
   209 	}
   210 
   210