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


Java CMSSignedDataGenerator.generateCounterSigners方法代码示例

本文整理汇总了Java中org.bouncycastle.cms.CMSSignedDataGenerator.generateCounterSigners方法的典型用法代码示例。如果您正苦于以下问题:Java CMSSignedDataGenerator.generateCounterSigners方法的具体用法?Java CMSSignedDataGenerator.generateCounterSigners怎么用?Java CMSSignedDataGenerator.generateCounterSigners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.cms.CMSSignedDataGenerator的用法示例。


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

示例1: testSHA1WithRSACounterSignature

import org.bouncycastle.cms.CMSSignedDataGenerator; //导入方法依赖的package包/类
public void testSHA1WithRSACounterSignature()
    throws Exception
{
    List                certList = new ArrayList();
    CMSProcessable      msg = new CMSProcessableByteArray("Hello World!".getBytes());

    certList.add(_signCert);
    certList.add(_origCert);

    certList.add(_signCrl);

    CertStore           certsAndCrls = CertStore.getInstance("Collection",
                    new CollectionCertStoreParameters(certList), BC);

    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

    gen.addSigner(_signKP.getPrivate(), _signCert, CMSSignedDataGenerator.DIGEST_SHA1);

    gen.addCertificatesAndCRLs(certsAndCrls);

    CMSSignedData s = gen.generate(msg, true, BC);
    SignerInformation origSigner = (SignerInformation)s.getSignerInfos().getSigners().toArray()[0];
    SignerInformationStore counterSigners1 = gen.generateCounterSigners(origSigner, BC);
    SignerInformationStore counterSigners2 = gen.generateCounterSigners(origSigner, BC);

    SignerInformation signer1 = SignerInformation.addCounterSigners(origSigner, counterSigners1);
    SignerInformation signer2 = SignerInformation.addCounterSigners(signer1, counterSigners2);

    SignerInformationStore cs = signer2.getCounterSignatures();
    Collection csSigners = cs.getSigners();
    assertEquals(2, csSigners.size());

    Iterator it = csSigners.iterator();
    while (it.hasNext())
    {
        SignerInformation   cSigner = (SignerInformation)it.next();
        Collection          certCollection = certsAndCrls.getCertificates(selectorConverter.getCertSelector(cSigner.getSID()));

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

        assertNull(cSigner.getSignedAttributes().get(PKCSObjectIdentifiers.pkcs_9_at_contentType));
        assertEquals(true, cSigner.verify(cert, BC));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:46,代码来源:SignedDataTest.java

示例2: testSHA1WithRSACounterSignature

import org.bouncycastle.cms.CMSSignedDataGenerator; //导入方法依赖的package包/类
public void testSHA1WithRSACounterSignature()
    throws Exception
{
    List certList = new ArrayList();
    List crlList = new ArrayList();
    CMSTypedData        msg = new CMSProcessableByteArray("Hello World!".getBytes());

    certList.add(_signCert);
    certList.add(_origCert);

    crlList.add(_signCrl);

    Store           certStore = new JcaCertStore(certList);
    Store           crlStore = new JcaCRLStore(crlList);

    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

    ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_signKP.getPrivate());

    gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _signCert));

    gen.addCertificates(certStore);
    gen.addCRLs(crlStore);
    
    CMSSignedData s = gen.generate(msg, true);
    SignerInformation origSigner = (SignerInformation)s.getSignerInfos().getSigners().toArray()[0];
    SignerInformationStore counterSigners1 = gen.generateCounterSigners(origSigner);
    SignerInformationStore counterSigners2 = gen.generateCounterSigners(origSigner);

    SignerInformation signer1 = SignerInformation.addCounterSigners(origSigner, counterSigners1);
    SignerInformation signer2 = SignerInformation.addCounterSigners(signer1, counterSigners2);

    SignerInformationStore cs = signer2.getCounterSignatures();
    Collection csSigners = cs.getSigners();
    assertEquals(2, csSigners.size());

    Iterator it = csSigners.iterator();
    while (it.hasNext())
    {
        SignerInformation   cSigner = (SignerInformation)it.next();
        Collection certCollection = certStore.getMatches(cSigner.getSID());

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

        assertTrue(cSigner.isCounterSignature());
        assertNull(cSigner.getSignedAttributes().get(PKCSObjectIdentifiers.pkcs_9_at_contentType));
        assertEquals(true, cSigner.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:51,代码来源:BcSignedDataTest.java

示例3: testSHA1WithRSACounterSignature

import org.bouncycastle.cms.CMSSignedDataGenerator; //导入方法依赖的package包/类
public void testSHA1WithRSACounterSignature()
    throws Exception
{
    List                certList = new ArrayList();
    List                crlList = new ArrayList();
    CMSTypedData        msg = new CMSProcessableByteArray("Hello World!".getBytes());

    certList.add(_signCert);
    certList.add(_origCert);

    crlList.add(_signCrl);

    Store           certStore = new JcaCertStore(certList);
    Store           crlStore = new JcaCRLStore(crlList);

    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

    ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(_signKP.getPrivate());

    gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build()).build(sha1Signer, _signCert));

    gen.addCertificates(certStore);
    gen.addCRLs(crlStore);
    
    CMSSignedData s = gen.generate(msg, true);
    SignerInformation origSigner = (SignerInformation)s.getSignerInfos().getSigners().toArray()[0];
    SignerInformationStore counterSigners1 = gen.generateCounterSigners(origSigner);
    SignerInformationStore counterSigners2 = gen.generateCounterSigners(origSigner);

    SignerInformation signer1 = SignerInformation.addCounterSigners(origSigner, counterSigners1);
    SignerInformation signer2 = SignerInformation.addCounterSigners(signer1, counterSigners2);

    SignerInformationStore cs = signer2.getCounterSignatures();
    Collection csSigners = cs.getSigners();
    assertEquals(2, csSigners.size());

    Iterator it = csSigners.iterator();
    while (it.hasNext())
    {
        SignerInformation   cSigner = (SignerInformation)it.next();
        Collection          certCollection = certStore.getMatches(cSigner.getSID());

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

        assertTrue(cSigner.isCounterSignature());
        assertNull(cSigner.getSignedAttributes().get(PKCSObjectIdentifiers.pkcs_9_at_contentType));
        assertEquals(true, cSigner.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(cert)));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:51,代码来源:NewSignedDataTest.java


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