1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.webkit; 18 19 import android.annotation.SystemApi; 20 import android.os.Handler; 21 22 /** 23 * Represents a request for HTTP authentication. Instances of this class are 24 * created by the WebView and passed to 25 * {@link WebViewClient#onReceivedHttpAuthRequest}. The host application must 26 * call either {@link #proceed} or {@link #cancel} to set the WebView's 27 * response to the request. 28 */ 29 public class HttpAuthHandler extends Handler { 30 31 /** 32 * @hide Only for use by WebViewProvider implementations. 33 */ 34 @SystemApi HttpAuthHandler()35 public HttpAuthHandler() { 36 } 37 38 /** 39 * Gets whether the credentials stored for the current host (i.e. the host 40 * for which {@link WebViewClient#onReceivedHttpAuthRequest} was called) 41 * are suitable for use. Credentials are not suitable if they have 42 * previously been rejected by the server for the current request. 43 * 44 * <p class="note"><b>Note:</b> The host application must call this method 45 * on the host application's UI Thread. 46 * 47 * @return whether the credentials are suitable for use 48 * @see WebView#getHttpAuthUsernamePassword 49 */ useHttpAuthUsernamePassword()50 public boolean useHttpAuthUsernamePassword() { 51 return false; 52 } 53 54 /** 55 * Instructs the WebView to cancel the authentication request. 56 * 57 * <p class="note"><b>Note:</b> The host application must call this method 58 * on the host application's UI Thread. 59 */ cancel()60 public void cancel() { 61 } 62 63 /** 64 * Instructs the WebView to proceed with the authentication with the given 65 * credentials. Credentials for use with this method can be retrieved from 66 * the WebView's store using {@link WebView#getHttpAuthUsernamePassword}. 67 * 68 * <p class="note"><b>Note:</b> The host application must call this method 69 * on the host application's UI Thread. 70 */ proceed(String username, String password)71 public void proceed(String username, String password) { 72 } 73 } 74