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


Java SslErrorHandler類代碼示例

本文整理匯總了Java中android.webkit.SslErrorHandler的典型用法代碼示例。如果您正苦於以下問題:Java SslErrorHandler類的具體用法?Java SslErrorHandler怎麽用?Java SslErrorHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SslErrorHandler類屬於android.webkit包,在下文中一共展示了SslErrorHandler類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceivedSslError

import android.webkit.SslErrorHandler; //導入依賴的package包/類
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
	/*
	 * in theory this should be checked to make sure it's not null but if there is some failure 
	 * in the association then usage of webViewProxy should trigger a NPE to make sure the issue 
	 * is not ignored
	 */
	KrollProxy webViewProxy = this.webView.getProxy();
	
	KrollDict data = new KrollDict();
	data.put(TiC.ERROR_PROPERTY_CODE, error.getPrimaryError());
	webView.getProxy().fireSyncEvent(TiC.EVENT_SSL_ERROR, data);

	boolean ignoreSslError = false;
	try {
		ignoreSslError = webViewProxy.getProperties().optBoolean(TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR, false);

	} catch(IllegalArgumentException e) {
		Log.e(TAG, TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR + " property does not contain a boolean value, ignoring"); 
	}

	if (ignoreSslError == true) {
		Log.w(TAG, "ran into SSL error but ignoring...");
		handler.proceed();

	} else {
		Log.e(TAG, "SSL error occurred: " + error.toString());
		handler.cancel();
	}
}
 
開發者ID:chreck,項目名稱:movento-webview,代碼行數:32,代碼來源:TiWebViewClient.java

示例2: onReceivedSslError

import android.webkit.SslErrorHandler; //導入依賴的package包/類
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:34,代碼來源:SystemWebViewClient.java

示例3: preSetting

import android.webkit.SslErrorHandler; //導入依賴的package包/類
private void preSetting(){
    //加載服務器上的頁麵
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setBlockNetworkImage(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mWebView.getSettings().setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view,
                                       SslErrorHandler handler, SslError error) {
            // TODO Auto-generated method stub
            // handler.cancel();// Android默認的處理方式
            handler.proceed();// 接受所有網站的證書
            // handleMessage(Message msg);// 進行其他處理
        }
    });
    //加載本地中的html
    //myWebView.loadUrl("file:///android_asset/www/test2.html");
    //加上下麵這段代碼可以使網頁中的鏈接不以瀏覽器的方式打開
    mWebView.setWebViewClient(new WebViewClient());
    //允許使用javascript
    mWebView.getSettings().setJavaScriptEnabled(true);
}
 
開發者ID:MarukoZ,項目名稱:FaceRecognition,代碼行數:26,代碼來源:Main2Activity.java

示例4: initView

import android.webkit.SslErrorHandler; //導入依賴的package包/類
@Override
protected void initView() {

    String name = getIntent().getStringExtra("name");
    String url = getIntent().getStringExtra("url");

    //設置沉浸式狀態欄
    setStatus();
    iv_search.setVisibility(View.VISIBLE);
    //設置沉浸式狀態欄背景
    bar_layout.setBackgroundResource(R.color.black_alpha_5);

    title_text.setText(name);

    wv.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            super.onReceivedSslError(view, handler, error);
            handler.proceed();
        }
    });
    wv.getSettings().setJavaScriptEnabled(true);

    wv.loadUrl(url);
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:26,代碼來源:WebViewActivity.java

示例5: c

