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


Java CertPathBuilder类代码示例

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


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

示例1: PKIXCertificateValidationProvider

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Initializes a new instance that uses the specified JCE providers for CertPathBuilder
 * and Signature.
 * @param trustAnchors the keystore with the trust-anchors ({@code TrustedCertificateEntry})
 * @param revocationEnabled whether revocation is enabled
 * @param maxPathLength the maximum length of the certification paths
 * @param certPathBuilderProvider the CertPathBuilder provider
 * @param signatureProvider the Signature provider
 * @param intermCertsAndCrls a set of {@code CertStore}s that contain certificates to be
 *      used in the construction of the certification path. May contain CRLs to be used
 *      if revocation is enabled
 * @see xades4j.utils.FileSystemDirectoryCertStore
 * @throws NoSuchAlgorithmException if there is no provider for PKIX CertPathBuilder
 */
public PKIXCertificateValidationProvider(
        KeyStore trustAnchors,
        boolean revocationEnabled,
        int maxPathLength,
        String certPathBuilderProvider,
        String signatureProvider,
        CertStore... intermCertsAndCrls) throws NoSuchAlgorithmException, NoSuchProviderException
{
    if (null == trustAnchors)
    {
        throw new NullPointerException("Trust anchors cannot be null");
    }

    this.trustAnchors = trustAnchors;
    this.revocationEnabled = revocationEnabled;
    this.maxPathLength = maxPathLength;
    this.certPathBuilder = certPathBuilderProvider == null ? CertPathBuilder.getInstance("PKIX") : CertPathBuilder.getInstance("PKIX", certPathBuilderProvider);
    this.signatureProvider = signatureProvider;
    this.intermCertsAndCrls = intermCertsAndCrls;
}
 
开发者ID:luisgoncalves,项目名称:xades4j,代码行数:35,代码来源:PKIXCertificateValidationProvider.java

