Http Digest Authentication in S60 2rd edition
Hi, guys!
I want to get user data from the GPRS networking using HTTP protocol. But the server request the authentication using digest.
I looked up in the Symbian SDK documentation and found the "MHTTPAuthenticationCallback" may do this work.
I inherented the class and implemented the GetCredentialsL function. But when i send the "GET" operation to the server, the server give a response of "401" message, but the program don't do nothing and GetCredentialsL method is also not called.
So i want someone give some suggestions or why it doesn't work.
Thanks in advance!
My code snippet is followed below:
[code]
void CHttpHandler::ConstructL()
{
iSession.OpenL();
InstallAuthenticationL(iSession);
}
void CHttpHandler::SendGetL( const TDesC8& aURI, const TDesC8& aETag)
{
TUriParser8 uriParser;
uriParser.Parse( aURI);
RStringF getMethod = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable());
iTransaction = iSession.OpenTransactionL( uriParser, *this, getMethod);
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
if ( aETag != KNullDesC8)
SetHeaderL( hdr, HTTP::EIfMatch, aETag);
SetHeaderL( hdr, KXCAPIden, iUserUri);
iTransaction.SubmitL();
}
TBool CHttpHandler::GetCredentialsL( const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword)
{
TBuf<KURIBufferSize> authType;
TBuf<KURIBufferSize> uri;
TBuf<KDefaultBufferSize> authText;
authType.Copy(aAuthenticationType.DesC());
uri.Copy(aURI.UriDes());
_LIT(KAuthRequired, "%S requires %S authentication.");
authText.Format(KAuthRequired, &uri, &authType);
_LIT(KAuthNote, "Authentication required.");
RLog::Log( KAuthNote );
TBuf8<KDefaultBufferSize> userName;
TBuf8<KDefaultBufferSize> password;
_LIT8(KUserName, "sip:user7@example.com");
_LIT8(KPswd, "123");
userName = KUserName();
password = KPswd();
TBuf8<KDefaultBufferSize> temp;
temp.Copy(userName);
TRAPD(err, aUsername = aRealm.Pool().OpenStringL(temp));
if (!err)
{
temp.Copy(password);
TRAP(err, aPassword = aRealm.Pool().OpenStringL(temp));
if (!err)
return ETrue;
}
return EFalse;
}
[/code]
Re: Http Digest Authentication in S60 2rd edition
Hello my name is shravan.Iam also symbian beginner in developing. Actually iam struck with How to implement startonBoot code and launch a dialog for pw at the startup ie when mobile gets switched on?
can u send me the code or try to help me in any way.