当前位置: 首页>>代码示例>>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;未经允许,请勿转载。