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


Java PKIXCertPathBuilderResult类代码示例

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


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

示例1: isValid

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Take a CMS SignedData message and a trust anchor and determine if
 * the message is signed with a valid signature from a end entity
 * certificate recognized by the trust anchor rootCert.
 */
public static boolean isValid(CMSSignedData signedData,
                              X509Certificate rootCert)
    throws Exception
{
    CertStore certsAndCRLs = signedData.getCertificatesAndCRLs("Collection", "BC");
    SignerInformationStore signers = signedData.getSignerInfos();
    Iterator<?> it = signers.getSigners().iterator();

    while (it.hasNext())
    {
        SignerInformation signer = (SignerInformation)it.next();
        X509CertSelector signerConstraints = signer.getSID();
        
        signerConstraints.setKeyUsage(getKeyUsageForSignature());            
        PKIXCertPathBuilderResult result = buildPath(rootCert, signer.getSID(), certsAndCRLs);

        if (signer.verify(result.getPublicKey(), "BC"))
        	return true;
    }
    
    return false;
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:28,代码来源:SmimeUtilities.java

示例2: logCertPathDebug

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Log information from the constructed cert path at level debug.
 * 
 * @param buildResult the PKIX cert path builder result containing the cert path and trust anchor
 * @param targetCert the cert untrusted certificate that was being evaluated
 */
private void logCertPathDebug(PKIXCertPathBuilderResult buildResult, X509Certificate targetCert) {
    log.debug("Built valid PKIX cert path");
    log.debug("Target certificate: {}", x500DNHandler.getName(targetCert.getSubjectX500Principal()));
    for (Certificate cert : buildResult.getCertPath().getCertificates()) {
        log.debug("CertPath certificate: {}", x500DNHandler.getName(((X509Certificate) cert)
                .getSubjectX500Principal()));
    }
    TrustAnchor ta = buildResult.getTrustAnchor();
    if (ta.getTrustedCert() != null) {
        log.debug("TrustAnchor: {}", x500DNHandler.getName(ta.getTrustedCert().getSubjectX500Principal()));
    } else if (ta.getCA() != null) {
        log.debug("TrustAnchor: {}", x500DNHandler.getName(ta.getCA()));
    } else {
        log.debug("TrustAnchor: {}", ta.getCAName());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:CertPathPKIXTrustEvaluator.java

示例3: testPKIXCertPathBuilderResult01

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    method = "PKIXCertPathBuilderResult",
    args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult01()
    throws InvalidKeySpecException,
           NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);
    assertTrue(r instanceof PKIXCertPathBuilderResult);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:PKIXCertPathBuilderResultTest.java

示例4: testPKIXCertPathBuilderResult02

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: policy tree parameter may be <code>null</code>
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    method = "PKIXCertPathBuilderResult",
    args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult02()
    throws InvalidKeySpecException,
           NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                null,
                testPublicKey);
    assertTrue(r instanceof PKIXCertPathBuilderResult);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:PKIXCertPathBuilderResultTest.java

示例5: testPKIXCertPathBuilderResult03

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: <code>NullPointerException</code>
 * if certPath is <code>null</code>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    method = "PKIXCertPathBuilderResult",
    args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult03() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }

    try {
        // pass null
        new PKIXCertPathBuilderResult(
                null,
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:29,代码来源:PKIXCertPathBuilderResultTest.java

示例6: testPKIXCertPathBuilderResult04

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: <code>NullPointerException</code>
 * if trustAnchor is <code>null</code>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    method = "PKIXCertPathBuilderResult",
    args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult04() {
    try {
        // pass null
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                null,
                TestUtils.getPolicyTree(),
                testPublicKey);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:PKIXCertPathBuilderResultTest.java

示例7: testPKIXCertPathBuilderResult05

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: <code>NullPointerException</code>
 * if publicKey is <code>null</code>
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    method = "PKIXCertPathBuilderResult",
    args = {java.security.cert.CertPath.class, java.security.cert.TrustAnchor.class, java.security.cert.PolicyNode.class, java.security.PublicKey.class}
)
public final void testPKIXCertPathBuilderResult05() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }

    try {
        // pass null
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                TestUtils.getPolicyTree(),
                null);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:29,代码来源:PKIXCertPathBuilderResultTest.java

示例8: test_clone

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "clone",
    args = {}
)
public final void test_clone() {

    // Regression for HARMONY-2786.
    TrustAnchor ta = TestUtils.getTrustAnchor();
    assertNotNull(getName()
            + ": not performed (could not create test TrustAnchor)", ta);

    PKIXCertPathBuilderResult init = new PKIXCertPathBuilderResult(
            new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(),
            testPublicKey);

    PKIXCertPathBuilderResult clone = (PKIXCertPathBuilderResult) init
            .clone();
    assertSame(init.getCertPath(), clone.getCertPath());
    assertSame(init.getPolicyTree(), clone.getPolicyTree());
    assertSame(init.getPublicKey(), clone.getPublicKey());
    assertSame(init.getTrustAnchor(), clone.getTrustAnchor());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:PKIXCertPathBuilderResultTest.java

示例9: testGetCertPath

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test for <code>getCertPath()</code> method<br>
 * Assertion: the built and validated <code>CertPath</code>
 * (never <code>null</code>)
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getCertPath",
    args = {}
)
public final void testGetCertPath() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }

    CertPath cp = new MyCertPath(testEncoding);
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                cp,
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);

    // must return the same reference
    // as passed to the constructor
    assertSame(cp, r.getCertPath());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:PKIXCertPathBuilderResultTest.java

