Loading core/java/android/webkit/HttpAuthHandler.java +19 −8 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package android.webkit; import android.os.Handler; /** * HTTP authentication request that must be handled by the user interface. * WebView creates the object and hands it to the current {@link WebViewClient}, * which must call either {@link #proceed(String, String)} or {@link #cancel()}. * Represents a request for HTTP authentication. Instances of this class are * created by the WebView and passed to * {@link WebViewClient#onReceivedHttpAuthRequest}. The host application must * call either {@link #proceed} or {@link #cancel} to set the WebView's * response to the request. */ public class HttpAuthHandler extends Handler { Loading @@ -32,27 +34,36 @@ public class HttpAuthHandler extends Handler { } /** * @return True if we can use user credentials on record * (ie, if we did not fail trying to use them last time) * Gets whether the credentials stored for the current host (i.e. the host * for which {@link WebViewClient#onReceivedHttpAuthRequest} was called) * are suitable for use. Credentials are not suitable if they have * previously been rejected by the server for the current request. * * @return whether the credentials are suitable for use * @see Webview#getHttpAuthUsernamePassword */ public boolean useHttpAuthUsernamePassword() { return false; } /** * Cancel the authorization request. * Instructs the WebView to cancel the authentication request. */ public void cancel() { } /** * Proceed with the authorization with the given credentials. * Instructs the WebView to proceed with the authentication with the given * credentials. Credentials for use with this method can be retrieved from * the WebView's store using {@link WebView#getHttpAuthUsernamePassword}. */ public void proceed(String username, String password) { } /** * return true if the prompt dialog should be suppressed. * Gets whether the prompt dialog should be suppressed. * * @return whether the prompt dialog should be suppressed * @hide */ public boolean suppressDialog() { Loading core/java/android/webkit/WebView.java +20 −11 Original line number Diff line number Diff line Loading @@ -599,13 +599,17 @@ public class WebView extends AbsoluteLayout } /** * Sets the HTTP authentication credentials for a given host and realm. * Stores HTTP authentication credentials for a given host and realm. This * method is intended to be used with * {@link WebViewClient#onReceivedHttpAuthRequest}. * * @param host the host for the credentials * @param realm the realm for the credentials * @param username the username for the password. If it is null, it means * password can't be saved. * @param host the host to which the credentials apply * @param realm the realm to which the credentials apply * @param username the username * @param password the password * @see getHttpAuthUsernamePassword * @see WebViewDatabase#hasHttpAuthUsernamePassword * @see WebViewDatabase#clearHttpAuthUsernamePassword */ public void setHttpAuthUsernamePassword(String host, String realm, String username, String password) { Loading @@ -614,13 +618,18 @@ public class WebView extends AbsoluteLayout } /** * Retrieves the HTTP authentication username and password for a given * host and realm pair * Retrieves HTTP authentication credentials for a given host and realm. * This method is intended to be used with * {@link WebViewClient#onReceivedHttpAuthRequest}. * * @param host the host for which the credentials apply * @param realm the realm for which the credentials apply * @return String[] if found. String[0] is username, which can be null and * String[1] is password. Return null if it can't find anything. * @param host the host to which the credentials apply * @param realm the realm to which the credentials apply * @return the credentials as a String array, if found. The first element * is the username and the second element is the password. Null if * no credentials are found. * @see setHttpAuthUsernamePassword * @see WebViewDatabase#hasHttpAuthUsernamePassword * @see WebViewDatabase#clearHttpAuthUsernamePassword */ public String[] getHttpAuthUsernamePassword(String host, String realm) { checkThread(); Loading core/java/android/webkit/WebViewClient.java +9 −7 Original line number Diff line number Diff line Loading @@ -204,14 +204,16 @@ public class WebViewClient { } /** * Notify the host application to handle an authentication request. The * default behavior is to cancel the request. * Notifies the host application that the WebView received an HTTP * authentication request. The host application can use the supplied * {@link HttpAuthHandler} to set the WebView's response to the request. * The default behavior is to cancel the request. * * @param view The WebView that is initiating the callback. * @param handler The HttpAuthHandler that will handle the user's response. * @param host The host requiring authentication. * @param realm A description to help store user credentials for future * visits. * @param view the WebView that is initiating the callback * @param handler the HttpAuthHandler used to set the WebView's response * @param host the host requiring authentication * @param realm the realm for which authentication is required * @see Webview#getHttpAuthUsernamePassword */ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { Loading core/java/android/webkit/WebViewDatabase.java +10 −3 Original line number Diff line number Diff line Loading @@ -66,16 +66,23 @@ public class WebViewDatabase { } /** * Gets whether there are any HTTP authentication username/password combinations saved. * Gets whether there are any saved credentials for HTTP authentication. * * @return true if there are any HTTP authentication username/passwords saved * @return whether there are any saved credentials * @see Webview#getHttpAuthUsernamePassword * @see Webview#setHttpAuthUsernamePassword * @see clearHttpAuthUsernamePassword */ public boolean hasHttpAuthUsernamePassword() { throw new MustOverrideException(); } /** * Clears any HTTP authentication username/passwords that are saved. * Clears any saved credentials for HTTP authentication. * * @see Webview#getHttpAuthUsernamePassword * @see Webview#setHttpAuthUsernamePassword * @see hasHttpAuthUsernamePassword */ public void clearHttpAuthUsernamePassword() { throw new MustOverrideException(); Loading Loading
core/java/android/webkit/HttpAuthHandler.java +19 −8 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package android.webkit; import android.os.Handler; /** * HTTP authentication request that must be handled by the user interface. * WebView creates the object and hands it to the current {@link WebViewClient}, * which must call either {@link #proceed(String, String)} or {@link #cancel()}. * Represents a request for HTTP authentication. Instances of this class are * created by the WebView and passed to * {@link WebViewClient#onReceivedHttpAuthRequest}. The host application must * call either {@link #proceed} or {@link #cancel} to set the WebView's * response to the request. */ public class HttpAuthHandler extends Handler { Loading @@ -32,27 +34,36 @@ public class HttpAuthHandler extends Handler { } /** * @return True if we can use user credentials on record * (ie, if we did not fail trying to use them last time) * Gets whether the credentials stored for the current host (i.e. the host * for which {@link WebViewClient#onReceivedHttpAuthRequest} was called) * are suitable for use. Credentials are not suitable if they have * previously been rejected by the server for the current request. * * @return whether the credentials are suitable for use * @see Webview#getHttpAuthUsernamePassword */ public boolean useHttpAuthUsernamePassword() { return false; } /** * Cancel the authorization request. * Instructs the WebView to cancel the authentication request. */ public void cancel() { } /** * Proceed with the authorization with the given credentials. * Instructs the WebView to proceed with the authentication with the given * credentials. Credentials for use with this method can be retrieved from * the WebView's store using {@link WebView#getHttpAuthUsernamePassword}. */ public void proceed(String username, String password) { } /** * return true if the prompt dialog should be suppressed. * Gets whether the prompt dialog should be suppressed. * * @return whether the prompt dialog should be suppressed * @hide */ public boolean suppressDialog() { Loading
core/java/android/webkit/WebView.java +20 −11 Original line number Diff line number Diff line Loading @@ -599,13 +599,17 @@ public class WebView extends AbsoluteLayout } /** * Sets the HTTP authentication credentials for a given host and realm. * Stores HTTP authentication credentials for a given host and realm. This * method is intended to be used with * {@link WebViewClient#onReceivedHttpAuthRequest}. * * @param host the host for the credentials * @param realm the realm for the credentials * @param username the username for the password. If it is null, it means * password can't be saved. * @param host the host to which the credentials apply * @param realm the realm to which the credentials apply * @param username the username * @param password the password * @see getHttpAuthUsernamePassword * @see WebViewDatabase#hasHttpAuthUsernamePassword * @see WebViewDatabase#clearHttpAuthUsernamePassword */ public void setHttpAuthUsernamePassword(String host, String realm, String username, String password) { Loading @@ -614,13 +618,18 @@ public class WebView extends AbsoluteLayout } /** * Retrieves the HTTP authentication username and password for a given * host and realm pair * Retrieves HTTP authentication credentials for a given host and realm. * This method is intended to be used with * {@link WebViewClient#onReceivedHttpAuthRequest}. * * @param host the host for which the credentials apply * @param realm the realm for which the credentials apply * @return String[] if found. String[0] is username, which can be null and * String[1] is password. Return null if it can't find anything. * @param host the host to which the credentials apply * @param realm the realm to which the credentials apply * @return the credentials as a String array, if found. The first element * is the username and the second element is the password. Null if * no credentials are found. * @see setHttpAuthUsernamePassword * @see WebViewDatabase#hasHttpAuthUsernamePassword * @see WebViewDatabase#clearHttpAuthUsernamePassword */ public String[] getHttpAuthUsernamePassword(String host, String realm) { checkThread(); Loading
core/java/android/webkit/WebViewClient.java +9 −7 Original line number Diff line number Diff line Loading @@ -204,14 +204,16 @@ public class WebViewClient { } /** * Notify the host application to handle an authentication request. The * default behavior is to cancel the request. * Notifies the host application that the WebView received an HTTP * authentication request. The host application can use the supplied * {@link HttpAuthHandler} to set the WebView's response to the request. * The default behavior is to cancel the request. * * @param view The WebView that is initiating the callback. * @param handler The HttpAuthHandler that will handle the user's response. * @param host The host requiring authentication. * @param realm A description to help store user credentials for future * visits. * @param view the WebView that is initiating the callback * @param handler the HttpAuthHandler used to set the WebView's response * @param host the host requiring authentication * @param realm the realm for which authentication is required * @see Webview#getHttpAuthUsernamePassword */ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { Loading
core/java/android/webkit/WebViewDatabase.java +10 −3 Original line number Diff line number Diff line Loading @@ -66,16 +66,23 @@ public class WebViewDatabase { } /** * Gets whether there are any HTTP authentication username/password combinations saved. * Gets whether there are any saved credentials for HTTP authentication. * * @return true if there are any HTTP authentication username/passwords saved * @return whether there are any saved credentials * @see Webview#getHttpAuthUsernamePassword * @see Webview#setHttpAuthUsernamePassword * @see clearHttpAuthUsernamePassword */ public boolean hasHttpAuthUsernamePassword() { throw new MustOverrideException(); } /** * Clears any HTTP authentication username/passwords that are saved. * Clears any saved credentials for HTTP authentication. * * @see Webview#getHttpAuthUsernamePassword * @see Webview#setHttpAuthUsernamePassword * @see hasHttpAuthUsernamePassword */ public void clearHttpAuthUsernamePassword() { throw new MustOverrideException(); Loading