本文整理匯總了Java中android.webkit.HttpAuthHandler類的典型用法代碼示例。如果您正苦於以下問題:Java HttpAuthHandler類的具體用法?Java HttpAuthHandler怎麽用?Java HttpAuthHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpAuthHandler類屬於android.webkit包,在下文中一共展示了HttpAuthHandler類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceivedHttpAuthRequest
import android.webkit.HttpAuthHandler; //導入依賴的package包/類
/**
* On received http auth request.
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
*/
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
// Get the authentication token (if specified)
AuthenticationToken token = this.getAuthenticationToken(host, realm);
if (token != null) {
handler.proceed(token.getUserName(), token.getPassword());
return;
}
// Check if there is some plugin which can resolve this auth challenge
PluginManager pluginManager = this.parentEngine.pluginManager;
if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(null, new CordovaHttpAuthHandler(handler), host, realm)) {
parentEngine.client.clearLoadTimeoutTimer();
return;
}
// By default handle 401 like we'd normally do!
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
示例2: onReceivedHttpAuthRequest
import android.webkit.HttpAuthHandler; //導入依賴的package包/類
/**
* On received http auth request.
* The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
*
* @param view
* @param handler
* @param host
* @param realm
*/
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
// Get the authentication token (if specified)
AuthenticationToken token = this.getAuthenticationToken(host, realm);
if (token != null) {
handler.proceed(token.getUserName(), token.getPassword());
return;
}
// Check if there is some plugin which can resolve this auth challenge
PluginManager pluginManager = this.appView.pluginManager;
if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(this.appView, new CordovaHttpAuthHandler(handler), host, realm)) {
this.appView.loadUrlTimeout++;
return;
}
// By default handle 401 like we'd normally do!
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
示例3: createAuthenticationDialog
import android.webkit.HttpAuthHandler; //導入依賴的package包/類
/**
* Create and show dialog for request authentication to the user
* @param webView Web view to emebd into the authentication dialog.
* @param handler Object responsible for catching and recovering HTTP authentication fails.
*/
public void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) {
// Show a dialog with the certificate info
CredentialsDialogFragment dialog =
CredentialsDialogFragment.newInstanceForCredentials(webView, handler);
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(null);
dialog.setCancelable(false);
dialog.show(ft, CREDENTIALS_DIALOG_TAG);
if (!mIsFirstAuthAttempt) {
Toast.makeText(
getApplicationContext(),
getText(R.string.saml_authentication_wrong_pass),
Toast.LENGTH_LONG
).show();
} else {
mIsFirstAuthAttempt = false;
}
}
示例4: onReceivedHttpAuthRequest
import android.webkit.HttpAuthHandler; //導入依賴的package包/類
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
if (mBlog != null && mBlog.hasValidHTTPAuthCredentials()) {
// Check that the HTTP AUth protected domain is the same of the blog. Do not send current blog's HTTP
// AUTH credentials to external site.
// NOTE: There is still a small security hole here, since the realm is not considered when getting
// the password. Unfortunately the real is not stored when setting up the blog, and we cannot compare it
// at this point.
String domainFromHttpAuthRequest = UrlUtils.getDomainFromUrl(UrlUtils.addUrlSchemeIfNeeded(host, false));
String currentBlogDomain = UrlUtils.getDomainFromUrl(mBlog.getUrl());
if (domainFromHttpAuthRequest.equals(currentBlogDomain)) {
handler.proceed(mBlog.getHttpuser(), mBlog.getHttppassword());
return;
}
}
// TODO: If there is no match show the HTTP Auth dialog here. Like a normal browser usually does...
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}