Help! Trying to get Basic Auth working with WebView. setHttpAuthUsernamePassword?

by Stoffe » Fri, 16 Oct 2009 07:39:19 GMT


Sponsored Links
 Hi Matt!

You need to do something like this:

@Override
public void onCreate(Bundle savedInstanceState) {

WebView webkit = (WebView) findViewById(R.id.web_view);




--~--~---------~--~----~------------~-------~--~----~



Help! Trying to get Basic Auth working with WebView. setHttpAuthUsernamePassword?

by Stoffe » Fri, 16 Oct 2009 07:39:20 GMT


 Hi Matt!

@Override
public void onCreate(Bundle savedInstanceState) {

    WebView webkit = (WebView) findViewById(R.id.web_view);
    webkit.setHttpAuthUsernamePassword(page.getHost(), realm,
username, password);
    webkit.setWebViewClient( new WebViewClient() {
        @Override
        public void onReceivedHttpAuthRequest  (WebView view,
                HttpAuthHandler handler, String host,String realm){
            String[] up = view.getHttpAuthUsernamePassword(host, realm);
            if( up != null && up.length == 2 ) {
                handler.proceed(up[0], up[1]);
            }
            else{
                Log.d("WebAuth","Could not find user/pass for domain :"+
                        host+" with realm = "+realm);
           }
        }
    });
    webkit.loadUrl(page.toString());

BR Stoffe




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Help! Trying to get Basic Auth working with WebView. setHttpAuthUsernamePassword?

by Stoffe » Tue, 20 Oct 2009 23:15:29 GMT


 Hi!

Just one more discovery that in my opinion is probably a bug in the
framework.
When you call setHttpAuthUsernamePassword only the first call is
stored.
If you try override values for the same host and realm it will only
return the first entered user.
Even after restarts of the client.

I even had clearCache(true) and that did not help.
So if you need to update a value you must first call.

WebViewDatabase.getInstance(this).clearHttpAuthUsernamePassword();
In my example you could as well skip the entire setHttpAuth/
getHttpAuth and pass the correct value but if you split the logic then
it matters.

BR Stoffe





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Publishing an application on an own web server

Hello,

I am looking a way to publish a private application on an own web
server.  I know that Android phones could download an apk file and
then I could install the application from the file downloaded. I
prefer to install the application directly by clicking the link but it
doesn't matter.

But the important thing is the update of the application, how could I
publish updates using my own web server ?

Regards.

-- 

2. Encryption on Android devices

Hello,

1) I am wondering if the Android SDK has already predefined encryption
functions or if one would have to write this all from scratch?

2) Suppose you have classes for encryption, either written by yourself
or provided by the SDK, how to make sure, that the content of the RAM
(that contains the key in plaintext) is never written to the permanent
storage of the android device? I guess if too much RAM is used,
there's some kind of swapping, besides that there are techniques like
HTC's fastboot that write the whole content to the storage if I am not
wrong? Any chance to prevent the RAM content for your software being
saved on a permanent storage? Or is there maybe some kind of event
before the RAM content is written to the permanenent storage, so one
could wipe the key before that?

The latter one is my main problem - how to make sure, that the key
never gets stored unencrypted on a storage?

Thanks you very much for any hint!

-- 

3. testApplicationTestCaseSetUpProperly failing

4. How to display a raw YUV frame in an Android OpenGL program?

5. How to send a simple email programatically? (exists a simple way to do it??)

6. Audio triggered by database change?

7. How to put text below the image of the item in a mapview? (googlemap view)