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