added http proxy authentication (see #819)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.cradle.iitc_mobile;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@ -7,6 +8,7 @@ import android.net.http.SslError;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
@ -168,6 +170,44 @@ public class IITC_WebViewClient extends WebViewClient {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler,
|
||||
final String host, final String realm) {
|
||||
String username = null;
|
||||
String password = null;
|
||||
|
||||
boolean reuseHttpAuthUsernamePassword
|
||||
= handler.useHttpAuthUsernamePassword();
|
||||
|
||||
if (reuseHttpAuthUsernamePassword && view != null) {
|
||||
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
|
||||
if (credentials != null && credentials.length == 2) {
|
||||
username = credentials[0];
|
||||
password = credentials[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (username != null && password != null) {
|
||||
handler.proceed(username, password);
|
||||
} else {
|
||||
HttpAuthenticationDialog dialog = new HttpAuthenticationDialog(mIitc, host, realm);
|
||||
|
||||
dialog.setOkListener(new HttpAuthenticationDialog.OkListener() {
|
||||
public void onOk(String host, String realm, String username, String password) {
|
||||
handler.proceed(username, password);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setCancelListener(new HttpAuthenticationDialog.CancelListener() {
|
||||
public void onCancel() {
|
||||
handler.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mIitcInjected = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user