import android.webkit.SslErrorHandler; //導入依賴的package包/類
private WebViewClient c() {
    Object obj = 1;
    Object obj2 = null;
    try {
        if (WebViewClient.class.getMethod("onReceivedSslError", new Class[]{WebView.class,
                SslErrorHandler.class, SslError.class}) == null) {
            obj = null;
        }
        obj2 = obj;
    } catch (NoSuchMethodException e) {
    } catch (IllegalArgumentException e2) {
    }
    if (obj2 != null) {
        Log.i(a, "has method onReceivedSslError : ");
        return new q(this);
    }
    Log.i(a, "has no method onReceivedSslError : ");
    return new a();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:j.java

示例6: onReceivedSslError

import android.webkit.SslErrorHandler; //導入依賴的package包/類
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = this.cordova.getActivity().getPackageName();
    final PackageManager pm = this.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:34,代碼來源:CordovaWebViewClient.java

示例7: onCreate

import android.webkit.SslErrorHandler; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_load_url);
        webview = (WebView) findViewById(R.id.webview);
        webview.loadUrl("https://www.sawerly.com/beta/cms/3/en");
        webview.getSettings().setUseWideViewPort(true);
        webview.getSettings().setJavaScriptEnabled(true);
//        webview.measure(100,100);
        webview.setWebViewClient(new WebViewClient(){
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                super.onReceivedSslError(view, handler, error);
                handler.proceed();
            }
        });
//        webview.setWebChromeClient(new WebChromeClient());
    }
 
開發者ID:parthdave93,項目名稱:AndroidTestingTutorial,代碼行數:19,代碼來源:LoadUrl.java

示例8: onReceivedSslError

import android.webkit.SslErrorHandler; //導入依賴的package包/類
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.cancel();

    // WebView can try to load the favicon for a bad page when you set a new URL. If we then
    // loadErrorPage() again, WebView tries to load the favicon again. We end up in onReceivedSSlError()
    // again, and we get an infinite loop of reloads (we also erroneously show the favicon URL
    // in the toolbar, but that's less noticeable). Hence we check whether this error is from
    // the desired page, or a page resource:
    if (error.getUrl().equals(currentPageURL)) {
        TelemetryWrapper.sslErrorEvent(true, error);
        ErrorPage.loadErrorPage(view, error.getUrl(), WebViewClient.ERROR_FAILED_SSL_HANDSHAKE);
    } else {
        TelemetryWrapper.sslErrorEvent(false, error);
    }
}
 
開發者ID:mozilla-mobile,項目名稱:focus-android,代碼行數:17,代碼來源:FocusWebViewClient.java

示例9: showUntrustedCertDialog

import android.webkit.SslErrorHandler; //導入依賴的package包/類
/**
 * Show untrusted cert dialog 
 */
public void showUntrustedCertDialog(
        X509Certificate x509Certificate, SslError error, SslErrorHandler handler
    ) {
    // Show a dialog with the certificate info
    SslUntrustedCertDialog dialog;
    if (x509Certificate == null) {
        dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler);
    } else {
        dialog = SslUntrustedCertDialog.
                newInstanceForFullSslError(x509Certificate, error, handler);
    }
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.addToBackStack(null);
    dialog.show(ft, UNTRUSTED_CERT_DIALOG_TAG);
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:20,代碼來源:AuthenticatorActivity.java

示例10: newInstanceForFullSslError

import android.webkit.SslErrorHandler; //導入依賴的package包/類
public static SslUntrustedCertDialog newInstanceForFullSslError(X509Certificate cert, SslError error, SslErrorHandler handler) {
    if (cert == null) {
        throw new IllegalArgumentException("Trying to create instance with parameter cert == null");
    }
    if (error == null) {
        throw new IllegalArgumentException("Trying to create instance with parameter error == null");
    }
    if (handler == null) {
        throw new IllegalArgumentException("Trying to create instance with parameter handler == null");
    }
    SslUntrustedCertDialog dialog = new SslUntrustedCertDialog();
    dialog.m509Certificate = cert;
    dialog.mHandler = handler;
    dialog.mErrorViewAdapter = new SslErrorViewAdapter(error);
    dialog.mCertificateViewAdapter = new X509CertificateViewAdapter(cert);
    return dialog;
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:18,代碼來源:SslUntrustedCertDialog.java


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