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


Java CMSTypedStream类代码示例

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


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

示例1: verifySignatures

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private void verifySignatures(CMSSignedDataParser sp)
    throws Exception
{
    CMSTypedStream sc = sp.getSignedContent();
    if (sc != null)
    {
        sc.drain();
    }
    
    CertStore               certs = sp.getCertificatesAndCRLs("Collection", BC);
    SignerInformationStore  signers = sp.getSignerInfos();

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

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

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

        verifySigner(signer, cert);
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:27,代码来源:Rfc4134Test.java

示例2: verifyData

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private void verifyData(
    ByteArrayOutputStream encodedStream,
    String                expectedOid,
    byte[]                expectedData)
    throws Exception
{
    CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(encodedStream.toByteArray());
    RecipientInformationStore  recipients = ep.getRecipientInfos();

    assertEquals(ep.getEncryptionAlgOID(), expectedOid);

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    while (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

        CMSTypedStream recData = recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC));

        assertEquals(true, Arrays.equals(expectedData, CMSTestUtil.streamToByteArray(recData.getContentStream())));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewEnvelopedDataStreamTest.java

示例3: verifyData

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private void verifyData(
    ByteArrayOutputStream encodedStream,
    String                expectedOid,
    byte[]                expectedData)
    throws Exception
{
    CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(encodedStream.toByteArray());
    RecipientInformationStore  recipients = ep.getRecipientInfos();

    assertEquals(ep.getEncryptionAlgOID(), expectedOid);
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();
    
    while (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());
        
        CMSTypedStream recData = recipient.getContentStream(_reciKP.getPrivate(), BC);
        
        assertEquals(true, Arrays.equals(expectedData, CMSTestUtil.streamToByteArray(recData.getContentStream())));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:EnvelopedDataStreamTest.java

示例4: getSignedInputStream

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private static CMSTypedStream getSignedInputStream(
    BodyPart    bodyPart,
    String      defaultContentTransferEncoding,
    File        backingFile)
    throws MessagingException
{
    try
    {
        OutputStream   out = new BufferedOutputStream(new FileOutputStream(backingFile));

        SMIMEUtil.outputBodyPart(out, bodyPart, defaultContentTransferEncoding);

        out.close();

        InputStream in = new TemporaryFileInputStream(backingFile);

        return new CMSTypedStream(in);
    }
    catch (IOException e)
    {
        throw new MessagingException("can't extract input stream: " + e);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:24,代码来源:SMIMESignedParser.java

示例5: SMIMESignedParser

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
/**
 * base constructor for a signed message with encapsulated content.
 * <p>
 * Note: in this case the encapsulated MimeBody part will only be suitable for a single
 * writeTo - once writeTo has been called the file containing the body part will be deleted. If writeTo is not
 * called the file will be left in the temp directory.
 * </p>
 * @param message the message containing the encapsulated signed data.
 * @exception MessagingException on an error extracting the signature or
 * otherwise processing the message.
 * @exception SMIMEException if the body part encapsulated in the message cannot be extracted.
 * @exception CMSException if some other problem occurs.
 * @deprecated use method that takes a DigestCalculatorProvider
 */
public SMIMESignedParser(
    Part message) 
    throws MessagingException, CMSException, SMIMEException
{
    super(getInputStream(message));

    this.message = message;

    CMSTypedStream  cont = this.getSignedContent();

    if (cont != null)
    {
        this.content = SMIMEUtil.toWriteOnceBodyPart(cont);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:30,代码来源:SMIMESignedParser.java

示例6: checkSigParseable

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private void checkSigParseable(byte[] sig)
    throws Exception
{
    CMSSignedDataParser sp = new CMSSignedDataParser(sig);
    sp.getVersion();
    CMSTypedStream sc = sp.getSignedContent();
    if (sc != null)
    {
        sc.drain();
    }
    sp.getCertificatesAndCRLs("Collection", BC);
    sp.getSignerInfos();
    sp.close();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:SignedDataStreamTest.java

示例7: testSHA1WithRSANoAttributes

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
public void testSHA1WithRSANoAttributes()
    throws Exception
{
    List                certList = new ArrayList();
    CMSProcessable      msg = new CMSProcessableByteArray(TEST_MESSAGE.getBytes());

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

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

    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

    gen.addSigner(_origKP.getPrivate(), _origCert, CMSSignedDataGenerator.DIGEST_SHA1);

    gen.addCertificatesAndCRLs(certs);

    CMSSignedData s = gen.generate(CMSSignedDataGenerator.DATA, msg, false, BC, false);

    CMSSignedDataParser     sp = new CMSSignedDataParser(
            new CMSTypedStream(new ByteArrayInputStream(TEST_MESSAGE.getBytes())), s.getEncoded());
    
    sp.getSignedContent().drain();
    
    //
    // compute expected content digest
    //
    MessageDigest md = MessageDigest.getInstance("SHA1", BC);
    
    verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:SignedDataStreamTest.java

示例8: testDSANoAttributes

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
public void testDSANoAttributes()
    throws Exception
{
    List                certList = new ArrayList();
    CMSProcessable      msg = new CMSProcessableByteArray(TEST_MESSAGE.getBytes());

    certList.add(_origDsaCert);
    certList.add(_signCert);

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

    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

    gen.addSigner(_origDsaKP.getPrivate(), _origDsaCert, CMSSignedDataGenerator.DIGEST_SHA1);

    gen.addCertificatesAndCRLs(certs);

    CMSSignedData s = gen.generate(CMSSignedDataGenerator.DATA, msg, false, BC, false);

    CMSSignedDataParser     sp = new CMSSignedDataParser(
            new CMSTypedStream(new ByteArrayInputStream(TEST_MESSAGE.getBytes())), s.getEncoded());
    
    sp.getSignedContent().drain();
    
    //
    // compute expected content digest
    //
    MessageDigest md = MessageDigest.getInstance("SHA1", BC);
    
    verifySignatures(sp, md.digest(TEST_MESSAGE.getBytes()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:SignedDataStreamTest.java

示例9: checkSigParseable

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
private void checkSigParseable(byte[] sig)
    throws Exception
{
    CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), sig);
    sp.getVersion();
    CMSTypedStream sc = sp.getSignedContent();
    if (sc != null)
    {
        sc.drain();
    }
    sp.getCertificates();
    sp.getCRLs();
    sp.getSignerInfos();
    sp.close();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:16,代码来源:NewSignedDataStreamTest.java

示例10: testRfc4_3

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
public void testRfc4_3()
    throws Exception
{
    byte[] data = getRfc4134Data("4.3.bin");
    CMSSignedData signedData = new CMSSignedData(new CMSProcessableByteArray(exContent), data);

    verifySignatures(signedData, sha1);

    CMSSignedDataParser parser = new CMSSignedDataParser(
            new CMSTypedStream(new ByteArrayInputStream(exContent)),
            data);

    verifySignatures(parser);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:Rfc4134Test.java

示例11: toMimeBodyPart

import org.bouncycastle.cms.CMSTypedStream; //导入依赖的package包/类
/**
 * return a file backed MimeBodyPart described in {@link CMSTypedStream} content. 
 * </p>
 */
public static FileBackedMimeBodyPart toMimeBodyPart(
    CMSTypedStream    content)
    throws SMIMEException
{
    try
    {
        return toMimeBodyPart(content, File.createTempFile("bcMail", ".mime"));
    }
    catch (IOException e)
    {
        throw new SMIMEException("IOException creating tmp file:" + e.getMessage(), e);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:SMIMEUtil.java


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