示例2: createCPBs

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
private static CertPathBuilder[] createCPBs() {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return null;
    }
    try {
        CertPathBuilder[] certPBs = new CertPathBuilder[3];
        certPBs[0] = CertPathBuilder.getInstance(defaultType);
        certPBs[1] = CertPathBuilder.getInstance(defaultType,
                defaultProviderName);
        certPBs[2] = CertPathBuilder.getInstance(defaultType,
                defaultProvider);
        return certPBs;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:CertPathBuilder1Test.java

示例3: testCertPathBuilder03

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm)</code> method
 * Assertion: returns CertPathBuilder object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies positive functionality.",
    method = "getInstance",
    args = {java.lang.String.class}
)
public void testCertPathBuilder03() throws NoSuchAlgorithmException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    for (int i = 0; i < validValues.length; i++) {
        CertPathBuilder cpb = CertPathBuilder.getInstance(validValues[i]);
        assertEquals("Incorrect algorithm", cpb.getAlgorithm(), validValues[i]);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:CertPathBuilder1Test.java

示例4: testCertPathBuilder05

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, String provider)</code> method
 * Assertion:
 * throws NoSuchProviderException when provider has invalid value
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies that getInstance throws NoSuchProviderException when provider has invalid value.",
    method = "getInstance",
    args = {java.lang.String.class, java.lang.String.class}
)
public void testCertPathBuilder05()
        throws NoSuchAlgorithmException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    for (int i = 0; i < validValues.length; i++ ) {
        for (int j = 1; j < invalidValues.length; j++) {
            try {
                CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
                fail("NoSuchProviderException must be hrown");
            } catch (NoSuchProviderException e1) {
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:CertPathBuilder1Test.java

示例5: testCertPathBuilder06

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, String provider)</code> method
 * Assertion:
 * throws NullPointerException when algorithm is null
 * throws NoSuchAlgorithmException when algorithm  is not correct
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies NullPointerException when algorithm is null; verifies NoSuchAlgorithmException when algorithm  is not correct.",
    method = "getInstance",
    args = {java.lang.String.class, java.lang.String.class}
)
public void testCertPathBuilder06()
        throws NoSuchAlgorithmException, NoSuchProviderException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    try {
        CertPathBuilder.getInstance(null, defaultProviderName);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
    for (int i = 0; i < invalidValues.length; i++) {
        try {
            CertPathBuilder.getInstance(invalidValues[i], defaultProviderName);
            fail("NoSuchAlgorithmException must be thrown");
        } catch (NoSuchAlgorithmException e1) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:CertPathBuilder1Test.java

示例6: testCertPathBuilder07

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, String provider)</code> method
 * Assertion: returns CertPathBuilder object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies positive case.",
    method = "getInstance",
    args = {java.lang.String.class, java.lang.String.class}
)
public void testCertPathBuilder07()
        throws NoSuchAlgorithmException, NoSuchProviderException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    CertPathBuilder certPB;
    for (int i = 0; i < validValues.length; i++) {
        certPB = CertPathBuilder.getInstance(validValues[i], defaultProviderName);
        assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
        assertEquals("Incorrect provider name", certPB.getProvider().getName(), defaultProviderName);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertPathBuilder1Test.java

示例7: testCertPathBuilder08

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, Provider provider)</code> method
 * Assertion: throws IllegalArgumentException when provider is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies that getInstance method throws IllegalArgumentException when provider is null method.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.Provider.class}
)
public void testCertPathBuilder08()
        throws NoSuchAlgorithmException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    Provider prov = null;
    for (int t = 0; t < validValues.length; t++ ) {
        try {
            CertPathBuilder.getInstance(validValues[t], prov);
            fail("IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e1) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:CertPathBuilder1Test.java

示例8: testCertPathBuilder09

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, String provider)</code> method
 * Assertion:
 * throws NullPointerException when algorithm is null
 * throws NoSuchAlgorithmException when algorithm  is not correct
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies that getInstance method throws NullPointerException when algorithm is null, throws NoSuchAlgorithmException when algorithm  is not correct.",
    method = "getInstance",
    args = {java.lang.String.class, java.security.Provider.class}
)
public void testCertPathBuilder09()
        throws NoSuchAlgorithmException, NoSuchProviderException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    try {
        CertPathBuilder.getInstance(null, defaultProvider);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
    for (int i = 0; i < invalidValues.length; i++) {
        try {
            CertPathBuilder.getInstance(invalidValues[i], defaultProvider);
            fail("NoSuchAlgorithm must be thrown");
        } catch (NoSuchAlgorithmException e1) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:CertPathBuilder1Test.java

示例9: testCertPathBuilder10

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>getInstance(String algorithm, String provider)</code> method
 * Assertion: returns CertPathBuilder object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies that getInstance returns CertPathBuilder object.",
    method = "getInstance",
    args = {java.lang.String.class, java.lang.String.class}
)
public void testCertPathBuilder10()
        throws NoSuchAlgorithmException, NoSuchProviderException  {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    CertPathBuilder certPB;
    for (int i = 0; i < invalidValues.length; i++) {
        certPB = CertPathBuilder.getInstance(validValues[i], defaultProvider);
        assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
        assertEquals("Incorrect provider name", certPB.getProvider(), defaultProvider);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertPathBuilder1Test.java

示例10: testCertPathBuilder11

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
 * Test for <code>build(CertPathParameters params)</code> method
 * Assertion: throws InvalidAlgorithmParameterException params is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies that build method throws InvalidAlgorithmParameterException if a parameter is null.",
    method = "build",
    args = {java.security.cert.CertPathParameters.class}
)
public void testCertPathBuilder11()
        throws NoSuchAlgorithmException, NoSuchProviderException,
        CertPathBuilderException {
    if (!PKIXSupport) {
        fail(NotSupportMsg);
        return;
    }
    CertPathBuilder [] certPB = createCPBs();
    assertNotNull("CertPathBuilder objects were not created", certPB);
    for (int i = 0; i < certPB.length; i++ ){
        try {
            certPB[i].build(null);
            fail("InvalidAlgorithmParameterException must be thrown");
        } catch(InvalidAlgorithmParameterException e) {
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:CertPathBuilder1Test.java

示例11: testBuild

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
@TestTargetNew(
        level=TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies normal case",
        method="build",
        args={CertPathParameters.class}
)
// Test passed on RI
@KnownFailure(value="expired certificate bug 2322662")
public void testBuild() throws Exception {
    TestUtils.initCertPathSSCertChain();
    CertPathParameters params = TestUtils.getCertPathParameters();
    CertPathBuilder builder = TestUtils.getCertPathBuilder();

    try {
        CertPathBuilderResult result = builder.build(params);
        assertNotNull("builder result is null", result);
        CertPath certPath = result.getCertPath();
        assertNotNull("certpath of builder result is null", certPath);
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected Exception: " + e);
    }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:CertPathBuilder1Test.java

示例12: checkResult

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
private void checkResult(CertPathBuilder certBuild)
        throws InvalidAlgorithmParameterException,
        CertPathBuilderException {
    String dt = CertPathBuilder.getDefaultType();
    String propName = CertPathBuilder1Test.DEFAULT_TYPE_PROPERTY;
    String dtN;
    for (int i = 0; i <invalidValues.length; i++) {
        Security.setProperty(propName, invalidValues[i]);
        dtN = CertPathBuilder.getDefaultType();
        if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
            fail("Incorrect default type: ".concat(dtN));
        }
    }
    Security.setProperty(propName, dt);
    assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
            dt);
    try {
        certBuild.build(null);
        fail("CertPathBuilderException must be thrown");
    } catch (CertPathBuilderException e) {
    }
    CertPathBuilderResult cpbResult = certBuild.build(null);
    assertNull("Not null CertPathBuilderResult", cpbResult);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:CertPathBuilder2Test.java

示例13: testCertPathBuilder05

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
   * Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertion: 
* throws NoSuchProviderException when provider has invalid value
   */
  public void testCertPathBuilder05()
          throws NoSuchAlgorithmException  {
      if (!PKIXSupport) {
          fail(NotSupportMsg);
          return;
      }
      for (int i = 0; i < validValues.length; i++ ) {
          for (int j = 1; j < invalidValues.length; j++) {
              try {
                  CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
                  fail("NoSuchProviderException must be hrown");
              } catch (NoSuchProviderException e1) {
              }
          }
      }        
  }
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:CertPathBuilder1Test.java

示例14: testCertPathBuilder06

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
   * Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertion: 
* throws NullPointerException when algorithm is null 
* throws NoSuchAlgorithmException when algorithm  is not correct
   */
  public void testCertPathBuilder06()
          throws NoSuchAlgorithmException, NoSuchProviderException  {
      if (!PKIXSupport) {
          fail(NotSupportMsg);
          return;
      }
      try {
          CertPathBuilder.getInstance(null, defaultProviderName);
          fail("No expected NullPointerException");
      } catch (NullPointerException e) {
      }
      for (int i = 0; i < invalidValues.length; i++) {
          try {
              CertPathBuilder.getInstance(invalidValues[i], defaultProviderName);
              fail("NoSuchAlgorithmException must be thrown");
          } catch (NoSuchAlgorithmException e1) {
          }
      }        
  }
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:CertPathBuilder1Test.java

示例15: testCertPathBuilder08

import java.security.cert.CertPathBuilder; //导入依赖的package包/类
/**
   * Test for <code>getInstance(String algorithm, Provider provider)</code> method
* Assertion: throws IllegalArgumentException when provider is null
   */
  public void testCertPathBuilder08()
          throws NoSuchAlgorithmException  {
      if (!PKIXSupport) {
          fail(NotSupportMsg);
          return;
      }
      Provider prov = null;
      for (int t = 0; t < validValues.length; t++ ) {
          try {
              CertPathBuilder.getInstance(validValues[t], prov);
              fail("IllegalArgumentException must be thrown");
          } catch (IllegalArgumentException e1) {
          }
      }        
  }
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:CertPathBuilder1Test.java


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