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


Java FileBackedMimeBodyPart类代码示例

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


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

示例1: testSHA1WithRSAEncapsulatedParserAndFile

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testSHA1WithRSAEncapsulatedParserAndFile()
    throws Exception
{
    File         tmp = File.createTempFile("bcTest", ".mime");
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);       
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res, tmp);
    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificates(), s.getSignerInfos());
    
    assertTrue(tmp.exists());
    
    s.close();
    
    content.dispose();
    
    assertFalse(tmp.exists());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:NewSMIMESignedTest.java

示例2: testSHA1WithRSAEncapsulatedParserAndFile

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testSHA1WithRSAEncapsulatedParserAndFile()
    throws Exception
{
    File         tmp = File.createTempFile("bcTest", ".mime");
    MimeBodyPart res = generateEncapsulatedRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);       
    SMIMESignedParser s = new SMIMESignedParser(res, tmp);
    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();

    verifyMessageBytes(msg, s.getContent());

    verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    
    assertTrue(tmp.exists());
    
    s.close();
    
    content.dispose();
    
    assertFalse(tmp.exists());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:SMIMESignedTest.java

示例3: toMimeBodyPart

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的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

示例4: testQuotePrintableSigPreservation

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testQuotePrintableSigPreservation()
    throws Exception
{
    MimeMessage msg = new MimeMessage((Session)null, getClass().getResourceAsStream("qp-soft-break.eml"));

    SMIMEEnvelopedGenerator  encGen = new SMIMEEnvelopedGenerator();

    encGen.addKeyTransRecipient(origCert);

    MimeBodyPart   mp = encGen.generate(msg, SMIMEEnvelopedGenerator.AES128_CBC, "BC");

    SMIMEEnveloped       env = new SMIMEEnveloped(mp);
    RecipientInformation ri = (RecipientInformation)env.getRecipientInfos().getRecipients().iterator().next();
    MimeBodyPart         mm = SMIMEUtil.toMimeBodyPart(ri.getContentStream(origKP.getPrivate(), "BC"));
    SMIMESigned          s = new SMIMESigned((MimeMultipart)mm.getContent());
    Collection           c = s.getSignerInfos().getSigners();
    Iterator             it = c.iterator();
    CertStore            certs = s.getCertificatesAndCRLs("Collection", "BC");

    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();

        assertEquals(true, signer.verify(cert, "BC"));
    }

    ((FileBackedMimeBodyPart)mm).dispose();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:SMIMEMiscTest.java

示例5: testSHA1WithRSAEncapsulatedParser

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testSHA1WithRSAEncapsulatedParser()
    throws Exception
{
    MimeBodyPart res = generateEncapsulatedRsa("SHA1withRSA", msg);
    SMIMESignedParser s = new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(), res);

    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();
    
    verifyMessageBytes(msg, content);

    content.dispose();
    
    verifySigners(s.getCertificates(), s.getSignerInfos());
    
    s.close();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:17,代码来源:NewSMIMESignedTest.java

示例6: testSHA1WithRSAEncapsulatedParser

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testSHA1WithRSAEncapsulatedParser()
    throws Exception
{
    MimeBodyPart res = generateEncapsulatedRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);       
    SMIMESignedParser s = new SMIMESignedParser(res);

    FileBackedMimeBodyPart content = (FileBackedMimeBodyPart)s.getContent();
    
    verifyMessageBytes(msg, content);

    content.dispose();
    
    verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    
    s.close();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:17,代码来源:SMIMESignedTest.java

示例7: testTwoRecipients

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testTwoRecipients()
    throws Exception
{
    MimeBodyPart    _msg      = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");

    SMIMEEnvelopedGenerator   gen = new SMIMEEnvelopedGenerator();
      
    gen.addKeyTransRecipient(_reciCert);
    gen.addKeyTransRecipient(_reciCert2);
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //
    MimeBodyPart mp = gen.generate(_msg, SMIMEEnvelopedGenerator.RC2_CBC, 40, "BC");

    SMIMEEnvelopedParser       m = new SMIMEEnvelopedParser(mp);

    RecipientId                recId = getRecipientId(_reciCert2);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);
    
    FileBackedMimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(_reciKP2.getPrivate(), "BC"));

    verifyMessageBytes(_msg, res);
    
    m = new SMIMEEnvelopedParser(mp);

    res.dispose();
    
    recId = getRecipientId(_reciCert);

    recipients = m.getRecipientInfos();
    recipient = recipients.get(recId);
 
    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(_reciKP.getPrivate(), "BC"));

    verifyMessageBytes(_msg, res);
    
    res.dispose();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:43,代码来源:SMIMEEnvelopedTest.java

示例8: testTwoRecipients

import org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart; //导入依赖的package包/类
public void testTwoRecipients()
    throws Exception
{
    MimeBodyPart    _msg      = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");

    SMIMEEnvelopedGenerator   gen = new SMIMEEnvelopedGenerator();

    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert2).setProvider(BC));
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //
    MimeBodyPart mp = gen.generate(_msg, new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC, 40).setProvider(BC).build());

    SMIMEEnvelopedParser       m = new SMIMEEnvelopedParser(mp);

    RecipientId                recId = getRecipientId(_reciCert2);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);
    
    FileBackedMimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP2.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);
    
    m = new SMIMEEnvelopedParser(mp);

    res.dispose();
    
    recId = getRecipientId(_reciCert);

    recipients = m.getRecipientInfos();
    recipient = recipients.get(recId);
 
    res = SMIMEUtil.toMimeBodyPart(recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);
    
    res.dispose();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:43,代码来源:NewSMIMEEnvelopedTest.java


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