当前位置: 首页>>代码示例>>Java>>正文


Java CertificateChainCleaner类代码示例

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


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

示例1: orderedChainOfCertificatesWithRoot

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void orderedChainOfCertificatesWithRoot() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(root)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(certA)
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(certB, certA, root), cleaner.clean(list(certB, certA, root), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:CertificateChainCleanerTest.java

示例2: orderedChainOfCertificatesWithoutRoot

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void orderedChainOfCertificatesWithoutRoot() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(root)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(certA)
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(certB, certA, root),
      cleaner.clean(list(certB, certA), "hostname")); // Root is added!
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:CertificateChainCleanerTest.java

示例3: unorderedChainOfCertificatesWithRoot

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void unorderedChainOfCertificatesWithRoot() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(root)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(certA)
      .build();
  HeldCertificate certC = new HeldCertificate.Builder()
      .serialNumber("4")
      .issuedBy(certB)
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(certC, certB, certA, root),
      cleaner.clean(list(certC, certA, root, certB), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:CertificateChainCleanerTest.java

示例4: unorderedChainOfCertificatesWithoutRoot

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void unorderedChainOfCertificatesWithoutRoot() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(root)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(certA)
      .build();
  HeldCertificate certC = new HeldCertificate.Builder()
      .serialNumber("4")
      .issuedBy(certB)
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(certC, certB, certA, root),
      cleaner.clean(list(certC, certA, certB), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:CertificateChainCleanerTest.java

示例5: unrelatedCertificatesAreOmitted

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void unrelatedCertificatesAreOmitted() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(root)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(certA)
      .build();
  HeldCertificate certUnnecessary = new HeldCertificate.Builder()
      .serialNumber("4")
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(certB, certA, root),
      cleaner.clean(list(certB, certUnnecessary, certA, root), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:CertificateChainCleanerTest.java

示例6: chainGoesAllTheWayToSelfSignedRoot

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void chainGoesAllTheWayToSelfSignedRoot() throws Exception {
  HeldCertificate selfSigned = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate trusted = new HeldCertificate.Builder()
      .serialNumber("2")
      .issuedBy(selfSigned)
      .build();
  HeldCertificate certA = new HeldCertificate.Builder()
      .serialNumber("3")
      .issuedBy(trusted)
      .build();
  HeldCertificate certB = new HeldCertificate.Builder()
      .serialNumber("4")
      .issuedBy(certA)
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(
      selfSigned.certificate, trusted.certificate);
  assertEquals(list(certB, certA, trusted, selfSigned),
      cleaner.clean(list(certB, certA), "hostname"));
  assertEquals(list(certB, certA, trusted, selfSigned),
      cleaner.clean(list(certB, certA, trusted), "hostname"));
  assertEquals(list(certB, certA, trusted, selfSigned),
      cleaner.clean(list(certB, certA, trusted, selfSigned), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:CertificateChainCleanerTest.java

示例7: trustedRootNotSelfSigned

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void trustedRootNotSelfSigned() throws Exception {
  HeldCertificate unknownSigner = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate trusted = new HeldCertificate.Builder()
      .issuedBy(unknownSigner)
      .serialNumber("2")
      .build();
  HeldCertificate intermediateCa = new HeldCertificate.Builder()
      .issuedBy(trusted)
      .serialNumber("3")
      .build();
  HeldCertificate certificate = new HeldCertificate.Builder()
      .issuedBy(intermediateCa)
      .serialNumber("4")
      .build();

  CertificateChainCleaner cleaner = CertificateChainCleaner.get(trusted.certificate);
  assertEquals(list(certificate, intermediateCa, trusted),
      cleaner.clean(list(certificate, intermediateCa), "hostname"));
  assertEquals(list(certificate, intermediateCa, trusted),
      cleaner.clean(list(certificate, intermediateCa, trusted), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:CertificateChainCleanerTest.java

示例8: buildCertificateChainCleaner

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager trustManager) {
  try {
    Class<?> extensionsClass = Class.forName("android.net.http.X509TrustManagerExtensions");
    Constructor<?> constructor = extensionsClass.getConstructor(X509TrustManager.class);
    Object extensions = constructor.newInstance(trustManager);
    Method checkServerTrusted = extensionsClass.getMethod(
        "checkServerTrusted", X509Certificate[].class, String.class, String.class);
    return new AndroidCertificateChainCleaner(extensions, checkServerTrusted);
  } catch (Exception e) {
    return super.buildCertificateChainCleaner(trustManager);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:AndroidPlatform.java

示例9: equalsFromCertificate

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void equalsFromCertificate() throws Exception {
  HeldCertificate rootA = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  HeldCertificate rootB = new HeldCertificate.Builder()
      .serialNumber("2")
      .build();
  assertEquals(
      CertificateChainCleaner.get(rootA.certificate, rootB.certificate),
      CertificateChainCleaner.get(rootB.certificate, rootA.certificate));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:CertificateChainCleanerTest.java

示例10: equalsFromTrustManager

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void equalsFromTrustManager() throws Exception {
  SslClient client = new SslClient.Builder().build();
  X509TrustManager x509TrustManager = client.trustManager;
  assertEquals(
      CertificateChainCleaner.get(x509TrustManager),
      CertificateChainCleaner.get(x509TrustManager));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CertificateChainCleanerTest.java

示例11: normalizeSingleSelfSignedCertificate

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void normalizeSingleSelfSignedCertificate() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
  assertEquals(list(root), cleaner.clean(list(root), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CertificateChainCleanerTest.java

示例12: normalizeUnknownSelfSignedCertificate

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void normalizeUnknownSelfSignedCertificate() throws Exception {
  HeldCertificate root = new HeldCertificate.Builder()
      .serialNumber("1")
      .build();
  CertificateChainCleaner cleaner = CertificateChainCleaner.get();

  try {
    cleaner.clean(list(root), "hostname");
    fail();
  } catch (SSLPeerUnverifiedException expected) {
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:CertificateChainCleanerTest.java

示例13: chainMaxLength

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void chainMaxLength() throws Exception {
  List<HeldCertificate> heldCertificates = chainOfLength(10);
  List<Certificate> certificates = new ArrayList<>();
  for (HeldCertificate heldCertificate : heldCertificates) {
    certificates.add(heldCertificate.certificate);
  }

  X509Certificate root = heldCertificates.get(heldCertificates.size() - 1).certificate;
  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root);
  assertEquals(certificates, cleaner.clean(certificates, "hostname"));
  assertEquals(certificates, cleaner.clean(certificates.subList(0, 9), "hostname"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:CertificateChainCleanerTest.java

示例14: chainTooLong

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
@Test public void chainTooLong() throws Exception {
  List<HeldCertificate> heldCertificates = chainOfLength(11);
  List<Certificate> certificates = new ArrayList<>();
  for (HeldCertificate heldCertificate : heldCertificates) {
    certificates.add(heldCertificate.certificate);
  }

  X509Certificate root = heldCertificates.get(heldCertificates.size() - 1).certificate;
  CertificateChainCleaner cleaner = CertificateChainCleaner.get(root);
  try {
    cleaner.clean(certificates, "hostname");
    fail();
  } catch (SSLPeerUnverifiedException expected) {
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:CertificateChainCleanerTest.java

示例15: withCertificateChainCleaner

import okhttp3.internal.tls.CertificateChainCleaner; //导入依赖的package包/类
/** Returns a certificate pinner that uses {@code certificateChainCleaner}. */
CertificatePinner withCertificateChainCleaner(
    @Nullable CertificateChainCleaner certificateChainCleaner) {
  return equal(this.certificateChainCleaner, certificateChainCleaner)
      ? this
      : new CertificatePinner(pins, certificateChainCleaner);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CertificatePinner.java


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