當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpAuthHandler類代碼示例

本文整理匯總了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);
}
 
開發者ID:whtsky,項目名稱:ShaPaoZi-Mobile,代碼行數:25,代碼來源:SystemWebViewClient.java

示例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);
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:30,代碼來源:CordovaWebViewClient.java

示例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;
    }
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:27,代碼來源:AuthenticatorActivity.java

示例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);
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:19,代碼來源:WPWebViewClient.java


注:本文中的android.webkit.HttpAuthHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。