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


Java SslError類代碼示例

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


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

示例1: onReceivedSslError

import android.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的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.net.http.SslError; //導入依賴的package包/類
@Override
public void onReceivedSslError(AmazonWebView view, AmazonSslErrorHandler 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,項目名稱:firefox-tv,代碼行數:17,代碼來源:FocusWebViewClient.java

示例9: getAllSslErrorMessageCodes

import android.net.http.SslError; //導入依賴的package包/類
@NonNull
private static List<Integer> getAllSslErrorMessageCodes(@NonNull SslError error) {
    List<Integer> errorCodeMessageCodes = new ArrayList<>(1);

    if (error.hasError(SslError.SSL_DATE_INVALID)) {
        errorCodeMessageCodes.add(R.string.message_certificate_date_invalid);
    }
    if (error.hasError(SslError.SSL_EXPIRED)) {
        errorCodeMessageCodes.add(R.string.message_certificate_expired);
    }
    if (error.hasError(SslError.SSL_IDMISMATCH)) {
        errorCodeMessageCodes.add(R.string.message_certificate_domain_mismatch);
    }
    if (error.hasError(SslError.SSL_NOTYETVALID)) {
        errorCodeMessageCodes.add(R.string.message_certificate_not_yet_valid);
    }
    if (error.hasError(SslError.SSL_UNTRUSTED)) {
        errorCodeMessageCodes.add(R.string.message_certificate_untrusted);
    }
    if (error.hasError(SslError.SSL_INVALID)) {
        errorCodeMessageCodes.add(R.string.message_certificate_invalid);
    }

    return errorCodeMessageCodes;
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:26,代碼來源:LightningWebClient.java

示例10: onReceivedSslError

import android.net.http.SslError; //導入依賴的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

示例11: onReceivedSslError

import android.net.http.SslError; //導入依賴的package包/類
/**
* Notify the host application that an SSL error occurred while loading a
* resource. The host application must call either callback.onReceiveValue(true)
* or callback.onReceiveValue(false). Note that the decision may be
* retained for use in response to future SSL errors. The default behavior
* is to pop up a dialog.
*/
@Override
public void onReceivedSslError(XWalkView view, ValueCallback<Boolean> callback, 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
            callback.onReceiveValue(true);
        } else {
            // debug = false
            callback.onReceiveValue(false);
        }
    } catch (PackageManager.NameNotFoundException e) {
        // When it doubt, lock it out!
        callback.onReceiveValue(false);
    }
}
 
開發者ID:infil00p,項目名稱:cordova-plugin-crosswalk-webview,代碼行數:28,代碼來源:XWalkCordovaResourceClient.java

示例12: onReceivedSslError

import android.net.http.SslError; //導入依賴的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 AmazonWebView that is initiating the callback.
 * @param handler       An AmazonSslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(AmazonWebView view, AmazonSslErrorHandler 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:chrisuehlinger,項目名稱:smart-mirror-app,代碼行數:34,代碼來源:CordovaWebViewClient.java

示例13: getX509CertificateFromError

import android.net.http.SslError; //導入依賴的package包/類
/**
 * Obtain the X509Certificate from SslError
 * @param   error     SslError
 * @return  X509Certificate from error
 */
public X509Certificate getX509CertificateFromError (SslError error) {
    Bundle bundle = SslCertificate.saveState(error.getCertificate());
    X509Certificate x509Certificate;
    byte[] bytes = bundle.getByteArray("x509-certificate");
    if (bytes == null) {
        x509Certificate = null;
    } else {
        try {
            CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
            Certificate cert = certFactory.generateCertificate(new ByteArrayInputStream(bytes));
            x509Certificate = (X509Certificate) cert;
        } catch (CertificateException e) {
            x509Certificate = null;
        }
    }        
    return x509Certificate;
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:23,代碼來源:SsoWebViewClient.java

示例14: showUntrustedCertDialog

import android.net.http.SslError; //導入依賴的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

示例15: newInstanceForFullSslError

import android.net.http.SslError; //導入依賴的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.net.http.SslError類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。