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


Java JcaSimpleSignerInfoVerifierBuilder类代码示例

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


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

示例1: verifySignature

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public static boolean verifySignature(CMSSignedData cmsSignedData, X509Certificate cert) {
    try {
        if (Security.getProvider("BC") == null)
            Security.addProvider(new BouncyCastleProvider());

        Collection<SignerInformation> signers = cmsSignedData.getSignerInfos().getSigners();
        X509CertificateHolder ch = new X509CertificateHolder(cert.getEncoded());
        for (SignerInformation si : signers)
            if (si.getSID().match(ch))
                if (si.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(ch)))
                    return true;
    } catch (Exception e) {}
    return false;
}
 
开发者ID:damianofalcioni,项目名称:Websocket-Smart-Card-Signer,代码行数:15,代码来源:PKCS7Manager.java

示例2: verifyAllSignatures

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public static boolean verifyAllSignatures(CMSSignedData cmsSignedData) {
    try {
        if (Security.getProvider("BC") == null)
            Security.addProvider(new BouncyCastleProvider());

        Collection<SignerInformation> signers = cmsSignedData.getSignerInfos().getSigners();

        for (SignerInformation si : signers) {
            @SuppressWarnings("unchecked")
            Collection<X509CertificateHolder> certList = cmsSignedData.getCertificates().getMatches(si.getSID());
            if (certList.size() == 0)
                throw new Exception("ERROR: Impossible to find a Certificate using the Signer ID: " + si.getSID());

            X509CertificateHolder cert = certList.iterator().next(); // Take only the first certificate of the chain

            if (!si.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert)))
                throw new Exception("ATTENTION: At least a signature is invalid!");

            boolean certOK = true;
            String msg = "";
            try {
                X509Utils.checkAllOnCertificate(X509Utils.getX509Certificate(cert.getEncoded()));
            } catch (Exception ex) {
                msg = ex.getMessage();
                certOK = false;
            }
            if (!certOK)
                throw new Exception("ATTENTION: The certificate is invalid:\n" + msg);
        }

        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
开发者ID:damianofalcioni,项目名称:Websocket-Smart-Card-Signer,代码行数:38,代码来源:PKCS7Manager.java

示例3: verifyTimestampCertificates

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
/**
 * Verifies a timestamp against a KeyStore.
 * @param ts the timestamp
 * @param keystore the <CODE>KeyStore</CODE>
 * @param provider the provider or <CODE>null</CODE> to use the BouncyCastle provider
 * @return <CODE>true</CODE> is a certificate was found
 * @since	2.1.6
 */    
public static boolean verifyTimestampCertificates(TimeStampToken ts, KeyStore keystore, String provider) {
    if (provider == null)
        provider = "BC";
    try {
        for (Enumeration aliases = keystore.aliases(); aliases.hasMoreElements();) {
            try {
                String alias = (String)aliases.nextElement();
                if (!keystore.isCertificateEntry(alias))
                    continue;
                X509Certificate certStoreX509 = (X509Certificate)keystore.getCertificate(alias);
                SignerInformationVerifier siv = new JcaSimpleSignerInfoVerifierBuilder().setProvider(provider).build(certStoreX509);
                ts.validate(siv);
                return true;
            }
            catch (Exception ex) {
            }
        }
    }
    catch (Exception e) {
    }
    return false;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:31,代码来源:PdfPKCS7.java

示例4: signatureVerified

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
/**
 * Verify the passed in CMS signed data, return false on failure.
 *
 * @param cmsData a CMSSignedData object.
 * @return true if signature checks out, false if there is a problem with the signature or the path to its verifying certificate.
 */
public boolean signatureVerified(CMSSignedData cmsData)
{
    Store certs = cmsData.getCertificates();
    SignerInformationStore signers = cmsData.getSignerInfos();

    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    SignerInformation signer = (SignerInformation)it.next();

    try
    {
        PKIXCertPathBuilderResult result = checkCertPath(signer.getSID(), certs);

        X509Certificate cert = (X509Certificate)result.getCertPath().getCertificates().get(0);

        return signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert));
    }
    catch (Exception e)
    {
        return false;
    }
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:30,代码来源:SignedDataVerifier.java

示例5: PECVerifier

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public PECVerifier() {
	this.bcprov = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
	if (this.bcprov == null) {
		this.bcprov = new BouncyCastleProvider();
		Security.addProvider(bcprov);
	}

	this.verifier = new JcaSimpleSignerInfoVerifierBuilder();
	this.verifier.setProvider(bcprov);

	this.jcaX509CertificateConverter = new JcaX509CertificateConverter();
	this.jcaX509CertificateConverter.setProvider(bcprov);

	if (!Init.isInitialized()) {
		Init.init();
	}
}
 
开发者ID:tornabene,项目名称:jopenpec,代码行数:18,代码来源:PECVerifier.java

