// ---------------------------------------------------------------------------- // CWmDrmDlaDefaultHttpManager::GetCredentialsL // This function is NOT currently used as authentication is not current used in // this project at the current time // ---------------------------------------------------------------------------- TBool CWmDrmDlaDefaultHttpManager::GetCredentialsL( const TUriC8& /*aURI*/, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword ) { LOGFN( "CWmDrmDlaDefaultHttpManager::GetCredentialsL" ); iCredentialsOk = EFalse; RStringPool pool = aRealm.Pool(); if ( aAuthenticationType == HTTP_STRING( HTTP::EBasic ) ) { DeleteUsernamePassword(); // Get the username/password iInCallback = ETrue; iCredentialsOk = iObserver.OnGetUsernamePasswordL( iUsername, iPassword ); iInCallback = EFalse; // authentication = iCredentialsOk && iUsername && iPassword // no authentication = !iCredentialsOk && !iUsername && !iPassword ASSERT( (iCredentialsOk && iUsername && iPassword) || (!iCredentialsOk && !iUsername && !iPassword ) ); if (iCredentialsOk) { aUsername = pool.OpenStringL( *iUsername ); aPassword = pool.OpenStringL( *iPassword ); } } // If the authentication type is not Basic, we simply return EFalse. return iCredentialsOk; }
// ---------------------------------------------------------------------------- // CClientEngine::GetCredentialsL() // // Inherited from MHTTPAuthenticationCallback // Called by framework when we requested authenticated page and framework // needs to know username and password. // ---------------------------------------------------------------------------- TBool CClientEngine::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { // aURI, aReal and aAuthenticationType are informational only. We only need // to set aUsername and aPassword and return ETrue, if aUsername and // aPassword are provided by user. // Informational only 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."); CEikonEnv::Static()->InfoWinL(KAuthNote, authText); // Query user name and password TBuf<KDefaultBufferSize> userName; TBuf<KDefaultBufferSize> password; //CAknMultiLineDataQueryDialog* dlg = // CAknMultiLineDataQueryDialog::NewL(userName, password); //if (!dlg->ExecuteLD(R_DIALOG_USER_PASSWORD_QUERY)) // return EFalse; // No credentials given; must return EFalse // Set aUsername and aPassword 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 ETrue if user has given credentials (username and password), // otherwise EFlase return EFalse; }
/** Get the credentials from the user. @param aURI [in] The URI being requested @param aRealm [out] The realm being requested @param aAuthenticationType [out] The type of authentication. @param aUsername [out] User name @param aPassword [out] Pass word @return TBool ETrue if credentials being returned else EFalse */ TBool CTestWebBrowser::GetCredentialsL( const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword ) { // Convert to 16 bit to display HBufC* uriDesBuf = HBufC::NewLC( aURI.UriDes().Length() ); TPtr uriDesPtr( uriDesBuf->Des() ); uriDesPtr.Copy( aURI.UriDes() ); HBufC* uriRealmBuf = HBufC::NewLC( aRealm.DesC().Length() ); TPtr uriRealmPtr( uriRealmBuf->Des() ); uriRealmPtr.Copy( aRealm.DesC() ); HBufC* uriAuthenticationType = HBufC::NewLC ( aAuthenticationType.DesC().Length() ); TPtr uriAuthenticationPtr( uriAuthenticationType->Des() ); uriAuthenticationPtr.Copy ( aAuthenticationType.DesC() ); // Prompt user for input iTestUtils.Test().Printf ( _L( "Enter credentials for URL %S, realm %S\n"), &uriDesPtr, &uriRealmPtr ); iTestUtils.Test().Printf ( _L("Using %S authentication\n"), &uriAuthenticationPtr ); CleanupStack::PopAndDestroy ( 3 ); // Pop and destroy uriDesBuf, uriRealmBuf and uriAuthenticationType HBufC* userDetails16 = HBufC::NewLC ( KMaxUserEntrySize ); HBufC8* userDetails8 = HBufC8::NewLC ( KMaxUserEntrySize ); TPtr userDetailsPtr16( userDetails16->Des() ); TPtr8 userDetailsPtr8( userDetails8->Des() ); iTestUtils.GetAnEntry ( _L( "Username (or QUIT to give up): " ), userDetailsPtr16 ); TBool set = EFalse; if ( userDetailsPtr16.CompareF ( KQuit ) ) { userDetailsPtr8.Copy ( userDetailsPtr16 ); aUsername = aRealm.Pool().OpenStringL ( userDetailsPtr8 ); iTestUtils.GetAnEntry( _L( "Password: " ), userDetailsPtr16 ); userDetailsPtr8.Copy ( userDetailsPtr16 ); aPassword = aRealm.Pool().OpenStringL ( userDetailsPtr8 ); set = ETrue; } CleanupStack::PopAndDestroy ( 2 ); // Pop and destroy userDetails16 & userDetails8 return set; }
TBool CHttpTestCaseGet12::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { iEngine->Utils().LogIt(_L("Supplying credentials")); iEngine->Utils().DumpData(aURI.UriDes()); iEngine->Utils().DumpData(aRealm.DesC()); iEngine->Utils().DumpData(aAuthenticationType.DesC()); _LIT8(KScooby, "scooby"); _LIT8(KDoo, "doo"); RStringPool p = aRealm.Pool(); aUsername = p.OpenStringL(KScooby); aPassword = p.OpenStringL(KDoo); return ETrue; }
TBool CHttpTestCaseGet14::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { if(iCallsNum++) { iTestFail=1; iEngine->Utils().LogIt(_L("The test will fail: the credential haven't been kept(the GetCredential function has been called again)")); return EFalse; } iEngine->Utils().LogIt(_L("Supplying credentials")); iEngine->Utils().DumpData(aURI.UriDes()); iEngine->Utils().DumpData(aRealm.DesC()); iEngine->Utils().DumpData(aAuthenticationType.DesC()); _LIT8(KScooby, "scooby"); _LIT8(KDoo, "doo"); RStringPool p = aRealm.Pool(); aUsername = p.OpenStringL(KScooby); aPassword = p.OpenStringL(KDoo); return ETrue; }