示例10: testToString

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test for <code>toString()</code> method<br>
 * Assertion: the printable representation of this object
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "toString",
    args = {}
)
public final void testToString()
    throws InvalidKeySpecException,
           NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);

    assertNotNull(r.toString());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:29,代码来源:PKIXCertPathBuilderResultTest.java

示例11: testPKIXCertPathBuilderResult01

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
public final void testPKIXCertPathBuilderResult01()
    throws InvalidKeySpecException,
           NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);
    assertTrue(r instanceof PKIXCertPathBuilderResult);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:PKIXCertPathBuilderResultTest.java

示例12: testPKIXCertPathBuilderResult02

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: policy tree parameter may be <code>null</code>
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 */
public final void testPKIXCertPathBuilderResult02()
    throws InvalidKeySpecException,
           NoSuchAlgorithmException {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    CertPathBuilderResult r =
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                null,
                testPublicKey);
    assertTrue(r instanceof PKIXCertPathBuilderResult);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:PKIXCertPathBuilderResultTest.java

示例13: testPKIXCertPathBuilderResult03

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: <code>NullPointerException</code>
 * if certPath is <code>null</code>
 */
public final void testPKIXCertPathBuilderResult03() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }

    try {
        // pass null
        new PKIXCertPathBuilderResult(
                null,
                ta,
                TestUtils.getPolicyTree(),
                testPublicKey);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:PKIXCertPathBuilderResultTest.java

示例14: testPKIXCertPathBuilderResult05

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
/**
 * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
 *   PolicyNode, PublicKey)</code> constructor<br>
 * Assertion: <code>NullPointerException</code>
 * if publicKey is <code>null</code>
 */
public final void testPKIXCertPathBuilderResult05() {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }

    try {
        // pass null
        new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding),
                ta,
                TestUtils.getPolicyTree(),
                null);
        fail("NPE expected");
    } catch (NullPointerException e) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:PKIXCertPathBuilderResultTest.java

示例15: test_clone

import java.security.cert.PKIXCertPathBuilderResult; //导入依赖的package包/类
public final void test_clone() {

        // Regression for HARMONY-2786.
        TrustAnchor ta = TestUtils.getTrustAnchor();
        assertNotNull(getName()
                + ": not performed (could not create test TrustAnchor)", ta);

        PKIXCertPathBuilderResult init = new PKIXCertPathBuilderResult(
                new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(),
                testPublicKey);

        PKIXCertPathBuilderResult clone = (PKIXCertPathBuilderResult) init
                .clone();
        assertSame(init.getCertPath(), clone.getCertPath());
        assertSame(init.getPolicyTree(), clone.getPolicyTree());
        assertSame(init.getPublicKey(), clone.getPublicKey());
        assertSame(init.getTrustAnchor(), clone.getTrustAnchor());
    }
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:PKIXCertPathBuilderResultTest.java


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