示例6: checkSignerStoreReplacement

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
private void checkSignerStoreReplacement(
    CMSSignedData orig, 
    SignerInformationStore signers) 
    throws Exception
{
    CMSSignedData s = CMSSignedData.replaceSigners(orig, signers);
    
    Store certs = s.getCertificates();
    
    signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certs.getMatches(signer.getSID());

        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:25,代码来源:BcSignedDataTest.java

示例7: testUnsortedAttributes

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testUnsortedAttributes()
    throws Exception
{
    CMSSignedData s = new CMSSignedData(new CMSProcessableByteArray(disorderedMessage), disorderedSet);

    Store certs = s.getCertificates();

    SignerInformationStore  signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certs.getMatches(signer.getSID());
        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:BcSignedDataTest.java

示例8: verifySignatures

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
private void verifySignatures(CMSSignedDataParser sp)
    throws Exception
{
    Store               certs = sp.getCertificates();
    SignerInformationStore  signers = sp.getSignerInfos();

    Collection c = signers.getSigners();
    Iterator it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection certCollection = certs.getMatches(signer.getSID());

        Iterator certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:BcSignedDataTest.java

示例9: testGostNoAttributesEncapsulated

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testGostNoAttributesEncapsulated()
    throws Exception
{
    CMSSignedData data = new CMSSignedData(rawGost);

    Store                   certStore = data.getCertificates();
    SignerInformationStore  signers = data.getSignerInfos();

    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certStore.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:23,代码来源:NewSignedDataTest.java

示例10: checkSignerStoreReplacement

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
private void checkSignerStoreReplacement(
    CMSSignedData orig, 
    SignerInformationStore signers) 
    throws Exception
{
    CMSSignedData s = CMSSignedData.replaceSigners(orig, signers);
    
    Store certs = s.getCertificates();
    
    signers = s.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator   it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:25,代码来源:NewSignedDataTest.java

示例11: testUnsortedAttributes

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testUnsortedAttributes()
    throws Exception
{
    CMSSignedData s = new CMSSignedData(new CMSProcessableByteArray(disorderedMessage), disorderedSet);

    Store certs = s.getCertificates();

    SignerInformationStore  signers = s.getSignerInfos();
    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());
        Iterator              certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:NewSignedDataTest.java

示例12: verifySignatures

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
private void verifySignatures(CMSSignedDataParser sp)
    throws Exception
{
    Store               certs = sp.getCertificates();
    SignerInformationStore  signers = sp.getSignerInfos();

    Collection              c = signers.getSigners();
    Iterator                it = c.iterator();

    while (it.hasNext())
    {
        SignerInformation   signer = (SignerInformation)it.next();
        Collection          certCollection = certs.getMatches(signer.getSID());

        Iterator        certIt = certCollection.iterator();
        X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

        assertEquals(true, signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:NewSignedDataTest.java

示例13: testCPDRequest

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testCPDRequest()
    throws Exception
{
    CMSSignedData reqMsg = getWrappedCPDRequest();

    assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
    {
        public SignerInformationVerifier get(SignerId sid)
            throws OperatorCreationException
        {
            return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
        }
    }));

    DVCSRequest request = new DVCSRequest(reqMsg);

    CPDRequestData reqData = (CPDRequestData)request.getData();

    assertTrue(Arrays.areEqual(new byte[100], reqData.getMessage()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:AllTests.java

示例14: testVPKCRequest

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testVPKCRequest()
    throws Exception
{
    SignedDVCSMessageGenerator gen = getSignedDVCSMessageGenerator();

    VPKCRequestBuilder reqBuilder = new VPKCRequestBuilder();

    reqBuilder.addTargetChain(new JcaX509CertificateHolder(signCert));

    CMSSignedData reqMsg = gen.build(reqBuilder.build());

    assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
    {
        public SignerInformationVerifier get(SignerId sid)
            throws OperatorCreationException
        {
            return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
        }
    }));

    DVCSRequest request = new DVCSRequest(reqMsg);

    VPKCRequestData reqData = (VPKCRequestData)request.getData();

    assertEquals(new TargetEtcChain(new CertEtcToken(CertEtcToken.TAG_CERTIFICATE, new JcaX509CertificateHolder(signCert).toASN1Structure())), ((TargetChain)reqData.getCerts().get(0)).toASN1Structure());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:27,代码来源:AllTests.java

示例15: testVSDRequest

import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; //导入依赖的package包/类
public void testVSDRequest()
    throws Exception
{
    CMSSignedData message = getWrappedCPDRequest();

    SignedDVCSMessageGenerator gen = getSignedDVCSMessageGenerator();

    VSDRequestBuilder reqBuilder = new VSDRequestBuilder();

    CMSSignedData reqMsg = gen.build(reqBuilder.build(message));

    assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
    {
        public SignerInformationVerifier get(SignerId sid)
            throws OperatorCreationException
        {
            return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
        }
    }));

    DVCSRequest request = new DVCSRequest(reqMsg);

    VSDRequestData reqData = (VSDRequestData)request.getData();

    assertEquals(message.toASN1Structure().getContentType(), reqData.getParsedMessage().toASN1Structure().getContentType());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:27,代码来源:AllTests.java


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