• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SslCertificate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.net.http.SslCertificate的典型用法代码示例。如果您正苦于以下问题:Java SslCertificate类的具体用法?Java SslCertificate怎么用?Java SslCertificate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SslCertificate类属于android.net.http包,在下文中一共展示了SslCertificate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addCertificate

import android.net.http.SslCertificate; //导入依赖的package包/类
public static synchronized void addCertificate(SslCertificate certificate) throws GeneralSecurityException, IOException {
    KeyStore localTrustStore = loadTrustStore();
    X509Certificate x509Certificate = getX509CertFromSslCertHack(certificate);

    String alias = hashName(x509Certificate.getSubjectX500Principal());
    localTrustStore.setCertificateEntry(alias, x509Certificate);

    saveTrustStore(localTrustStore);

    // reset fields so the keystore gets read again
    mTrustManager = null;
    mSslContext = null;

    // notify listeners
    synchronized (mListeners) {
        for (CertChangedListener l : mListeners) {
            l.certAdded();
        }
    }
}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:21,代码来源:ConnectionUtil.java


示例2: getX509CertificateFromError

import android.net.http.SslCertificate; //导入依赖的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


示例3: showSubject

import android.net.http.SslCertificate; //导入依赖的package包/类
private void showSubject(SslCertificate.DName subject, View dialogView) {
    TextView cnView = ((TextView)dialogView.findViewById(R.id.value_subject_CN));
    cnView.setText(subject.getCName());
    cnView.setVisibility(View.VISIBLE);
    
    TextView oView = ((TextView)dialogView.findViewById(R.id.value_subject_O));
    oView.setText(subject.getOName());
    oView.setVisibility(View.VISIBLE);
    
    TextView ouView = ((TextView)dialogView.findViewById(R.id.value_subject_OU));
    ouView.setText(subject.getUName());
    ouView.setVisibility(View.VISIBLE);

    // SslCertificates don't offer this information
    dialogView.findViewById(R.id.value_subject_C).setVisibility(View.GONE);
    dialogView.findViewById(R.id.value_subject_ST).setVisibility(View.GONE);
    dialogView.findViewById(R.id.value_subject_L).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_subject_C).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_subject_ST).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_subject_L).setVisibility(View.GONE);
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:22,代码来源:SslCertificateViewAdapter.java


示例4: showIssuer

import android.net.http.SslCertificate; //导入依赖的package包/类
private void showIssuer(SslCertificate.DName issuer, View dialogView) {
    TextView cnView = ((TextView)dialogView.findViewById(R.id.value_issuer_CN));
    cnView.setText(issuer.getCName());
    cnView.setVisibility(View.VISIBLE);
    
    TextView oView = ((TextView)dialogView.findViewById(R.id.value_issuer_O));
    oView.setText(issuer.getOName());
    oView.setVisibility(View.VISIBLE);

    TextView ouView = ((TextView)dialogView.findViewById(R.id.value_issuer_OU));
    ouView.setText(issuer.getUName());
    ouView.setVisibility(View.VISIBLE);
    
    // SslCertificates don't offer this information
    dialogView.findViewById(R.id.value_issuer_C).setVisibility(View.GONE);
    dialogView.findViewById(R.id.value_issuer_ST).setVisibility(View.GONE);
    dialogView.findViewById(R.id.value_issuer_L).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_issuer_C).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_issuer_ST).setVisibility(View.GONE);
    dialogView.findViewById(R.id.label_issuer_L).setVisibility(View.GONE);
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:22,代码来源:SslCertificateViewAdapter.java


示例5: allowCertificateError

import android.net.http.SslCertificate; //导入依赖的package包/类
@CalledByNative
private boolean allowCertificateError(int certError, byte[] derBytes, final String url,
        final int id) {
    final SslCertificate cert = SslUtil.getCertificateFromDerBytes(derBytes);
    if (cert == null) {
        // if the certificate or the client is null, cancel the request
        return false;
    }
    final SslError sslError = SslUtil.sslErrorFromNetErrorCode(certError, cert, url);
    ValueCallback<Boolean> callback = new ValueCallback<Boolean>() {
        @Override
        public void onReceiveValue(Boolean value) {
            proceedSslError(value.booleanValue(), id);
        }
    };
    mClient.onReceivedSslError(callback, sslError);
    return true;
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:19,代码来源:AwContentsClientBridge.java


示例6: sslErrorFromNetErrorCode

import android.net.http.SslCertificate; //导入依赖的package包/类
/**
 * Creates an SslError object from a chromium net error code.
 */
public static SslError sslErrorFromNetErrorCode(int error, SslCertificate cert, String url) {
    assert (error >= NetError.ERR_CERT_END && error <= NetError.ERR_CERT_COMMON_NAME_INVALID);
    switch(error) {
        case NetError.ERR_CERT_COMMON_NAME_INVALID:
            return new SslError(SslError.SSL_IDMISMATCH, cert, url);
        case NetError.ERR_CERT_DATE_INVALID:
            return new SslError(SslError.SSL_DATE_INVALID, cert, url);
        case NetError.ERR_CERT_AUTHORITY_INVALID:
            return new SslError(SslError.SSL_UNTRUSTED, cert, url);
        default:
            break;
    }
    // Map all other codes to SSL_INVALID.
    return new SslError(SslError.SSL_INVALID, cert, url);
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:19,代码来源:SslUtil.java


示例7: isTrusted

import android.net.http.SslCertificate; //导入依赖的package包/类
public static synchronized boolean isTrusted(SslCertificate cert) {
    if (mTrustManager == null) {
        KeyStore trustStore = loadTrustStore();
        mTrustManager = new LocalTrustManager(trustStore);
    }

    try {
        mTrustManager.checkClientTrusted(new X509Certificate[]{getX509CertFromSslCertHack(cert)}, "generic");
    } catch (CertificateException e) {
        return false;
    }

    return true;
}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:15,代码来源:ConnectionUtil.java


示例8: saveState

import android.net.http.SslCertificate; //导入依赖的package包/类
void saveState(SystemWebView view, Bundle bundle) {
    final SslCertificate certificate = view.getCertificate();
    if (certificate != null) {
        bundle.putString(STATE_KEY_URL, view.getUrl());
        bundle.putBundle(STATE_KEY_CERTIFICATE, SslCertificate.saveState(certificate));
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:8,代码来源:FocusWebViewClient.java


示例9: onPageFinished

import android.net.http.SslCertificate; //导入依赖的package包/类
@Override
    public void onPageFinished(AmazonWebView view, final String url) {
        SslCertificate certificate = view.getCertificate();

        if (!TextUtils.isEmpty(restoredUrl)) {
            if (restoredUrl.equals(url) && certificate == null) {
                // We just restored the previous state. Let's re-use the certificate we restored.
                // The reason for that is that WebView doesn't restore the certificate itself.
                // Without restoring the certificate manually we'd lose the certificate when
                // switching tabs or restoring a previous session for other reasons.
                certificate = restoredCertificate;
            } else {
                // The URL has changed since we restored the last state. Let's just clear all
                // restored data because we do not need it anymore.
                restoredUrl = null;
                restoredCertificate = null;
            }
        }

        if (callback != null) {
            callback.onPageFinished(certificate != null);
            // The URL which is supplied in onPageFinished() could be fake (see #301), but webview's
            // URL is always correct _except_ for error pages
            final String viewURL = view.getUrl();
            if (!UrlUtils.isInternalErrorURL(viewURL) && viewURL != null) {
                callback.onURLChanged(viewURL);
            }
        }
        super.onPageFinished(view, url);

//        evaluateJavascript(view,
//                "(function() {" +
//
//                CLEAR_VISITED_CSS +
//
//                "})();");
    }
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:38,代码来源:FocusWebViewClient.java


示例10: saveState

import android.net.http.SslCertificate; //导入依赖的package包/类
void saveState(WebView view, Bundle bundle) {
    final SslCertificate certificate = view.getCertificate();
    if (certificate != null) {
        bundle.putString(STATE_KEY_URL, view.getUrl());
        bundle.putBundle(STATE_KEY_CERTIFICATE, SslCertificate.saveState(certificate));
    }
}
 
开发者ID:mozilla-mobile,项目名称:focus-android,代码行数:8,代码来源:FocusWebViewClient.java


示例11: onPageFinished

import android.net.http.SslCertificate; //导入依赖的package包/类
@Override
public void onPageFinished(WebView view, final String url) {
    SslCertificate certificate = view.getCertificate();

    if (!TextUtils.isEmpty(restoredUrl)) {
        if (restoredUrl.equals(url) && certificate == null) {
            // We just restored the previous state. Let's re-use the certificate we restored.
            // The reason for that is that WebView doesn't restore the certificate itself.
            // Without restoring the certificate manually we'd lose the certificate when
            // switching tabs or restoring a previous session for other reasons.
            certificate = restoredCertificate;
        } else {
            // The URL has changed since we restored the last state. Let's just clear all
            // restored data because we do not need it anymore.
            restoredUrl = null;
            restoredCertificate = null;
        }
    }

    if (callback != null) {
        callback.onPageFinished(certificate != null);
        // The URL which is supplied in onPageFinished() could be fake (see #301), but webview's
        // URL is always correct _except_ for error pages
        final String viewURL = view.getUrl();
        if (!UrlUtils.isInternalErrorURL(viewURL) && viewURL != null) {
            callback.onURLChanged(viewURL);
        }
    }
    super.onPageFinished(view, url);

    view.evaluateJavascript(
            "(function() {" +

            CLEAR_VISITED_CSS +

            "})();",

            null);
}
 
开发者ID:mozilla-mobile,项目名称:focus-android,代码行数:40,代码来源:FocusWebViewClient.java


示例12: onReceivedSslError

import android.net.http.SslCertificate; //导入依赖的package包/类
/**
 * Catch (self-signed) SSL errors and test if they correspond to Syncthing's certificate.
 */
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    try {
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            // The mX509Certificate field is not available for ICS- devices
            Log.w(TAG, "Skipping certificate check for devices <ICS");
            handler.proceed();
            return;
        }
        // Use reflection to access the private mX509Certificate field of SslCertificate
        SslCertificate sslCert = error.getCertificate();
        Field f = sslCert.getClass().getDeclaredField("mX509Certificate");
        f.setAccessible(true);
        X509Certificate cert = (X509Certificate)f.get(sslCert);
        if (cert == null) {
            Log.w(TAG, "X509Certificate reference invalid");
            handler.cancel();
            return;
        }
        cert.verify(mCaCert.getPublicKey());
        handler.proceed();
    } catch (NoSuchFieldException|IllegalAccessException|CertificateException|
            NoSuchAlgorithmException|InvalidKeyException|NoSuchProviderException|
            SignatureException e) {
        Log.w(TAG, e);
        handler.cancel();
    }
}
 
开发者ID:syncthing,项目名称:syncthing-android,代码行数:33,代码来源:WebGuiActivity.java


示例13: getCertificate

import android.net.http.SslCertificate; //导入依赖的package包/类
@Override
public SslCertificate getCertificate() {
    mFactory.startYourEngines(true);
    if (checkNeedsPost()) {
        SslCertificate ret = runOnUiThreadBlocking(new Callable<SslCertificate>() {
            @Override
            public SslCertificate call() {
                return getCertificate();
            }
        });
        return ret;
    }
    return mAwContents.getCertificate();
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:15,代码来源:WebViewChromium.java


示例14: getCertificateFromError

import android.net.http.SslCertificate; //导入依赖的package包/类
private X509Certificate getCertificateFromError(SslError error) throws NoSuchFieldException, IllegalAccessException {
    SslCertificate sslCertificate = error.getCertificate();
    Field mX509CertificateField =  sslCertificate.getClass().getDeclaredField("mX509Certificate");
    mX509CertificateField.setAccessible(true);

    return (X509Certificate) mX509CertificateField.get(sslCertificate);
}
 
开发者ID:silverbullet-dk,项目名称:opentele-client-android,代码行数:8,代码来源:WebViewNode.java


示例15: hasCertificate

import android.net.http.SslCertificate; //导入依赖的package包/类
public WebViewAssert hasCertificate(SslCertificate certificate) {
  isNotNull();
  SslCertificate actualCertificate = actual.getCertificate();
  assertThat(actualCertificate) //
      .overridingErrorMessage("Expected certificate <%s> but was <%s>.", certificate,
          actualCertificate) //
      .isSameAs(certificate);
  return this;
}
 
开发者ID:square,项目名称:assertj-android,代码行数:10,代码来源:WebViewAssert.java


示例16: addCertificateDetails

import android.net.http.SslCertificate; //导入依赖的package包/类
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    java.text.DateFormat dateFormat = DateFormat.getDateFormat(mContext);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:42,代码来源:CertificateViewer.java


示例17: restoreState

import android.net.http.SslCertificate; //导入依赖的package包/类
void restoreState(Bundle bundle) {
    if (bundle != null && bundle.containsKey(STATE_KEY_CERTIFICATE)) {
        restoredUrl = bundle.getString(STATE_KEY_URL);
        restoredCertificate = SslCertificate.restoreState(bundle.getBundle("client_last_certificate"));
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:7,代码来源:FocusWebViewClient.java


示例18: hasCertificate

import android.net.http.SslCertificate; //导入依赖的package包/类
public WebViewSubject hasCertificate(SslCertificate certificate) {
  assertThat(actual().getCertificate())
      .named("certificate")
      .isSameAs(certificate);
  return this;
}
 
开发者ID:pkware,项目名称:truth-android,代码行数:7,代码来源:WebViewSubject.java


示例19: getCertificate

import android.net.http.SslCertificate; //导入依赖的package包/类
/**
 * @return The SSL certificate associated with the error set
 */
public SslCertificate getCertificate() {
    return mCertificate;
}
 
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:7,代码来源:SslError.java


示例20: addCertificateDetails

import android.net.http.SslCertificate; //导入依赖的package包/类
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:42,代码来源:CertificateViewer.java



注:本文中的android.net.http.SslCertificate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AccountLockedException类代码示例发布时间:2022-05-21
下一篇:
Java IEntityClassListener类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap